spontaneous 0.2.0.alpha2 → 0.2.0.alpha3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (404) hide show
  1. data/Gemfile +3 -40
  2. data/Rakefile +29 -41
  3. data/Readme.markdown +21 -8
  4. data/application/css/add_alias_dialogue.css.scss +79 -0
  5. data/application/css/{v2.scss → core.css.scss} +537 -550
  6. data/application/css/{definitions.scss → definitions.css.scss} +121 -33
  7. data/application/css/dialogue.css.scss +409 -0
  8. data/application/css/{editing.scss → editing.css.scss} +25 -262
  9. data/application/css/font.css.scss +8 -0
  10. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  11. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  12. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_flat_10_000000_40x100.png +0 -0
  13. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  14. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  15. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  16. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  17. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  18. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  19. data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_222222_256x240.png +0 -0
  20. data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_228ef1_256x240.png +0 -0
  21. data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_ef8c08_256x240.png +0 -0
  22. data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_ffd27a_256x240.png +0 -0
  23. data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_ffffff_256x240.png +0 -0
  24. data/application/css/jquery-ui-1.8.21.custom/ui-lightness.css.scss +565 -0
  25. data/application/css/{login.scss → login.css.scss} +4 -4
  26. data/application/css/meta.css.scss +331 -0
  27. data/application/css/{popover.scss → popover.css.scss} +9 -8
  28. data/application/css/{schema_error.scss → schema_error.css.scss} +4 -4
  29. data/application/css/spontaneous.css +5 -0
  30. data/application/css/unsupported.css.scss +42 -0
  31. data/application/js/add_alias_dialogue.js +72 -10
  32. data/application/js/ajax.js +50 -16
  33. data/application/js/compatibility.js +19 -15
  34. data/application/js/content.js +39 -36
  35. data/application/js/content_area.js +53 -5
  36. data/application/js/dialogue.js +17 -0
  37. data/application/js/dom.js +1 -1
  38. data/application/js/edit_panel.js +23 -8
  39. data/application/js/extensions.js +7 -2
  40. data/application/js/field_preview.js +2 -1
  41. data/application/js/field_types/date_field.js +11 -8
  42. data/application/js/field_types/file_field.js +188 -9
  43. data/application/js/field_types/image_field.js +46 -29
  44. data/application/js/field_types/markdown_field.js +57 -14
  45. data/application/js/field_types/select_field.js +72 -0
  46. data/application/js/field_types/string_field.js +8 -0
  47. data/application/js/field_types/webvideo_field.js +8 -0
  48. data/application/js/init.js +1 -7
  49. data/application/js/location.js +41 -13
  50. data/application/js/login.js +3 -0
  51. data/application/js/meta_view/user_admin.js +543 -0
  52. data/application/js/meta_view.js +1 -0
  53. data/application/js/metadata.js +20 -0
  54. data/application/js/page.js +17 -3
  55. data/application/js/page_browser.js +40 -30
  56. data/application/js/page_entry.js +4 -0
  57. data/application/js/panel/root_menu.js +66 -0
  58. data/application/js/popover.js +2 -2
  59. data/application/js/preview.js +1 -1
  60. data/application/js/publish.js +138 -30
  61. data/application/js/services.js +43 -0
  62. data/application/js/sharded_upload.js +2 -2
  63. data/application/js/spontaneous.js +64 -5
  64. data/application/js/state.js +20 -9
  65. data/application/js/top_bar.js +273 -150
  66. data/application/js/types.js +20 -15
  67. data/application/js/upload.js +1 -2
  68. data/application/js/user.js +18 -4
  69. data/application/js/vendor/date.js +104 -0
  70. data/application/js/vendor/jquery-ui-1.8.18.custom.min.js +356 -0
  71. data/application/js/views/box_view.js +15 -8
  72. data/application/js/views/page_piece_view.js +11 -8
  73. data/application/js/views/page_view.js +21 -3
  74. data/application/js/views/piece_view.js +19 -10
  75. data/application/js/views.js +3 -0
  76. data/application/static/chromelogo-200x52-45c7cbc93be080bea342df5fcda2ef8b.png +0 -0
  77. data/application/static/dot-texture-9eea29e4ac7ad9a772285252078ec127.png +0 -0
  78. data/application/static/editing-textarea-resize-s-b5af62365eb7e19ea4beccf7242d508e.png +0 -0
  79. data/application/static/editing-texture-1-42b06a3439752490988f30f2a06d5e7c.png +0 -0
  80. data/application/static/font/fontawesome-webfont-5c5c21100a346972a82c34c5e96ffcfe.ttf +0 -0
  81. data/application/static/loop_alt1-white-7894b458528e92216196cae26b4c2c96.svg +12 -0
  82. data/application/static/spontaneous-states-e91ec89db525c62da0105b97cdd781ce.png +0 -0
  83. data/application/views/index.erb +2 -2
  84. data/application/views/login.erb +4 -8
  85. data/application/views/schema_modification_error.html.erb +1 -4
  86. data/application/views/unsupported.erb +9 -7
  87. data/bin/spot +1 -1
  88. data/db/migrations/20110209152710_users_and_groups.rb +10 -10
  89. data/db/migrations/20120305112647_site_modification_time.rb +11 -0
  90. data/db/migrations/20120418153903_add_ownership_of_content.rb +14 -0
  91. data/db/migrations/20120423175416_add_pending_modifications.rb +21 -0
  92. data/db/migrations/20120525164947_add_field_versions.rb +27 -0
  93. data/lib/sequel/plugins/scoped_table_name.rb +10 -1
  94. data/lib/spontaneous/asset/file.rb +25 -0
  95. data/lib/spontaneous/asset/source.rb +28 -0
  96. data/lib/spontaneous/asset.rb +75 -0
  97. data/lib/spontaneous/box.rb +6 -4
  98. data/lib/spontaneous/capistrano/deploy.rb +47 -0
  99. data/lib/spontaneous/capistrano/sync.rb +81 -0
  100. data/lib/spontaneous/capistrano.rb +13 -0
  101. data/lib/spontaneous/change.rb +60 -68
  102. data/lib/spontaneous/cli/assets.rb +29 -0
  103. data/lib/spontaneous/cli/base.rb +0 -48
  104. data/lib/spontaneous/cli/console.rb +1 -1
  105. data/lib/spontaneous/cli/server.rb +6 -4
  106. data/lib/spontaneous/cli/site.rb +28 -17
  107. data/lib/spontaneous/cli/user.rb +107 -0
  108. data/lib/spontaneous/cli.rb +100 -4
  109. data/lib/spontaneous/collections/entry_set.rb +2 -2
  110. data/lib/spontaneous/collections/field_set.rb +48 -22
  111. data/lib/spontaneous/collections/prototype_set.rb +20 -13
  112. data/lib/spontaneous/constants.rb +3 -0
  113. data/lib/spontaneous/content.rb +22 -5
  114. data/lib/spontaneous/errors.rb +3 -3
  115. data/lib/spontaneous/extensions/array.rb +12 -0
  116. data/lib/spontaneous/extensions/enumerable.rb +30 -0
  117. data/lib/spontaneous/extensions/nil.rb +3 -1
  118. data/lib/spontaneous/extensions/string.rb +16 -0
  119. data/lib/spontaneous/field_types/date_field.rb +45 -2
  120. data/lib/spontaneous/field_types/field.rb +42 -9
  121. data/lib/spontaneous/field_types/file_field.rb +68 -0
  122. data/lib/spontaneous/field_types/image_field.rb +63 -0
  123. data/lib/spontaneous/field_types/select_field.rb +109 -0
  124. data/lib/spontaneous/field_types/string_field.rb +6 -1
  125. data/lib/spontaneous/field_types/webvideo_field.rb +85 -27
  126. data/lib/spontaneous/field_types.rb +1 -1
  127. data/lib/spontaneous/field_version.rb +8 -0
  128. data/lib/spontaneous/generators/page.rb +1 -1
  129. data/lib/spontaneous/generators/site/Capfile.tt +1 -4
  130. data/lib/spontaneous/generators/site/Gemfile.tt +13 -6
  131. data/lib/spontaneous/generators/site/config/deploy.rb.tt +28 -0
  132. data/lib/spontaneous/generators/site/config/environments/production.rb.tt +7 -2
  133. data/lib/spontaneous/generators/site.rb +1 -0
  134. data/lib/spontaneous/json.rb +34 -11
  135. data/lib/spontaneous/layout.rb +22 -0
  136. data/lib/spontaneous/media/file.rb +4 -0
  137. data/lib/spontaneous/output/assets/compression.rb +58 -0
  138. data/lib/spontaneous/output/assets.rb +32 -0
  139. data/lib/spontaneous/output/context.rb +179 -0
  140. data/lib/spontaneous/output/format/html.rb +5 -0
  141. data/lib/spontaneous/output/format/plain.rb +5 -0
  142. data/lib/spontaneous/output/format.rb +180 -0
  143. data/lib/spontaneous/output/helpers/classes_helper.rb +18 -0
  144. data/lib/spontaneous/{render/helpers/html_helper.rb → output/helpers/conditional_comment_helper.rb} +3 -12
  145. data/lib/spontaneous/output/helpers/script_helper.rb +73 -0
  146. data/lib/spontaneous/output/helpers/stylesheet_helper.rb +61 -0
  147. data/lib/spontaneous/output/helpers.rb +28 -0
  148. data/lib/spontaneous/output/template/engine.rb +59 -0
  149. data/lib/spontaneous/output/template/renderer.rb +153 -0
  150. data/lib/spontaneous/output/template.rb +21 -0
  151. data/lib/spontaneous/output.rb +163 -0
  152. data/lib/spontaneous/page.rb +2 -1
  153. data/lib/spontaneous/paths.rb +6 -1
  154. data/lib/spontaneous/permissions/access_key.rb +5 -5
  155. data/lib/spontaneous/permissions/user.rb +81 -35
  156. data/lib/spontaneous/permissions/user_level.rb +26 -22
  157. data/lib/spontaneous/plugins/aliases.rb +76 -12
  158. data/lib/spontaneous/plugins/allowed_types.rb +60 -18
  159. data/lib/spontaneous/plugins/application/paths.rb +0 -28
  160. data/lib/spontaneous/plugins/application/system.rb +35 -0
  161. data/lib/spontaneous/plugins/boxes.rb +4 -0
  162. data/lib/spontaneous/plugins/content_groups.rb +16 -0
  163. data/lib/spontaneous/plugins/entries.rb +50 -30
  164. data/lib/spontaneous/plugins/fields.rb +15 -0
  165. data/lib/spontaneous/plugins/layouts.rb +8 -2
  166. data/lib/spontaneous/plugins/modifications.rb +228 -0
  167. data/lib/spontaneous/plugins/page/formats.rb +67 -42
  168. data/lib/spontaneous/plugins/page/request.rb +10 -0
  169. data/lib/spontaneous/plugins/page/site_timestamps.rb +28 -0
  170. data/lib/spontaneous/plugins/paths.rb +15 -3
  171. data/lib/spontaneous/plugins/publishing.rb +124 -45
  172. data/lib/spontaneous/plugins/render.rb +13 -8
  173. data/lib/spontaneous/plugins/schema_hierarchy.rb +18 -6
  174. data/lib/spontaneous/plugins/site/helpers.rb +53 -0
  175. data/lib/spontaneous/plugins/site/hooks.rb +50 -0
  176. data/lib/spontaneous/plugins/site/map.rb +1 -1
  177. data/lib/spontaneous/plugins/site/paths.rb +13 -0
  178. data/lib/spontaneous/plugins/site/publishing.rb +6 -2
  179. data/lib/spontaneous/plugins/site/{revisions.rb → state.rb} +5 -1
  180. data/lib/spontaneous/plugins/site/storage.rb +4 -0
  181. data/lib/spontaneous/plugins/site/url.rb +15 -0
  182. data/lib/spontaneous/plugins/site_map.rb +13 -3
  183. data/lib/spontaneous/plugins/styles.rb +5 -1
  184. data/lib/spontaneous/plugins/visibility.rb +39 -12
  185. data/lib/spontaneous/prototypes/box_prototype.rb +4 -0
  186. data/lib/spontaneous/prototypes/field_prototype.rb +15 -10
  187. data/lib/spontaneous/publishing/event_client.rb +46 -0
  188. data/lib/spontaneous/publishing/immediate.rb +81 -44
  189. data/lib/spontaneous/publishing/simultaneous.rb +23 -6
  190. data/lib/spontaneous/publishing.rb +4 -3
  191. data/lib/spontaneous/rack/around_back.rb +1 -5
  192. data/lib/spontaneous/rack/around_front.rb +4 -4
  193. data/lib/spontaneous/rack/around_preview.rb +4 -3
  194. data/lib/spontaneous/rack/assets.rb +81 -54
  195. data/lib/spontaneous/rack/authentication.rb +0 -1
  196. data/lib/spontaneous/rack/back.rb +160 -72
  197. data/lib/spontaneous/rack/cookie_authentication.rb +2 -2
  198. data/lib/spontaneous/rack/css.rb +18 -15
  199. data/lib/spontaneous/rack/event_source.rb +9 -21
  200. data/lib/spontaneous/rack/fiber_pool.rb +26 -0
  201. data/lib/spontaneous/rack/front.rb +12 -4
  202. data/lib/spontaneous/rack/helpers.rb +35 -13
  203. data/lib/spontaneous/rack/js.rb +41 -0
  204. data/lib/spontaneous/rack/public.rb +34 -44
  205. data/lib/spontaneous/rack/sse.rb +18 -0
  206. data/lib/spontaneous/rack/static.rb +3 -0
  207. data/lib/spontaneous/rack/user_admin.rb +100 -0
  208. data/lib/spontaneous/rack/user_helpers.rb +1 -1
  209. data/lib/spontaneous/rack.rb +6 -2
  210. data/lib/spontaneous/schema.rb +31 -4
  211. data/lib/spontaneous/search/index.rb +19 -3
  212. data/lib/spontaneous/search/results.rb +1 -1
  213. data/lib/spontaneous/sequel.rb +17 -0
  214. data/lib/spontaneous/site.rb +11 -4
  215. data/lib/spontaneous/state.rb +11 -0
  216. data/lib/spontaneous/storage/cloud.rb +4 -0
  217. data/lib/spontaneous/storage/local.rb +11 -0
  218. data/lib/spontaneous/style.rb +2 -2
  219. data/lib/spontaneous/tasks/database.rake +21 -22
  220. data/lib/spontaneous/utils/database/mysql_dumper.rb +4 -0
  221. data/lib/spontaneous/utils/database/postgres_dumper.rb +78 -0
  222. data/lib/spontaneous/utils/database.rb +6 -3
  223. data/lib/spontaneous/utils/smart_quotes.rb +499 -0
  224. data/lib/spontaneous/utils/smush_it.rb +66 -0
  225. data/lib/spontaneous/utils.rb +3 -1
  226. data/lib/spontaneous/version.rb +2 -2
  227. data/lib/spontaneous.rb +25 -29
  228. data/spontaneous.gemspec +186 -106
  229. data/test/experimental/test_features.rb +1 -1
  230. data/test/fixtures/asset_pipeline/application/css/basic.css.scss +4 -0
  231. data/test/fixtures/asset_pipeline/application/css/complex.css.scss.erb +6 -0
  232. data/test/fixtures/asset_pipeline/application/css/simple.css +3 -0
  233. data/test/fixtures/asset_pipeline/application/css/spontaneous.css +7 -0
  234. data/test/fixtures/asset_pipeline/application/css/subdir/complex.css.scss.erb +6 -0
  235. data/test/fixtures/asset_pipeline/application/css/subdir/library.css.scss +1 -0
  236. data/test/fixtures/asset_pipeline/application/css/subdir/simple.css +3 -0
  237. data/test/fixtures/asset_pipeline/application/js/basic.js.coffee +1 -0
  238. data/test/fixtures/asset_pipeline/application/js/complex.js.coffee.erb +1 -0
  239. data/test/fixtures/asset_pipeline/application/js/login.js +1 -0
  240. data/test/fixtures/asset_pipeline/application/js/require.js +1 -0
  241. data/test/fixtures/asset_pipeline/application/js/simple.js +1 -0
  242. data/test/fixtures/asset_pipeline/application/js/spontaneous.js +5 -0
  243. data/test/fixtures/asset_pipeline/application/js/subdir/complex.js.coffee.erb +1 -0
  244. data/test/fixtures/asset_pipeline/application/js/subdir/library.js.coffee +1 -0
  245. data/test/fixtures/asset_pipeline/application/js/subdir/simple.js +1 -0
  246. data/test/fixtures/asset_pipeline/application/js/vendor/jquery.js +1 -0
  247. data/test/fixtures/asset_pipeline/application/static/dot-texture.png +0 -0
  248. data/test/fixtures/asset_pipeline/application/static/subdir/px.gif +0 -0
  249. data/test/fixtures/assets/public1/css/a.scss +1 -0
  250. data/test/fixtures/assets/public1/js/a.js +1 -0
  251. data/test/fixtures/assets/public1/js/m.coffee +1 -0
  252. data/test/fixtures/assets/public2/css/b.scss +1 -0
  253. data/test/fixtures/assets/public2/css/c.css +1 -0
  254. data/test/fixtures/assets/public2/js/b.js +1 -0
  255. data/test/fixtures/assets/public2/js/c.js +1 -0
  256. data/test/fixtures/assets/public2/js/n.coffee +1 -0
  257. data/test/fixtures/back/config/user_levels.yml +3 -0
  258. data/test/fixtures/back/public/js/coffeescript.coffee +1 -0
  259. data/test/fixtures/back/templates/layouts/standard.css.cut +1 -0
  260. data/test/fixtures/back/templates/layouts/standard.js.cut +1 -0
  261. data/test/fixtures/example_application/config/database.yml +4 -4
  262. data/test/fixtures/helpers/templates/layouts/standard.html.cut +1 -0
  263. data/test/fixtures/helpers/templates/layouts/standard.mobile.cut +1 -0
  264. data/test/fixtures/images/vimlogo.pdf +0 -0
  265. data/test/fixtures/outputs/templates/layouts/standard.atom.cut +1 -0
  266. data/test/fixtures/permissions/config/user_levels.yml +6 -3
  267. data/test/fixtures/serialisation/class_hash.yaml.erb +1 -0
  268. data/test/fixtures/serialisation/root_hash.yaml.erb +2 -2
  269. data/test/fixtures/templates/extended/grandparent.html.cut +7 -7
  270. data/test/fixtures/templates/extended/main.html.cut +5 -5
  271. data/test/fixtures/templates/extended/parent.html.cut +8 -8
  272. data/test/fixtures/templates/extended/partial_with_locals.html.cut +1 -1
  273. data/test/fixtures/templates/extended/with_includes.html.cut +6 -6
  274. data/test/fixtures/templates/extended/with_includes_and_locals.html.cut +6 -7
  275. data/test/fixtures/templates/layouts/entries.html.cut +4 -4
  276. data/test/fixtures/templates/layouts/standard.html.cut +1 -0
  277. data/test/fixtures/templates/layouts/variables.html.cut +1 -1
  278. data/test/fixtures/templates/publishing/templates/layouts/static.html.cut +1 -1
  279. data/test/fixtures/templates/publishing/templates/layouts/static.rtf.cut +1 -0
  280. data/test/fixtures/templates/template_class/complex_template.html.cut +2 -2
  281. data/test/fixtures/templates/template_class/complex_template.pdf.cut +2 -2
  282. data/test/fixtures/templates/template_class/default_template_style.html.cut +1 -1
  283. data/test/fixtures/templates/template_class/images_with_template.html.cut +2 -2
  284. data/test/fixtures/templates/template_class/slots_template.html.cut +2 -2
  285. data/test/fixtures/templates/template_class/slots_template.pdf.cut +2 -2
  286. data/test/fixtures/user_manager/config/user_levels.yml +9 -0
  287. data/test/functional/test_application.rb +7 -7
  288. data/test/functional/test_back.rb +352 -97
  289. data/test/functional/test_front.rb +71 -20
  290. data/test/functional/test_user_manager.rb +284 -0
  291. data/test/javascript/env.js +13505 -0
  292. data/test/javascript/test_markdown.rb +43 -3
  293. data/test/support/custom_matchers.rb +3 -2
  294. data/test/test_helper.rb +50 -9
  295. data/test/test_javascript.rb +13 -13
  296. data/test/ui_helper.rb +1 -1
  297. data/test/unit/test_alias.rb +79 -8
  298. data/test/unit/test_asset_bundler.rb +220 -0
  299. data/test/unit/test_assets.rb +213 -0
  300. data/test/unit/test_async.rb +55 -0
  301. data/test/unit/test_authentication.rb +52 -39
  302. data/test/unit/test_boxes.rb +20 -15
  303. data/test/unit/test_changesets.rb +261 -0
  304. data/test/unit/test_content.rb +73 -33
  305. data/test/unit/test_content_inheritance.rb +18 -18
  306. data/test/unit/test_extensions.rb +26 -0
  307. data/test/unit/test_fields.rb +303 -16
  308. data/test/unit/test_formats.rb +267 -34
  309. data/test/unit/test_helpers.rb +79 -2
  310. data/test/unit/test_images.rb +10 -0
  311. data/test/unit/test_layouts.rb +21 -13
  312. data/test/unit/test_modifications.rb +648 -0
  313. data/test/unit/test_page.rb +6 -2
  314. data/test/unit/test_permissions.rb +101 -27
  315. data/test/unit/test_piece.rb +4 -4
  316. data/test/unit/test_plugins.rb +3 -2
  317. data/test/unit/test_publishing.rb +332 -0
  318. data/test/unit/test_render.rb +118 -67
  319. data/test/unit/test_revisions.rb +546 -0
  320. data/test/unit/test_schema.rb +83 -1
  321. data/test/unit/test_search.rb +59 -0
  322. data/test/unit/test_serialisation.rb +2 -47
  323. data/test/unit/test_site.rb +217 -108
  324. data/test/unit/test_storage.rb +26 -0
  325. data/test/unit/test_structure.rb +2 -2
  326. data/test/unit/test_styles.rb +90 -75
  327. data/test/unit/test_table_scoping.rb +21 -17
  328. data/test/unit/test_templates.rb +75 -69
  329. data/test/{slow → unit}/test_visibility.rb +78 -22
  330. metadata +528 -221
  331. data/application/css/add_alias_dialogue.scss +0 -27
  332. data/application/css/min/14c2a35812c443001b15d8b12a4780f88c678035.css +0 -1
  333. data/application/css/min/565d4c25e82148acb01c45c8d675b37a08676d77.css +0 -1
  334. data/application/css/min/84dbe894ea96eafd321c30823d630817bfc4b03b.css +0 -1
  335. data/application/css/spontaneous.scss +0 -111
  336. data/application/css/unsupported.scss +0 -16
  337. data/application/css/variables.scss +0 -80
  338. data/application/js/min/2a0c2962537a3181fedfff5c92596ba6d3122dc9.js +0 -3
  339. data/application/js/min/4cf1c493d3379ecba5287758c61238034c0893f9.js +0 -2
  340. data/application/js/min/78ac6b99d96750bb6b9f9aad4cb9cd91cd03f391.js +0 -3
  341. data/application/js/min/b8abf302a824c35385ff517b34111e1710ff3b37.js +0 -2
  342. data/application/js/min/c8efb9b9f7c3f6613fcebc6be60f605b6570a382.js +0 -90
  343. data/application/static/diagonal-texture.png +0 -0
  344. data/application/static/editing-0-noise.png +0 -0
  345. data/application/static/editing-1-noise.png +0 -0
  346. data/application/static/editing-texture-1.png +0 -0
  347. data/application/static/editing-texture.png +0 -0
  348. data/application/static/editing-toolbar-shadow-bottom.png +0 -0
  349. data/application/static/editing-toolbar-shadow-top.png +0 -0
  350. data/application/static/inner-glow.png +0 -0
  351. data/application/static/item-buttons-highlight.png +0 -0
  352. data/application/static/item-buttons.png +0 -0
  353. data/application/static/paper-texture-dark.png +0 -0
  354. data/application/static/plus_alt.svg +0 -8
  355. data/application/static/select-arrow-root.png +0 -0
  356. data/application/static/slot-up-arrow.png +0 -0
  357. data/application/static/spontaneous.png +0 -0
  358. data/lib/cutaneous/context_helper.rb +0 -187
  359. data/lib/cutaneous/preview_context.rb +0 -32
  360. data/lib/cutaneous/preview_renderer.rb +0 -10
  361. data/lib/cutaneous/publish_context.rb +0 -10
  362. data/lib/cutaneous/publish_renderer.rb +0 -14
  363. data/lib/cutaneous/publish_template.rb +0 -62
  364. data/lib/cutaneous/publish_token_parser.rb +0 -8
  365. data/lib/cutaneous/renderer.rb +0 -124
  366. data/lib/cutaneous/request_context.rb +0 -9
  367. data/lib/cutaneous/request_renderer.rb +0 -15
  368. data/lib/cutaneous/request_template.rb +0 -11
  369. data/lib/cutaneous/request_token_parser.rb +0 -9
  370. data/lib/cutaneous/token_parser.rb +0 -125
  371. data/lib/cutaneous.rb +0 -48
  372. data/lib/spontaneous/render/context_base.rb +0 -143
  373. data/lib/spontaneous/render/development_renderer.rb +0 -14
  374. data/lib/spontaneous/render/engine.rb +0 -19
  375. data/lib/spontaneous/render/format/html.rb +0 -5
  376. data/lib/spontaneous/render/format.rb +0 -75
  377. data/lib/spontaneous/render/helpers/script_helper.rb +0 -17
  378. data/lib/spontaneous/render/helpers/stylesheet_helper.rb +0 -16
  379. data/lib/spontaneous/render/helpers.rb +0 -14
  380. data/lib/spontaneous/render/preview_context.rb +0 -8
  381. data/lib/spontaneous/render/preview_renderer.rb +0 -24
  382. data/lib/spontaneous/render/publish_context.rb +0 -22
  383. data/lib/spontaneous/render/published_renderer.rb +0 -53
  384. data/lib/spontaneous/render/publishing_renderer.rb +0 -16
  385. data/lib/spontaneous/render/render_cache.rb +0 -26
  386. data/lib/spontaneous/render/renderer.rb +0 -50
  387. data/lib/spontaneous/render/request_context.rb +0 -8
  388. data/lib/spontaneous/render.rb +0 -214
  389. data/test/experimental/test_cutaneous.rb +0 -309
  390. data/test/fixtures/application/css/test.less +0 -5
  391. data/test/slow/test_publishing.rb +0 -1006
  392. /data/application/css/{developer.scss → developer.css.scss} +0 -0
  393. /data/application/js/vendor/{jquery-1.7.1.min.js → jquery.js} +0 -0
  394. /data/application/static/{location-arrow.png → location-arrow-c1c1d3ca472481c61a0a5f8cb289d743.png} +0 -0
  395. /data/application/static/{missing.png → missing-911ce6dbd9f4602e0f3fbcd7e78846a2.png} +0 -0
  396. /data/application/static/{orange-down-arrow.png → orange-down-arrow-395ae1929e8662b2ff0977daf12c35bb.png} +0 -0
  397. /data/application/static/{page-browser-next.png → page-browser-next-ce781a242c23b980b99b9db7abc20b05.png} +0 -0
  398. /data/application/static/{plus-box.png → plus-box-dcde74a1e496f68298c9b443caa1c5d5.png} +0 -0
  399. /data/application/static/{select-arrow.png → select-arrow-6e7dd3745b00e934b0d7a3250c46558b.png} +0 -0
  400. /data/application/static/{slot-down-arrow.png → slot-down-arrow-59ad5f5ee5b52a7ebd00bca4b3104194.png} +0 -0
  401. /data/application/static/{splash.png → splash-65b493a714df9b8b3ab170103401b53d.png} +0 -0
  402. /data/application/static/{spot.png → spot-71fab1d2f065034f5fc15e7bea2ad36c.png} +0 -0
  403. /data/application/static/{spot.svg → spot-8505041082d8d3bbe8d34c29dddb3b7d.svg} +0 -0
  404. /data/application/static/{texture.png → texture-03f7627e8264b1d607113ab32c593a58.png} +0 -0
@@ -1,90 +0,0 @@
1
- /*
2
- * jQuery UI 1.8.16
3
- *
4
- * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
- * Dual licensed under the MIT or GPL Version 2 licenses.
6
- * http://jquery.org/license
7
- *
8
- * http://docs.jquery.com/UI
9
- */
10
- (function(e,d){function b(f,c){var g=f.nodeName.toLowerCase();if("area"===g){c=f.parentNode;g=c.name;if(!f.href||!g||c.nodeName.toLowerCase()!=="map"){return false}f=e("img[usemap=#"+g+"]")[0];return !!f&&a(f)}return(/input|select|textarea|button|object/.test(g)?!f.disabled:"a"==g?f.href||c:c)&&a(f)}function a(c){return !e(c).parents().andSelf().filter(function(){return e.curCSS(this,"visibility")==="hidden"||e.expr.filters.hidden(this)}).length}e.ui=e.ui||{};if(!e.ui.version){e.extend(e.ui,{version:"1.8.16",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});e.fn.extend({propAttr:e.fn.prop||e.fn.attr,_focus:e.fn.focus,focus:function(f,c){return typeof f==="number"?this.each(function(){var g=this;setTimeout(function(){e(g).focus();c&&c.call(g)},f)}):this._focus.apply(this,arguments)},scrollParent:function(){var c;c=e.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.curCSS(this,"position",1))&&/(auto|scroll)/.test(e.curCSS(this,"overflow",1)+e.curCSS(this,"overflow-y",1)+e.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(e.curCSS(this,"overflow",1)+e.curCSS(this,"overflow-y",1)+e.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!c.length?e(document):c},zIndex:function(f){if(f!==d){return this.css("zIndex",f)}if(this.length){f=e(this[0]);for(var c;f.length&&f[0]!==document;){c=f.css("position");if(c==="absolute"||c==="relative"||c==="fixed"){c=parseInt(f.css("zIndex"),10);if(!isNaN(c)&&c!==0){return c}}f=f.parent()}}return 0},disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(c){c.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});e.each(["Width","Height"],function(f,c){function l(o,i,h,p){e.each(k,function(){i-=parseFloat(e.curCSS(o,"padding"+this,true))||0;if(h){i-=parseFloat(e.curCSS(o,"border"+this+"Width",true))||0}if(p){i-=parseFloat(e.curCSS(o,"margin"+this,true))||0}});return i}var k=c==="Width"?["Left","Right"]:["Top","Bottom"],j=c.toLowerCase(),g={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+c]=function(h){if(h===d){return g["inner"+c].call(this)}return this.each(function(){e(this).css(j,l(this,h)+"px")})};e.fn["outer"+c]=function(i,h){if(typeof i!=="number"){return g["outer"+c].call(this,i)}return this.each(function(){e(this).css(j,l(this,i,true,h)+"px")})}});e.extend(e.expr[":"],{data:function(f,c,g){return !!e.data(f,g[3])},focusable:function(c){return b(c,!isNaN(e.attr(c,"tabindex")))},tabbable:function(f){var c=e.attr(f,"tabindex"),g=isNaN(c);return(g||c>=0)&&b(f,!g)}});e(function(){var f=document.body,c=f.appendChild(c=document.createElement("div"));e.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});e.support.minHeight=c.offsetHeight===100;e.support.selectstart="onselectstart" in c;f.removeChild(c).style.display="none"});e.extend(e.ui,{plugin:{add:function(f,c,h){f=e.ui[f].prototype;for(var g in h){f.plugins[g]=f.plugins[g]||[];f.plugins[g].push([c,h[g]])}},call:function(f,c,h){if((c=f.plugins[c])&&f.element[0].parentNode){for(var g=0;g<c.length;g++){f.options[c[g][0]]&&c[g][1].apply(f.element,h)}}}},contains:function(f,c){return document.compareDocumentPosition?f.compareDocumentPosition(c)&16:f!==c&&f.contains(c)},hasScroll:function(f,c){if(e(f).css("overflow")==="hidden"){return false}c=c&&c==="left"?"scrollLeft":"scrollTop";var g=false;if(f[c]>0){return true}f[c]=1;g=f[c]>0;f[c]=0;return g},isOverAxis:function(f,c,g){return f>c&&f<c+g},isOver:function(f,c,l,k,j,g){return e.ui.isOverAxis(f,l,j)&&e.ui.isOverAxis(c,k,g)}})}})(jQuery);
11
- /*
12
- * jQuery UI Widget 1.8.16
13
- *
14
- * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
15
- * Dual licensed under the MIT or GPL Version 2 licenses.
16
- * http://jquery.org/license
17
- *
18
- * http://docs.jquery.com/UI/Widget
19
- */
20
- (function(a,e){if(a.cleanData){var d=a.cleanData;a.cleanData=function(b){for(var h=0,g;(g=b[h])!=null;h++){try{a(g).triggerHandler("remove")}catch(f){}}d(b)}}else{var c=a.fn.remove;a.fn.remove=function(b,f){return this.each(function(){if(!f){if(!b||a.filter(b,[this]).length){a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(g){}})}}return c.call(a(this),b,f)})}}a.widget=function(b,j,i){var h=b.split(".")[0],g;b=b.split(".")[1];g=h+"-"+b;if(!i){i=j;j=a.Widget}a.expr[":"][g]=function(f){return !!a.data(f,b)};a[h]=a[h]||{};a[h][b]=function(f,k){arguments.length&&this._createWidget(f,k)};j=new j;j.options=a.extend(true,{},j.options);a[h][b].prototype=a.extend(true,j,{namespace:h,widgetName:b,widgetEventPrefix:a[h][b].prototype.widgetEventPrefix||b,widgetBaseClass:g},i);a.widget.bridge(b,a[h][b])};a.widget.bridge=function(b,f){a.fn[b]=function(k){var j=typeof k==="string",i=Array.prototype.slice.call(arguments,1),g=this;k=!j&&i.length?a.extend.apply(null,[true,k].concat(i)):k;if(j&&k.charAt(0)==="_"){return g}j?this.each(function(){var l=a.data(this,b),h=l&&a.isFunction(l[k])?l[k].apply(l,i):l;if(h!==l&&h!==e){g=h;return false}}):this.each(function(){var h=a.data(this,b);h?h.option(k||{})._init():a.data(this,b,new f(k,this))});return g}};a.Widget=function(b,f){arguments.length&&this._createWidget(b,f)};a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(b,g){a.data(g,this.widgetName,this);this.element=a(g);this.options=a.extend(true,{},this.options,this._getCreateOptions(),b);var f=this;this.element.bind("remove."+this.widgetName,function(){f.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(b,g){var f=b;if(arguments.length===0){return a.extend({},this.options)}if(typeof b==="string"){if(g===e){return this.options[b]}f={};f[b]=g}this._setOptions(f);return this},_setOptions:function(b){var f=this;a.each(b,function(h,g){f._setOption(h,g)});return this},_setOption:function(b,f){this.options[b]=f;if(b==="disabled"){this.widget()[f?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",f)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(b,j,i){var h=this.options[b];j=a.Event(j);j.type=(b===this.widgetEventPrefix?b:this.widgetEventPrefix+b).toLowerCase();i=i||{};if(j.originalEvent){b=a.event.props.length;for(var g;b;){g=a.event.props[--b];j[g]=j.originalEvent[g]}}this.element.trigger(j,i);return !(a.isFunction(h)&&h.call(this.element[0],j,i)===false||j.isDefaultPrevented())}}})(jQuery);
21
- /*
22
- * jQuery UI Mouse 1.8.16
23
- *
24
- * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
25
- * Dual licensed under the MIT or GPL Version 2 licenses.
26
- * http://jquery.org/license
27
- *
28
- * http://docs.jquery.com/UI/Mouse
29
- *
30
- * Depends:
31
- * jquery.ui.widget.js
32
- */
33
- (function(a){var c=false;a(document).mouseup(function(){c=false});a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(d){return b._mouseDown(d)}).bind("click."+this.widgetName,function(d){if(true===a.data(d.target,b.widgetName+".preventClickEvent")){a.removeData(d.target,b.widgetName+".preventClickEvent");d.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(b){if(!c){this._mouseStarted&&this._mouseUp(b);this._mouseDownEvent=b;var h=this,e=b.which==1,d=typeof this.options.cancel=="string"&&b.target.nodeName?a(b.target).closest(this.options.cancel).length:false;if(!e||d||!this._mouseCapture(b)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){h.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){this._mouseStarted=this._mouseStart(b)!==false;if(!this._mouseStarted){b.preventDefault();return true}}true===a.data(b.target,this.widgetName+".preventClickEvent")&&a.removeData(b.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(f){return h._mouseMove(f)};this._mouseUpDelegate=function(f){return h._mouseUp(f)};a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);b.preventDefault();return c=true}},_mouseMove:function(b){if(a.browser.msie&&!(document.documentMode>=9)&&!b.button){return this._mouseUp(b)}if(this._mouseStarted){this._mouseDrag(b);return b.preventDefault()}if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==false)?this._mouseDrag(b):this._mouseUp(b)}return !this._mouseStarted},_mouseUp:function(b){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;b.target==this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",true);this._mouseStop(b)}return false},_mouseDistanceMet:function(b){return Math.max(Math.abs(this._mouseDownEvent.pageX-b.pageX),Math.abs(this._mouseDownEvent.pageY-b.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);(function(f){f.ui=f.ui||{};var e=/left|center|right/,d=/top|center|bottom/,b=f.fn.position,a=f.fn.offset;f.fn.position=function(c){if(!c||!c.of){return b.apply(this,arguments)}c=f.extend({},c);var i=f(c.of),q=i[0],o=(c.collision||"flip").split(" "),p=c.offset?c.offset.split(" "):[0,0],n,l,m;if(q.nodeType===9){n=i.width();l=i.height();m={top:0,left:0}}else{if(q.setTimeout){n=i.width();l=i.height();m={top:i.scrollTop(),left:i.scrollLeft()}}else{if(q.preventDefault){c.at="left top";n=l=0;m={top:c.of.pageY,left:c.of.pageX}}else{n=i.outerWidth();l=i.outerHeight();m=i.offset()}}}f.each(["my","at"],function(){var g=(c[this]||"").split(" ");if(g.length===1){g=e.test(g[0])?g.concat(["center"]):d.test(g[0])?["center"].concat(g):["center","center"]}g[0]=e.test(g[0])?g[0]:"center";g[1]=d.test(g[1])?g[1]:"center";c[this]=g});if(o.length===1){o[1]=o[0]}p[0]=parseInt(p[0],10)||0;if(p.length===1){p[1]=p[0]}p[1]=parseInt(p[1],10)||0;if(c.at[0]==="right"){m.left+=n}else{if(c.at[0]==="center"){m.left+=n/2}}if(c.at[1]==="bottom"){m.top+=l}else{if(c.at[1]==="center"){m.top+=l/2}}m.left+=p[0];m.top+=p[1];return this.each(function(){var x=f(this),s=x.outerWidth(),k=x.outerHeight(),j=parseInt(f.curCSS(this,"marginLeft",true))||0,h=parseInt(f.curCSS(this,"marginTop",true))||0,z=s+j+(parseInt(f.curCSS(this,"marginRight",true))||0),y=k+h+(parseInt(f.curCSS(this,"marginBottom",true))||0),u=f.extend({},m),g;if(c.my[0]==="right"){u.left-=s}else{if(c.my[0]==="center"){u.left-=s/2}}if(c.my[1]==="bottom"){u.top-=k}else{if(c.my[1]==="center"){u.top-=k/2}}u.left=Math.round(u.left);u.top=Math.round(u.top);g={left:u.left-j,top:u.top-h};f.each(["left","top"],function(v,r){f.ui.position[o[v]]&&f.ui.position[o[v]][r](u,{targetWidth:n,targetHeight:l,elemWidth:s,elemHeight:k,collisionPosition:g,collisionWidth:z,collisionHeight:y,offset:p,my:c.my,at:c.at})});f.fn.bgiframe&&x.bgiframe();x.offset(f.extend(u,{using:c.using}))})};f.ui.position={fit:{left:function(c,g){var h=f(window);h=g.collisionPosition.left+g.collisionWidth-h.width()-h.scrollLeft();c.left=h>0?c.left-h:Math.max(c.left-g.collisionPosition.left,c.left)},top:function(c,g){var h=f(window);h=g.collisionPosition.top+g.collisionHeight-h.height()-h.scrollTop();c.top=h>0?c.top-h:Math.max(c.top-g.collisionPosition.top,c.top)}},flip:{left:function(c,i){if(i.at[0]!=="center"){var m=f(window);m=i.collisionPosition.left+i.collisionWidth-m.width()-m.scrollLeft();var k=i.my[0]==="left"?-i.elemWidth:i.my[0]==="right"?i.elemWidth:0,l=i.at[0]==="left"?i.targetWidth:-i.targetWidth,j=-2*i.offset[0];c.left+=i.collisionPosition.left<0?k+l+j:m>0?k+l+j:0}},top:function(c,i){if(i.at[1]!=="center"){var m=f(window);m=i.collisionPosition.top+i.collisionHeight-m.height()-m.scrollTop();var k=i.my[1]==="top"?-i.elemHeight:i.my[1]==="bottom"?i.elemHeight:0,l=i.at[1]==="top"?i.targetHeight:-i.targetHeight,j=-2*i.offset[1];c.top+=i.collisionPosition.top<0?k+l+j:m>0?k+l+j:0}}}};if(!f.offset.setOffset){f.offset.setOffset=function(c,i){if(/static/.test(f.curCSS(c,"position"))){c.style.position="relative"}var m=f(c),k=m.offset(),l=parseInt(f.curCSS(c,"top",true),10)||0,j=parseInt(f.curCSS(c,"left",true),10)||0;k={top:i.top-k.top+l,left:i.left-k.left+j};"using" in i?i.using.call(c,k):m.css(k)};f.fn.offset=function(c){var g=this[0];if(!g||!g.ownerDocument){return null}if(c){return this.each(function(){f.offset.setOffset(this,c)})}return a.call(this)}}})(jQuery);(function(a){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper=="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))){this.element[0].style.position="relative"}this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(d){var c=this.options;if(this.helper||c.disabled||a(d.target).is(".ui-resizable-handle")){return false}this.handle=this._getHandle(d);if(!this.handle){return false}if(c.iframeFix){a(c.iframeFix===true?"iframe":c.iframeFix).each(function(){a('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css(a(this).offset()).appendTo("body")})}return true},_mouseStart:function(d){var c=this.options;this.helper=this._createHelper(d);this._cacheHelperProportions();if(a.ui.ddmanager){a.ui.ddmanager.current=this}this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};a.extend(this.offset,{click:{left:d.pageX-this.offset.left,top:d.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this.position=this._generatePosition(d);this.originalPageX=d.pageX;this.originalPageY=d.pageY;c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt);c.containment&&this._setContainment();if(this._trigger("start",d)===false){this._clear();return false}this._cacheHelperProportions();a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,d);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(d,true);a.ui.ddmanager&&a.ui.ddmanager.dragStart(this,d);return true},_mouseDrag:function(d,c){this.position=this._generatePosition(d);this.positionAbs=this._convertPositionTo("absolute");if(!c){c=this._uiHash();if(this._trigger("drag",d,c)===false){this._mouseUp({});return false}this.position=c.position}if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px"}a.ui.ddmanager&&a.ui.ddmanager.drag(this,d);return false},_mouseStop:function(e){var d=false;if(a.ui.ddmanager&&!this.options.dropBehaviour){d=a.ui.ddmanager.drop(this,e)}if(this.dropped){d=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original"){return false}if(this.options.revert=="invalid"&&!d||this.options.revert=="valid"&&d||this.options.revert===true||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,d)){var f=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){f._trigger("stop",e)!==false&&f._clear()})}else{this._trigger("stop",e)!==false&&this._clear()}return false},_mouseUp:function(b){this.options.iframeFix===true&&a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});a.ui.ddmanager&&a.ui.ddmanager.dragStop(this,b);return a.ui.mouse.prototype._mouseUp.call(this,b)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(d){var c=!this.options.handle||!a(this.options.handle,this.element).length?true:false;a(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==d.target){c=true}});return c},_createHelper:function(d){var c=this.options;d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[d])):c.helper=="clone"?this.element.clone().removeAttr("id"):this.element;d.parents("body").length||d.appendTo(c.appendTo=="parent"?this.element[0].parentNode:c.appendTo);d[0]!=this.element[0]&&!/(fixed|absolute)/.test(d.css("position"))&&d.css("position","absolute");return d},_adjustOffsetFromHelper:function(b){if(typeof b=="string"){b=b.split(" ")}if(a.isArray(b)){b={left:+b[0],top:+b[1]||0}}if("left" in b){this.offset.click.left=b.left+this.margins.left}if("right" in b){this.offset.click.left=this.helperProportions.width-b.right+this.margins.left}if("top" in b){this.offset.click.top=b.top+this.margins.top}if("bottom" in b){this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top}},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])){b.left+=this.scrollParent.scrollLeft();b.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie){b={top:0,left:0}}return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var b=this.element.position();return{top:b.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:b.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else{return{top:0,left:0}}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e=this.options;if(e.containment=="parent"){e.containment=this.helper[0].parentNode}if(e.containment=="document"||e.containment=="window"){this.containment=[e.containment=="document"?0:a(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,e.containment=="document"?0:a(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(e.containment=="document"?0:a(window).scrollLeft())+a(e.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(e.containment=="document"?0:a(window).scrollTop())+(a(e.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]}if(!/^(document|window|parent)$/.test(e.containment)&&e.containment.constructor!=Array){e=a(e.containment);var d=e[0];if(d){e.offset();var f=a(d).css("overflow")!="hidden";this.containment=[(parseInt(a(d).css("borderLeftWidth"),10)||0)+(parseInt(a(d).css("paddingLeft"),10)||0),(parseInt(a(d).css("borderTopWidth"),10)||0)+(parseInt(a(d).css("paddingTop"),10)||0),(f?Math.max(d.scrollWidth,d.offsetWidth):d.offsetWidth)-(parseInt(a(d).css("borderLeftWidth"),10)||0)-(parseInt(a(d).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(f?Math.max(d.scrollHeight,d.offsetHeight):d.offsetHeight)-(parseInt(a(d).css("borderTopWidth"),10)||0)-(parseInt(a(d).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=e}}else{if(e.containment.constructor==Array){this.containment=e.containment}}},_convertPositionTo:function(e,d){if(!d){d=this.position}e=e=="absolute"?1:-1;var h=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=/(html|body)/i.test(h[0].tagName);return{top:d.top+this.offset.relative.top*e+this.offset.parent.top*e-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:h.scrollTop())*e),left:d.left+this.offset.relative.left*e+this.offset.parent.left*e-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:h.scrollLeft())*e)}},_generatePosition:function(i){var d=this.options,n=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,l=/(html|body)/i.test(n[0].tagName),m=i.pageX,j=i.pageY;if(this.originalPosition){var k;if(this.containment){if(this.relative_container){k=this.relative_container.offset();k=[this.containment[0]+k.left,this.containment[1]+k.top,this.containment[2]+k.left,this.containment[3]+k.top]}else{k=this.containment}if(i.pageX-this.offset.click.left<k[0]){m=k[0]+this.offset.click.left}if(i.pageY-this.offset.click.top<k[1]){j=k[1]+this.offset.click.top}if(i.pageX-this.offset.click.left>k[2]){m=k[2]+this.offset.click.left}if(i.pageY-this.offset.click.top>k[3]){j=k[3]+this.offset.click.top}}if(d.grid){j=d.grid[1]?this.originalPageY+Math.round((j-this.originalPageY)/d.grid[1])*d.grid[1]:this.originalPageY;j=k?!(j-this.offset.click.top<k[1]||j-this.offset.click.top>k[3])?j:!(j-this.offset.click.top<k[1])?j-d.grid[1]:j+d.grid[1]:j;m=d.grid[0]?this.originalPageX+Math.round((m-this.originalPageX)/d.grid[0])*d.grid[0]:this.originalPageX;m=k?!(m-this.offset.click.left<k[0]||m-this.offset.click.left>k[2])?m:!(m-this.offset.click.left<k[0])?m-d.grid[0]:m+d.grid[0]:m}}return{top:j-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():l?0:n.scrollTop()),left:m-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():l?0:n.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=false},_trigger:function(e,d,f){f=f||this._uiHash();a.ui.plugin.call(this,e,[d,f]);if(e=="drag"){this.positionAbs=this._convertPositionTo("absolute")}return a.Widget.prototype._trigger.call(this,e,d,f)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});a.extend(a.ui.draggable,{version:"1.8.16"});a.ui.plugin.add("draggable","connectToSortable",{start:function(g,d){var j=a(this).data("draggable"),h=j.options,i=a.extend({},d,{item:j.element});j.sortables=[];a(h.connectToSortable).each(function(){var b=a.data(this,"sortable");if(b&&!b.options.disabled){j.sortables.push({instance:b,shouldRevert:b.options.revert});b.refreshPositions();b._trigger("activate",g,i)}})},stop:function(e,d){var h=a(this).data("draggable"),g=a.extend({},d,{item:h.element});a.each(h.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;h.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert){this.instance.options.revert=true}this.instance._mouseStop(e);this.instance.options.helper=this.instance.options._helper;h.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})}else{this.instance.cancelHelperRemoval=false;this.instance._trigger("deactivate",e,g)}})},drag:function(e,d){var h=a(this).data("draggable"),g=this;a.each(h.sortables,function(){this.instance.positionAbs=h.positionAbs;this.instance.helperProportions=h.helperProportions;this.instance.offset.click=h.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=a(g).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return d.helper[0]};e.target=this.instance.currentItem[0];this.instance._mouseCapture(e,true);this.instance._mouseStart(e,true,true);this.instance.offset.click.top=h.offset.click.top;this.instance.offset.click.left=h.offset.click.left;this.instance.offset.parent.left-=h.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=h.offset.parent.top-this.instance.offset.parent.top;h._trigger("toSortable",e);h.dropped=this.instance.element;h.currentItem=h.element;this.instance.fromOutside=h}this.instance.currentItem&&this.instance._mouseDrag(e)}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger("out",e,this.instance._uiHash(this.instance));this.instance._mouseStop(e,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();this.instance.placeholder&&this.instance.placeholder.remove();h._trigger("fromSortable",e);h.dropped=false}}})}});a.ui.plugin.add("draggable","cursor",{start:function(){var d=a("body"),c=a(this).data("draggable").options;if(d.css("cursor")){c._cursor=d.css("cursor")}d.css("cursor",c.cursor)},stop:function(){var b=a(this).data("draggable").options;b._cursor&&a("body").css("cursor",b._cursor)}});a.ui.plugin.add("draggable","opacity",{start:function(d,c){d=a(c.helper);c=a(this).data("draggable").options;if(d.css("opacity")){c._opacity=d.css("opacity")}d.css("opacity",c.opacity)},stop:function(d,c){d=a(this).data("draggable").options;d._opacity&&a(c.helper).css("opacity",d._opacity)}});a.ui.plugin.add("draggable","scroll",{start:function(){var b=a(this).data("draggable");if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){b.overflowOffset=b.scrollParent.offset()}},drag:function(e){var d=a(this).data("draggable"),h=d.options,g=false;if(d.scrollParent[0]!=document&&d.scrollParent[0].tagName!="HTML"){if(!h.axis||h.axis!="x"){if(d.overflowOffset.top+d.scrollParent[0].offsetHeight-e.pageY<h.scrollSensitivity){d.scrollParent[0].scrollTop=g=d.scrollParent[0].scrollTop+h.scrollSpeed}else{if(e.pageY-d.overflowOffset.top<h.scrollSensitivity){d.scrollParent[0].scrollTop=g=d.scrollParent[0].scrollTop-h.scrollSpeed}}}if(!h.axis||h.axis!="y"){if(d.overflowOffset.left+d.scrollParent[0].offsetWidth-e.pageX<h.scrollSensitivity){d.scrollParent[0].scrollLeft=g=d.scrollParent[0].scrollLeft+h.scrollSpeed}else{if(e.pageX-d.overflowOffset.left<h.scrollSensitivity){d.scrollParent[0].scrollLeft=g=d.scrollParent[0].scrollLeft-h.scrollSpeed}}}}else{if(!h.axis||h.axis!="x"){if(e.pageY-a(document).scrollTop()<h.scrollSensitivity){g=a(document).scrollTop(a(document).scrollTop()-h.scrollSpeed)}else{if(a(window).height()-(e.pageY-a(document).scrollTop())<h.scrollSensitivity){g=a(document).scrollTop(a(document).scrollTop()+h.scrollSpeed)}}}if(!h.axis||h.axis!="y"){if(e.pageX-a(document).scrollLeft()<h.scrollSensitivity){g=a(document).scrollLeft(a(document).scrollLeft()-h.scrollSpeed)}else{if(a(window).width()-(e.pageX-a(document).scrollLeft())<h.scrollSensitivity){g=a(document).scrollLeft(a(document).scrollLeft()+h.scrollSpeed)}}}}g!==false&&a.ui.ddmanager&&!h.dropBehaviour&&a.ui.ddmanager.prepareOffsets(d,e)}});a.ui.plugin.add("draggable","snap",{start:function(){var d=a(this).data("draggable"),c=d.options;d.snapElements=[];a(c.snap.constructor!=String?c.snap.items||":data(draggable)":c.snap).each(function(){var e=a(this),b=e.offset();this!=d.element[0]&&d.snapElements.push({item:this,width:e.outerWidth(),height:e.outerHeight(),top:b.top,left:b.left})})},drag:function(L,K){for(var J=a(this).data("draggable"),H=J.options,I=H.snapTolerance,F=K.offset.left,G=F+J.helperProportions.width,z=K.offset.top,y=z+J.helperProportions.height,E=J.snapElements.length-1;E>=0;E--){var D=J.snapElements[E].left,B=D+J.snapElements[E].width,C=J.snapElements[E].top,A=C+J.snapElements[E].height;if(D-I<F&&F<B+I&&C-I<z&&z<A+I||D-I<F&&F<B+I&&C-I<y&&y<A+I||D-I<G&&G<B+I&&C-I<z&&z<A+I||D-I<G&&G<B+I&&C-I<y&&y<A+I){if(H.snapMode!="inner"){var x=Math.abs(C-y)<=I,w=Math.abs(A-z)<=I,v=Math.abs(D-G)<=I,u=Math.abs(B-F)<=I;if(x){K.position.top=J._convertPositionTo("relative",{top:C-J.helperProportions.height,left:0}).top-J.margins.top}if(w){K.position.top=J._convertPositionTo("relative",{top:A,left:0}).top-J.margins.top}if(v){K.position.left=J._convertPositionTo("relative",{top:0,left:D-J.helperProportions.width}).left-J.margins.left}if(u){K.position.left=J._convertPositionTo("relative",{top:0,left:B}).left-J.margins.left}}var d=x||w||v||u;if(H.snapMode!="outer"){x=Math.abs(C-z)<=I;w=Math.abs(A-y)<=I;v=Math.abs(D-F)<=I;u=Math.abs(B-G)<=I;if(x){K.position.top=J._convertPositionTo("relative",{top:C,left:0}).top-J.margins.top}if(w){K.position.top=J._convertPositionTo("relative",{top:A-J.helperProportions.height,left:0}).top-J.margins.top}if(v){K.position.left=J._convertPositionTo("relative",{top:0,left:D}).left-J.margins.left}if(u){K.position.left=J._convertPositionTo("relative",{top:0,left:B-J.helperProportions.width}).left-J.margins.left}}if(!J.snapElements[E].snapping&&(x||w||v||u||d)){J.options.snap.snap&&J.options.snap.snap.call(J.element,L,a.extend(J._uiHash(),{snapItem:J.snapElements[E].item}))}J.snapElements[E].snapping=x||w||v||u||d}else{J.snapElements[E].snapping&&J.options.snap.release&&J.options.snap.release.call(J.element,L,a.extend(J._uiHash(),{snapItem:J.snapElements[E].item}));J.snapElements[E].snapping=false}}}});a.ui.plugin.add("draggable","stack",{start:function(){var d=a(this).data("draggable").options;d=a.makeArray(a(d.stack)).sort(function(e,b){return(parseInt(a(e).css("zIndex"),10)||0)-(parseInt(a(b).css("zIndex"),10)||0)});if(d.length){var c=parseInt(d[0].style.zIndex)||0;a(d).each(function(b){this.style.zIndex=c+b});this[0].style.zIndex=c+d.length}}});a.ui.plugin.add("draggable","zIndex",{start:function(d,c){d=a(c.helper);c=a(this).data("draggable").options;if(d.css("zIndex")){c._zIndex=d.css("zIndex")}d.css("zIndex",c.zIndex)},stop:function(d,c){d=a(this).data("draggable").options;d._zIndex&&a(c.helper).css("zIndex",d._zIndex)}})})(jQuery);(function(a){a.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:false,addClasses:true,greedy:false,hoverClass:false,scope:"default",tolerance:"intersect"},_create:function(){var d=this.options,c=d.accept;this.isover=0;this.isout=1;this.accept=a.isFunction(c)?c:function(b){return b.is(c)};this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight};a.ui.ddmanager.droppables[d.scope]=a.ui.ddmanager.droppables[d.scope]||[];a.ui.ddmanager.droppables[d.scope].push(this);d.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){for(var d=a.ui.ddmanager.droppables[this.options.scope],c=0;c<d.length;c++){d[c]==this&&d.splice(c,1)}this.element.removeClass("ui-droppable ui-droppable-disabled").removeData("droppable").unbind(".droppable");return this},_setOption:function(d,c){if(d=="accept"){this.accept=a.isFunction(c)?c:function(b){return b.is(c)}}a.Widget.prototype._setOption.apply(this,arguments)},_activate:function(d){var c=a.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass);c&&this._trigger("activate",d,this.ui(c))},_deactivate:function(d){var c=a.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass);c&&this._trigger("deactivate",d,this.ui(c))},_over:function(d){var c=a.ui.ddmanager.current;if(!(!c||(c.currentItem||c.element)[0]==this.element[0])){if(this.accept.call(this.element[0],c.currentItem||c.element)){this.options.hoverClass&&this.element.addClass(this.options.hoverClass);this._trigger("over",d,this.ui(c))}}},_out:function(d){var c=a.ui.ddmanager.current;if(!(!c||(c.currentItem||c.element)[0]==this.element[0])){if(this.accept.call(this.element[0],c.currentItem||c.element)){this.options.hoverClass&&this.element.removeClass(this.options.hoverClass);this._trigger("out",d,this.ui(c))}}},_drop:function(f,d){var h=d||a.ui.ddmanager.current;if(!h||(h.currentItem||h.element)[0]==this.element[0]){return false}var g=false;this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var b=a.data(this,"droppable");if(b.options.greedy&&!b.options.disabled&&b.options.scope==h.options.scope&&b.accept.call(b.element[0],h.currentItem||h.element)&&a.ui.intersect(h,a.extend(b,{offset:b.element.offset()}),b.options.tolerance)){g=true;return false}});if(g){return false}if(this.accept.call(this.element[0],h.currentItem||h.element)){this.options.activeClass&&this.element.removeClass(this.options.activeClass);this.options.hoverClass&&this.element.removeClass(this.options.hoverClass);this._trigger("drop",f,this.ui(h));return this.element}return false},ui:function(b){return{draggable:b.currentItem||b.element,helper:b.helper,position:b.position,offset:b.positionAbs}}});a.extend(a.ui.droppable,{version:"1.8.16"});a.ui.intersect=function(w,v,u){if(!v.offset){return false}var s=(w.positionAbs||w.position.absolute).left,q=s+w.helperProportions.width,r=(w.positionAbs||w.position.absolute).top,p=r+w.helperProportions.height,o=v.offset.left,m=o+v.proportions.width,n=v.offset.top,d=n+v.proportions.height;switch(u){case"fit":return o<=s&&q<=m&&n<=r&&p<=d;case"intersect":return o<s+w.helperProportions.width/2&&q-w.helperProportions.width/2<m&&n<r+w.helperProportions.height/2&&p-w.helperProportions.height/2<d;case"pointer":return a.ui.isOver((w.positionAbs||w.position.absolute).top+(w.clickOffset||w.offset.click).top,(w.positionAbs||w.position.absolute).left+(w.clickOffset||w.offset.click).left,n,o,v.proportions.height,v.proportions.width);case"touch":return(r>=n&&r<=d||p>=n&&p<=d||r<n&&p>d)&&(s>=o&&s<=m||q>=o&&q<=m||s<o&&q>m);default:return false}};a.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(i,d){var n=a.ui.ddmanager.droppables[i.options.scope]||[],m=d?d.type:null,k=(i.currentItem||i.element).find(":data(droppable)").andSelf(),l=0;i:for(;l<n.length;l++){if(!(n[l].options.disabled||i&&!n[l].accept.call(n[l].element[0],i.currentItem||i.element))){for(var j=0;j<k.length;j++){if(k[j]==n[l].element[0]){n[l].proportions.height=0;continue i}}n[l].visible=n[l].element.css("display")!="none";if(n[l].visible){m=="mousedown"&&n[l]._activate.call(n[l],d);n[l].offset=n[l].element.offset();n[l].proportions={width:n[l].element[0].offsetWidth,height:n[l].element[0].offsetHeight}}}}},drop:function(e,d){var f=false;a.each(a.ui.ddmanager.droppables[e.options.scope]||[],function(){if(this.options){if(!this.options.disabled&&this.visible&&a.ui.intersect(e,this,this.options.tolerance)){f=f||this._drop.call(this,d)}if(!this.options.disabled&&this.visible&&this.accept.call(this.element[0],e.currentItem||e.element)){this.isout=1;this.isover=0;this._deactivate.call(this,d)}}});return f},dragStart:function(d,c){d.element.parents(":not(body,html)").bind("scroll.droppable",function(){d.options.refreshPositions||a.ui.ddmanager.prepareOffsets(d,c)})},drag:function(d,c){d.options.refreshPositions&&a.ui.ddmanager.prepareOffsets(d,c);a.each(a.ui.ddmanager.droppables[d.options.scope]||[],function(){if(!(this.options.disabled||this.greedyChild||!this.visible)){var h=a.ui.intersect(d,this,this.options.tolerance);if(h=!h&&this.isover==1?"isout":h&&this.isover==0?"isover":null){var f;if(this.options.greedy){var b=this.element.parents(":data(droppable):eq(0)");if(b.length){f=a.data(b[0],"droppable");f.greedyChild=h=="isover"?1:0}}if(f&&h=="isover"){f.isover=0;f.isout=1;f._out.call(f,c)}this[h]=1;this[h=="isout"?"isover":"isout"]=0;this[h=="isover"?"_over":"_out"].call(this,c);if(f&&h=="isout"){f.isout=0;f.isover=1;f._over.call(f,c)}}}})},dragStop:function(d,c){d.element.parents(":not(body,html)").unbind("scroll.droppable");d.options.refreshPositions||a.ui.ddmanager.prepareOffsets(d,c)}}})(jQuery);(function(c){c.widget("ui.resizable",c.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,containment:false,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1000},_create:function(){var e=this,h=this.options;this.element.addClass("ui-resizable");c.extend(this,{_aspectRatio:!!h.aspectRatio,aspectRatio:h.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:h.helper||h.ghost||h.animate?h.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){/relative/.test(this.element.css("position"))&&c.browser.opera&&this.element.css({position:"relative",top:"auto",left:"auto"});this.element.wrap(c('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=h.handles||(!c(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all"){this.handles="n,e,s,w,se,sw,ne,nw"}var l=this.handles.split(",");this.handles={};for(var k=0;k<l.length;k++){var j=c.trim(l[k]),i=c('<div class="ui-resizable-handle '+("ui-resizable-"+j)+'"></div>');/sw|se|ne|nw/.test(j)&&i.css({zIndex:++h.zIndex});"se"==j&&i.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[j]=".ui-resizable-"+j;this.element.append(i)}}this._renderAxis=function(m){m=m||this.element;for(var g in this.handles){if(this.handles[g].constructor==String){this.handles[g]=c(this.handles[g],this.element).show()}if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var f=c(this.handles[g],this.element),d=0;d=/sw|ne|nw|se|n|s/.test(g)?f.outerHeight():f.outerWidth();f=["padding",/ne|nw|n/.test(g)?"Top":/se|sw|s/.test(g)?"Bottom":/^e$/.test(g)?"Right":"Left"].join("");m.css(f,d);this._proportionallyResize()}c(this.handles[g])}};this._renderAxis(this.element);this._handles=c(".ui-resizable-handle",this.element).disableSelection();this._handles.mouseover(function(){if(!e.resizing){if(this.className){var d=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}e.axis=d&&d[1]?d[1]:"se"}});if(h.autoHide){this._handles.hide();c(this.element).addClass("ui-resizable-autohide").hover(function(){if(!h.disabled){c(this).removeClass("ui-resizable-autohide");e._handles.show()}},function(){if(!h.disabled){if(!e.resizing){c(this).addClass("ui-resizable-autohide");e._handles.hide()}}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var d=function(f){c(f).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){d(this.element);var e=this.element;e.after(this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);d(this.originalElement);return this},_mouseCapture:function(d){var e=false;for(var f in this.handles){if(c(this.handles[f])[0]==d.target){e=true}}return !this.options.disabled&&e},_mouseStart:function(e){var g=this.options,j=this.element.position(),i=this.element;this.resizing=true;this.documentScroll={top:c(document).scrollTop(),left:c(document).scrollLeft()};if(i.is(".ui-draggable")||/absolute/.test(i.css("position"))){i.css({position:"absolute",top:j.top,left:j.left})}c.browser.opera&&/relative/.test(i.css("position"))&&i.css({position:"relative",top:"auto",left:"auto"});this._renderProxy();j=a(this.helper.css("left"));var h=a(this.helper.css("top"));if(g.containment){j+=c(g.containment).scrollLeft()||0;h+=c(g.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:j,top:h};this.size=this._helper?{width:i.outerWidth(),height:i.outerHeight()}:{width:i.width(),height:i.height()};this.originalSize=this._helper?{width:i.outerWidth(),height:i.outerHeight()}:{width:i.width(),height:i.height()};this.originalPosition={left:j,top:h};this.sizeDiff={width:i.outerWidth()-i.width(),height:i.outerHeight()-i.height()};this.originalMousePosition={left:e.pageX,top:e.pageY};this.aspectRatio=typeof g.aspectRatio=="number"?g.aspectRatio:this.originalSize.width/this.originalSize.height||1;g=c(".ui-resizable-"+this.axis).css("cursor");c("body").css("cursor",g=="auto"?this.axis+"-resize":g);i.addClass("ui-resizable-resizing");this._propagate("start",e);return true},_mouseDrag:function(e){var f=this.helper,h=this.originalMousePosition,g=this._change[this.axis];if(!g){return false}h=g.apply(this,[e,e.pageX-h.left||0,e.pageY-h.top||0]);this._updateVirtualBoundaries(e.shiftKey);if(this._aspectRatio||e.shiftKey){h=this._updateRatio(h,e)}h=this._respectSize(h,e);this._propagate("resize",e);f.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(h);this._trigger("resize",e,this.ui());return false},_mouseStop:function(e){this.resizing=false;var h=this.options,l=this;if(this._helper){var k=this._proportionallyResizeElements,j=k.length&&/textarea/i.test(k[0].nodeName);k=j&&c.ui.hasScroll(k[0],"left")?0:l.sizeDiff.height;j=j?0:l.sizeDiff.width;j={width:l.helper.width()-j,height:l.helper.height()-k};k=parseInt(l.element.css("left"),10)+(l.position.left-l.originalPosition.left)||null;var i=parseInt(l.element.css("top"),10)+(l.position.top-l.originalPosition.top)||null;h.animate||this.element.css(c.extend(j,{top:i,left:k}));l.helper.height(l.size.height);l.helper.width(l.size.width);this._helper&&!h.animate&&this._proportionallyResize()}c("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",e);this._helper&&this.helper.remove();return false},_updateVirtualBoundaries:function(e){var g=this.options,j,i,h;g={minWidth:b(g.minWidth)?g.minWidth:0,maxWidth:b(g.maxWidth)?g.maxWidth:Infinity,minHeight:b(g.minHeight)?g.minHeight:0,maxHeight:b(g.maxHeight)?g.maxHeight:Infinity};if(this._aspectRatio||e){e=g.minHeight*this.aspectRatio;i=g.minWidth/this.aspectRatio;j=g.maxHeight*this.aspectRatio;h=g.maxWidth/this.aspectRatio;if(e>g.minWidth){g.minWidth=e}if(i>g.minHeight){g.minHeight=i}if(j<g.maxWidth){g.maxWidth=j}if(h<g.maxHeight){g.maxHeight=h}}this._vBoundaries=g},_updateCache:function(d){this.offset=this.helper.offset();if(b(d.left)){this.position.left=d.left}if(b(d.top)){this.position.top=d.top}if(b(d.height)){this.size.height=d.height}if(b(d.width)){this.size.width=d.width}},_updateRatio:function(e){var f=this.position,h=this.size,g=this.axis;if(b(e.height)){e.width=e.height*this.aspectRatio}else{if(b(e.width)){e.height=e.width/this.aspectRatio}}if(g=="sw"){e.left=f.left+(h.width-e.width);e.top=null}if(g=="nw"){e.top=f.top+(h.height-e.height);e.left=f.left+(h.width-e.width)}return e},_respectSize:function(s){var u=this._vBoundaries,r=this.axis,q=b(s.width)&&u.maxWidth&&u.maxWidth<s.width,p=b(s.height)&&u.maxHeight&&u.maxHeight<s.height,o=b(s.width)&&u.minWidth&&u.minWidth>s.width,n=b(s.height)&&u.minHeight&&u.minHeight>s.height;if(o){s.width=u.minWidth}if(n){s.height=u.minHeight}if(q){s.width=u.maxWidth}if(p){s.height=u.maxHeight}var m=this.originalPosition.left+this.originalSize.width,k=this.position.top+this.size.height,e=/sw|nw|w/.test(r);r=/nw|ne|n/.test(r);if(o&&e){s.left=m-u.minWidth}if(q&&e){s.left=m-u.maxWidth}if(n&&r){s.top=k-u.minHeight}if(p&&r){s.top=k-u.maxHeight}if((u=!s.width&&!s.height)&&!s.left&&s.top){s.top=null}else{if(u&&!s.top&&s.left){s.left=null}}return s},_proportionallyResize:function(){if(this._proportionallyResizeElements.length){for(var e=this.helper||this.element,g=0;g<this._proportionallyResizeElements.length;g++){var j=this._proportionallyResizeElements[g];if(!this.borderDif){var i=[j.css("borderTopWidth"),j.css("borderRightWidth"),j.css("borderBottomWidth"),j.css("borderLeftWidth")],h=[j.css("paddingTop"),j.css("paddingRight"),j.css("paddingBottom"),j.css("paddingLeft")];this.borderDif=c.map(i,function(f,d){f=parseInt(f,10)||0;d=parseInt(h[d],10)||0;return f+d})}c.browser.msie&&(c(e).is(":hidden")||c(e).parents(":hidden").length)||j.css({height:e.height()-this.borderDif[0]-this.borderDif[2]||0,width:e.width()-this.borderDif[1]-this.borderDif[3]||0})}}},_renderProxy:function(){var d=this.options;this.elementOffset=this.element.offset();if(this._helper){this.helper=this.helper||c('<div style="overflow:hidden;"></div>');var e=c.browser.msie&&c.browser.version<7,f=e?1:0;e=e?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+e,height:this.element.outerHeight()+e,position:"absolute",left:this.elementOffset.left-f+"px",top:this.elementOffset.top-f+"px",zIndex:++d.zIndex});this.helper.appendTo("body").disableSelection()}else{this.helper=this.element}},_change:{e:function(d,e){return{width:this.originalSize.width+e}},w:function(d,e){return{left:this.originalPosition.left+e,width:this.originalSize.width-e}},n:function(d,e,f){return{top:this.originalPosition.top+f,height:this.originalSize.height-f}},s:function(d,e,f){return{height:this.originalSize.height+f}},se:function(d,e,f){return c.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[d,e,f]))},sw:function(d,e,f){return c.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[d,e,f]))},ne:function(d,e,f){return c.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[d,e,f]))},nw:function(d,e,f){return c.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[d,e,f]))}},_propagate:function(d,e){c.ui.plugin.call(this,d,[e,this.ui()]);d!="resize"&&this._trigger(d,e,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});c.extend(c.ui.resizable,{version:"1.8.16"});c.ui.plugin.add("resizable","alsoResize",{start:function(){var d=c(this).data("resizable").options,e=function(f){c(f).each(function(){var g=c(this);g.data("resizable-alsoresize",{width:parseInt(g.width(),10),height:parseInt(g.height(),10),left:parseInt(g.css("left"),10),top:parseInt(g.css("top"),10),position:g.css("position")})})};if(typeof d.alsoResize=="object"&&!d.alsoResize.parentNode){if(d.alsoResize.length){d.alsoResize=d.alsoResize[0];e(d.alsoResize)}else{c.each(d.alsoResize,function(f){e(f)})}}else{e(d.alsoResize)}},resize:function(e,i){var n=c(this).data("resizable");e=n.options;var m=n.originalSize,l=n.originalPosition,k={height:n.size.height-m.height||0,width:n.size.width-m.width||0,top:n.position.top-l.top||0,left:n.position.left-l.left||0},j=function(f,d){c(f).each(function(){var g=c(this),o=c(this).data("resizable-alsoresize"),s={},h=d&&d.length?d:g.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];c.each(h,function(q,p){if((q=(o[p]||0)+(k[p]||0))&&q>=0){s[p]=q||null}});if(c.browser.opera&&/relative/.test(g.css("position"))){n._revertToRelativePosition=true;g.css({position:"absolute",top:"auto",left:"auto"})}g.css(s)})};typeof e.alsoResize=="object"&&!e.alsoResize.nodeType?c.each(e.alsoResize,function(f,d){j(f,d)}):j(e.alsoResize)},stop:function(){var d=c(this).data("resizable"),e=d.options,f=function(g){c(g).each(function(){var h=c(this);h.css({position:h.data("resizable-alsoresize").position})})};if(d._revertToRelativePosition){d._revertToRelativePosition=false;typeof e.alsoResize=="object"&&!e.alsoResize.nodeType?c.each(e.alsoResize,function(g){f(g)}):f(e.alsoResize)}c(this).removeData("resizable-alsoresize")}});c.ui.plugin.add("resizable","animate",{stop:function(e){var i=c(this).data("resizable"),n=i.options,m=i._proportionallyResizeElements,l=m.length&&/textarea/i.test(m[0].nodeName),k=l&&c.ui.hasScroll(m[0],"left")?0:i.sizeDiff.height;l={width:i.size.width-(l?0:i.sizeDiff.width),height:i.size.height-k};k=parseInt(i.element.css("left"),10)+(i.position.left-i.originalPosition.left)||null;var j=parseInt(i.element.css("top"),10)+(i.position.top-i.originalPosition.top)||null;i.element.animate(c.extend(l,j&&k?{top:j,left:k}:{}),{duration:n.animateDuration,easing:n.animateEasing,step:function(){var d={width:parseInt(i.element.css("width"),10),height:parseInt(i.element.css("height"),10),top:parseInt(i.element.css("top"),10),left:parseInt(i.element.css("left"),10)};m&&m.length&&c(m[0]).css({width:d.width,height:d.height});i._updateCache(d);i._propagate("resize",e)}})}});c.ui.plugin.add("resizable","containment",{start:function(){var e=c(this).data("resizable"),i=e.element,n=e.options.containment;if(i=n instanceof c?n.get(0):/parent/.test(n)?i.parent().get(0):n){e.containerElement=c(i);if(/document/.test(n)||n==document){e.containerOffset={left:0,top:0};e.containerPosition={left:0,top:0};e.parentData={element:c(document),left:0,top:0,width:c(document).width(),height:c(document).height()||document.body.parentNode.scrollHeight}}else{var m=c(i),l=[];c(["Top","Right","Left","Bottom"]).each(function(f,d){l[f]=a(m.css("padding"+d))});e.containerOffset=m.offset();e.containerPosition=m.position();e.containerSize={height:m.innerHeight()-l[3],width:m.innerWidth()-l[1]};n=e.containerOffset;var k=e.containerSize.height,j=e.containerSize.width;j=c.ui.hasScroll(i,"left")?i.scrollWidth:j;k=c.ui.hasScroll(i)?i.scrollHeight:k;e.parentData={element:i,left:n.left,top:n.top,width:j,height:k}}}},resize:function(e){var i=c(this).data("resizable"),n=i.options,m=i.containerOffset,l=i.position;e=i._aspectRatio||e.shiftKey;var k={top:0,left:0},j=i.containerElement;if(j[0]!=document&&/static/.test(j.css("position"))){k=m}if(l.left<(i._helper?m.left:0)){i.size.width+=i._helper?i.position.left-m.left:i.position.left-k.left;if(e){i.size.height=i.size.width/n.aspectRatio}i.position.left=n.helper?m.left:0}if(l.top<(i._helper?m.top:0)){i.size.height+=i._helper?i.position.top-m.top:i.position.top;if(e){i.size.width=i.size.height*n.aspectRatio}i.position.top=i._helper?m.top:0}i.offset.left=i.parentData.left+i.position.left;i.offset.top=i.parentData.top+i.position.top;n=Math.abs((i._helper?i.offset.left-k.left:i.offset.left-k.left)+i.sizeDiff.width);m=Math.abs((i._helper?i.offset.top-k.top:i.offset.top-m.top)+i.sizeDiff.height);l=i.containerElement.get(0)==i.element.parent().get(0);k=/relative|absolute/.test(i.containerElement.css("position"));if(l&&k){n-=i.parentData.left}if(n+i.size.width>=i.parentData.width){i.size.width=i.parentData.width-n;if(e){i.size.height=i.size.width/i.aspectRatio}}if(m+i.size.height>=i.parentData.height){i.size.height=i.parentData.height-m;if(e){i.size.width=i.size.height*i.aspectRatio}}},stop:function(){var e=c(this).data("resizable"),j=e.options,p=e.containerOffset,o=e.containerPosition,n=e.containerElement,m=c(e.helper),l=m.offset(),k=m.outerWidth()-e.sizeDiff.width;m=m.outerHeight()-e.sizeDiff.height;e._helper&&!j.animate&&/relative/.test(n.css("position"))&&c(this).css({left:l.left-o.left-p.left,width:k,height:m});e._helper&&!j.animate&&/static/.test(n.css("position"))&&c(this).css({left:l.left-o.left-p.left,width:k,height:m})}});c.ui.plugin.add("resizable","ghost",{start:function(){var d=c(this).data("resizable"),e=d.options,f=d.size;d.ghost=d.originalElement.clone();d.ghost.css({opacity:0.25,display:"block",position:"relative",height:f.height,width:f.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof e.ghost=="string"?e.ghost:"");d.ghost.appendTo(d.helper)},resize:function(){var d=c(this).data("resizable");d.ghost&&d.ghost.css({position:"relative",height:d.size.height,width:d.size.width})},stop:function(){var d=c(this).data("resizable");d.ghost&&d.helper&&d.helper.get(0).removeChild(d.ghost.get(0))}});c.ui.plugin.add("resizable","grid",{resize:function(){var e=c(this).data("resizable"),i=e.options,n=e.size,m=e.originalSize,l=e.originalPosition,k=e.axis;i.grid=typeof i.grid=="number"?[i.grid,i.grid]:i.grid;var j=Math.round((n.width-m.width)/(i.grid[0]||1))*(i.grid[0]||1);i=Math.round((n.height-m.height)/(i.grid[1]||1))*(i.grid[1]||1);if(/^(se|s|e)$/.test(k)){e.size.width=m.width+j;e.size.height=m.height+i}else{if(/^(ne)$/.test(k)){e.size.width=m.width+j;e.size.height=m.height+i;e.position.top=l.top-i}else{if(/^(sw)$/.test(k)){e.size.width=m.width+j;e.size.height=m.height+i}else{e.size.width=m.width+j;e.size.height=m.height+i;e.position.top=l.top-i}e.position.left=l.left-j}}}});var a=function(d){return parseInt(d,10)||0},b=function(d){return !isNaN(parseInt(d,10))}})(jQuery);(function(a){a.widget("ui.selectable",a.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var d=this;this.element.addClass("ui-selectable");this.dragged=false;var b;this.refresh=function(){b=a(d.options.filter,d.element[0]);b.each(function(){var e=a(this),c=e.offset();a.data(this,"selectable-item",{element:this,$element:e,left:c.left,top:c.top,right:c.left+e.outerWidth(),bottom:c.top+e.outerHeight(),startselected:false,selected:e.hasClass("ui-selected"),selecting:e.hasClass("ui-selecting"),unselecting:e.hasClass("ui-unselecting")})})};this.refresh();this.selectees=b.addClass("ui-selectee");this._mouseInit();this.helper=a("<div class='ui-selectable-helper'></div>")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(g){var b=this;this.opos=[g.pageX,g.pageY];if(!this.options.disabled){var e=this.options;this.selectees=a(e.filter,this.element[0]);this._trigger("start",g);a(e.appendTo).append(this.helper);this.helper.css({left:g.clientX,top:g.clientY,width:0,height:0});e.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var c=a.data(this,"selectable-item");c.startselected=true;if(!g.metaKey){c.$element.removeClass("ui-selected");c.selected=false;c.$element.addClass("ui-unselecting");c.unselecting=true;b._trigger("unselecting",g,{unselecting:c.element})}});a(g.target).parents().andSelf().each(function(){var c=a.data(this,"selectable-item");if(c){var d=!g.metaKey||!c.$element.hasClass("ui-selected");c.$element.removeClass(d?"ui-unselecting":"ui-selected").addClass(d?"ui-selecting":"ui-unselecting");c.unselecting=!d;c.selecting=d;(c.selected=d)?b._trigger("selecting",g,{selecting:c.element}):b._trigger("unselecting",g,{unselecting:c.element});return false}})}},_mouseDrag:function(q){var o=this;this.dragged=true;if(!this.options.disabled){var p=this.options,e=this.opos[0],n=this.opos[1],m=q.pageX,l=q.pageY;if(e>m){var k=m;m=e;e=k}if(n>l){k=l;l=n;n=k}this.helper.css({left:e,top:n,width:m-e,height:l-n});this.selectees.each(function(){var b=a.data(this,"selectable-item");if(!(!b||b.element==o.element[0])){var c=false;if(p.tolerance=="touch"){c=!(b.left>m||b.right<e||b.top>l||b.bottom<n)}else{if(p.tolerance=="fit"){c=b.left>e&&b.right<m&&b.top>n&&b.bottom<l}}if(c){if(b.selected){b.$element.removeClass("ui-selected");b.selected=false}if(b.unselecting){b.$element.removeClass("ui-unselecting");b.unselecting=false}if(!b.selecting){b.$element.addClass("ui-selecting");b.selecting=true;o._trigger("selecting",q,{selecting:b.element})}}else{if(b.selecting){if(q.metaKey&&b.startselected){b.$element.removeClass("ui-selecting");b.selecting=false;b.$element.addClass("ui-selected");b.selected=true}else{b.$element.removeClass("ui-selecting");b.selecting=false;if(b.startselected){b.$element.addClass("ui-unselecting");b.unselecting=true}o._trigger("unselecting",q,{unselecting:b.element})}}if(b.selected){if(!q.metaKey&&!b.startselected){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting");b.unselecting=true;o._trigger("unselecting",q,{unselecting:b.element})}}}}});return false}},_mouseStop:function(d){var b=this;this.dragged=false;a(".ui-unselecting",this.element[0]).each(function(){var c=a.data(this,"selectable-item");c.$element.removeClass("ui-unselecting");c.unselecting=false;c.startselected=false;b._trigger("unselected",d,{unselected:c.element})});a(".ui-selecting",this.element[0]).each(function(){var c=a.data(this,"selectable-item");c.$element.removeClass("ui-selecting").addClass("ui-selected");c.selecting=false;c.selected=true;c.startselected=true;b._trigger("selected",d,{selected:c.element})});this._trigger("stop",d);this.helper.remove();return false}});a.extend(a.ui.selectable,{version:"1.8.16"})})(jQuery);(function(a){a.widget("ui.sortable",a.ui.mouse,{widgetEventPrefix:"sort",options:{appendTo:"parent",axis:false,connectWith:false,containment:false,cursor:"auto",cursorAt:false,dropOnEmpty:true,forcePlaceholderSize:false,forceHelperSize:false,grid:false,handle:false,helper:"original",items:"> *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1000},_create:function(){var b=this.options;this.containerCache={};this.element.addClass("ui-sortable");this.refresh();this.floating=this.items.length?b.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):false;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var b=this.items.length-1;b>=0;b--){this.items[b].item.removeData("sortable-item")}return this},_setOption:function(d,c){if(d==="disabled"){this.options[d]=c;this.widget()[c?"addClass":"removeClass"]("ui-sortable-disabled")}else{a.Widget.prototype._setOption.apply(this,arguments)}},_mouseCapture:function(g,d){if(this.reverting){return false}if(this.options.disabled||this.options.type=="static"){return false}this._refreshItems(g);var j=null,i=this;a(g.target).parents().each(function(){if(a.data(this,"sortable-item")==i){j=a(this);return false}});if(a.data(g.target,"sortable-item")==i){j=a(g.target)}if(!j){return false}if(this.options.handle&&!d){var h=false;a(this.options.handle,j).find("*").andSelf().each(function(){if(this==g.target){h=true}});if(!h){return false}}this.currentItem=j;this._removeCurrentsFromItems();return true},_mouseStart:function(f,d,h){d=this.options;var g=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(f);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");a.extend(this.offset,{click:{left:f.pageX-this.offset.left,top:f.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(f);this.originalPageX=f.pageX;this.originalPageY=f.pageY;d.cursorAt&&this._adjustOffsetFromHelper(d.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder();d.containment&&this._setContainment();if(d.cursor){if(a("body").css("cursor")){this._storedCursor=a("body").css("cursor")}a("body").css("cursor",d.cursor)}if(d.opacity){if(this.helper.css("opacity")){this._storedOpacity=this.helper.css("opacity")}this.helper.css("opacity",d.opacity)}if(d.zIndex){if(this.helper.css("zIndex")){this._storedZIndex=this.helper.css("zIndex")}this.helper.css("zIndex",d.zIndex)}if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){this.overflowOffset=this.scrollParent.offset()}this._trigger("start",f,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!h){for(h=this.containers.length-1;h>=0;h--){this.containers[h]._trigger("activate",f,g._uiHash(this))}}if(a.ui.ddmanager){a.ui.ddmanager.current=this}a.ui.ddmanager&&!d.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,f);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(f);return true},_mouseDrag:function(g){this.position=this._generatePosition(g);this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs){this.lastPositionAbs=this.positionAbs}if(this.options.scroll){var d=this.options,j=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-g.pageY<d.scrollSensitivity){this.scrollParent[0].scrollTop=j=this.scrollParent[0].scrollTop+d.scrollSpeed}else{if(g.pageY-this.overflowOffset.top<d.scrollSensitivity){this.scrollParent[0].scrollTop=j=this.scrollParent[0].scrollTop-d.scrollSpeed}}if(this.overflowOffset.left+this.scrollParent[0].offsetWidth-g.pageX<d.scrollSensitivity){this.scrollParent[0].scrollLeft=j=this.scrollParent[0].scrollLeft+d.scrollSpeed}else{if(g.pageX-this.overflowOffset.left<d.scrollSensitivity){this.scrollParent[0].scrollLeft=j=this.scrollParent[0].scrollLeft-d.scrollSpeed}}}else{if(g.pageY-a(document).scrollTop()<d.scrollSensitivity){j=a(document).scrollTop(a(document).scrollTop()-d.scrollSpeed)}else{if(a(window).height()-(g.pageY-a(document).scrollTop())<d.scrollSensitivity){j=a(document).scrollTop(a(document).scrollTop()+d.scrollSpeed)}}if(g.pageX-a(document).scrollLeft()<d.scrollSensitivity){j=a(document).scrollLeft(a(document).scrollLeft()-d.scrollSpeed)}else{if(a(window).width()-(g.pageX-a(document).scrollLeft())<d.scrollSensitivity){j=a(document).scrollLeft(a(document).scrollLeft()+d.scrollSpeed)}}}j!==false&&a.ui.ddmanager&&!d.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,g)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px"}for(d=this.items.length-1;d>=0;d--){j=this.items[d];var i=j.item[0],h=this._intersectsWithPointer(j);if(h){if(i!=this.currentItem[0]&&this.placeholder[h==1?"next":"prev"]()[0]!=i&&!a.ui.contains(this.placeholder[0],i)&&(this.options.type=="semi-dynamic"?!a.ui.contains(this.element[0],i):true)){this.direction=h==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(j)){this._rearrange(g,j)}else{break}this._trigger("change",g,this._uiHash());break}}}this._contactContainers(g);a.ui.ddmanager&&a.ui.ddmanager.drag(this,g);this._trigger("sort",g,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(e,d){if(e){a.ui.ddmanager&&!this.options.dropBehaviour&&a.ui.ddmanager.drop(this,e);if(this.options.revert){var f=this;d=f.placeholder.offset();f.reverting=true;a(this.helper).animate({left:d.left-this.offset.parent.left-f.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:d.top-this.offset.parent.top-f.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){f._clear(e)})}else{this._clear(e,d)}return false}},cancel:function(){var d=this;if(this.dragging){this._mouseUp({target:null});this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var c=this.containers.length-1;c>=0;c--){this.containers[c]._trigger("deactivate",null,d._uiHash(this));if(this.containers[c].containerCache.over){this.containers[c]._trigger("out",null,d._uiHash(this));this.containers[c].containerCache.over=0}}}if(this.placeholder){this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove();a.extend(this,{helper:null,dragging:false,reverting:false,_noFinalSort:null});this.domPosition.prev?a(this.domPosition.prev).after(this.currentItem):a(this.domPosition.parent).prepend(this.currentItem)}return this},serialize:function(e){var d=this._getItemsAsjQuery(e&&e.connected),f=[];e=e||{};a(d).each(function(){var b=(a(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[-=_](.+)/);if(b){f.push((e.key||b[1]+"[]")+"="+(e.key&&e.expression?b[1]:b[2]))}});!f.length&&e.key&&f.push(e.key+"=");return f.join("&")},toArray:function(e){var d=this._getItemsAsjQuery(e&&e.connected),f=[];e=e||{};d.each(function(){f.push(a(e.item||this).attr(e.attribute||"id")||"")});return f},_intersectsWith:function(w){var v=this.positionAbs.left,u=v+this.helperProportions.width,s=this.positionAbs.top,r=s+this.helperProportions.height,q=w.left,p=q+w.width,o=w.top,m=o+w.height,n=this.offset.click.top,d=this.offset.click.left;n=s+n>o&&s+n<m&&v+d>q&&v+d<p;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>w[this.floating?"width":"height"]?n:q<v+this.helperProportions.width/2&&u-this.helperProportions.width/2<p&&o<s+this.helperProportions.height/2&&r-this.helperProportions.height/2<m},_intersectsWithPointer:function(e){var d=a.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,e.top,e.height);e=a.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,e.left,e.width);d=d&&e;e=this._getDragVerticalDirection();var f=this._getDragHorizontalDirection();if(!d){return false}return this.floating?f&&f=="right"||e=="down"?2:1:e&&(e=="down"?2:1)},_intersectsWithSides:function(f){var d=a.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,f.top+f.height/2,f.height);f=a.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,f.left+f.width/2,f.width);var h=this._getDragVerticalDirection(),g=this._getDragHorizontalDirection();return this.floating&&g?g=="right"&&f||g=="left"&&!f:h&&(h=="down"&&d||h=="up"&&!d)},_getDragVerticalDirection:function(){var b=this.positionAbs.top-this.lastPositionAbs.top;return b!=0&&(b>0?"down":"up")},_getDragHorizontalDirection:function(){var b=this.positionAbs.left-this.lastPositionAbs.left;return b!=0&&(b>0?"right":"left")},refresh:function(b){this._refreshItems(b);this.refreshPositions();return this},_connectWith:function(){var b=this.options;return b.connectWith.constructor==String?[b.connectWith]:b.connectWith},_getItemsAsjQuery:function(i){var d=[],n=[],m=this._connectWith();if(m&&i){for(i=m.length-1;i>=0;i--){for(var l=a(m[i]),k=l.length-1;k>=0;k--){var j=a.data(l[k],"sortable");if(j&&j!=this&&!j.options.disabled){n.push([a.isFunction(j.options.items)?j.options.items.call(j.element):a(j.options.items,j.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),j])}}}}n.push([a.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):a(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(i=n.length-1;i>=0;i--){n[i][0].each(function(){d.push(this)})}return a(d)},_removeCurrentsFromItems:function(){for(var e=this.currentItem.find(":data(sortable-item)"),d=0;d<this.items.length;d++){for(var f=0;f<e.length;f++){e[f]==this.items[d].item[0]&&this.items.splice(d,1)}}},_refreshItems:function(j){this.items=[];this.containers=[this];var d=this.items,p=[[a.isFunction(this.options.items)?this.options.items.call(this.element[0],j,{item:this.currentItem}):a(this.options.items,this.element),this]],o=this._connectWith();if(o){for(var n=o.length-1;n>=0;n--){for(var m=a(o[n]),l=m.length-1;l>=0;l--){var k=a.data(m[l],"sortable");if(k&&k!=this&&!k.options.disabled){p.push([a.isFunction(k.options.items)?k.options.items.call(k.element[0],j,{item:this.currentItem}):a(k.options.items,k.element),k]);this.containers.push(k)}}}}for(n=p.length-1;n>=0;n--){j=p[n][1];o=p[n][0];l=0;for(m=o.length;l<m;l++){k=a(o[l]);k.data("sortable-item",j);d.push({item:k,instance:j,width:0,height:0,left:0,top:0})}}},refreshPositions:function(f){if(this.offsetParent&&this.helper){this.offset.parent=this._getParentOffset()}for(var d=this.items.length-1;d>=0;d--){var h=this.items[d];if(!(h.instance!=this.currentContainer&&this.currentContainer&&h.item[0]!=this.currentItem[0])){var g=this.options.toleranceElement?a(this.options.toleranceElement,h.item):h.item;if(!f){h.width=g.outerWidth();h.height=g.outerHeight()}g=g.offset();h.left=g.left;h.top=g.top}}if(this.options.custom&&this.options.custom.refreshContainers){this.options.custom.refreshContainers.call(this)}else{for(d=this.containers.length-1;d>=0;d--){g=this.containers[d].element.offset();this.containers[d].containerCache.left=g.left;this.containers[d].containerCache.top=g.top;this.containers[d].containerCache.width=this.containers[d].element.outerWidth();this.containers[d].containerCache.height=this.containers[d].element.outerHeight()}}return this},_createPlaceholder:function(f){var d=f||this,h=d.options;if(!h.placeholder||h.placeholder.constructor==String){var g=h.placeholder;h.placeholder={element:function(){var b=a(document.createElement(d.currentItem[0].nodeName)).addClass(g||d.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!g){b.style.visibility="hidden"}return b},update:function(c,b){if(!(g&&!h.forcePlaceholderSize)){b.height()||b.height(d.currentItem.innerHeight()-parseInt(d.currentItem.css("paddingTop")||0,10)-parseInt(d.currentItem.css("paddingBottom")||0,10));b.width()||b.width(d.currentItem.innerWidth()-parseInt(d.currentItem.css("paddingLeft")||0,10)-parseInt(d.currentItem.css("paddingRight")||0,10))}}}}d.placeholder=a(h.placeholder.element.call(d.element,d.currentItem));d.currentItem.after(d.placeholder);h.placeholder.update(d,d.placeholder)},_contactContainers:function(i){for(var d=null,n=null,m=this.containers.length-1;m>=0;m--){if(!a.ui.contains(this.currentItem[0],this.containers[m].element[0])){if(this._intersectsWith(this.containers[m].containerCache)){if(!(d&&a.ui.contains(this.containers[m].element[0],d.element[0]))){d=this.containers[m];n=m}}else{if(this.containers[m].containerCache.over){this.containers[m]._trigger("out",i,this._uiHash(this));this.containers[m].containerCache.over=0}}}}if(d){if(this.containers.length===1){this.containers[n]._trigger("over",i,this._uiHash(this));this.containers[n].containerCache.over=1}else{if(this.currentContainer!=this.containers[n]){d=10000;m=null;for(var l=this.positionAbs[this.containers[n].floating?"left":"top"],k=this.items.length-1;k>=0;k--){if(a.ui.contains(this.containers[n].element[0],this.items[k].item[0])){var j=this.items[k][this.containers[n].floating?"left":"top"];if(Math.abs(j-l)<d){d=Math.abs(j-l);m=this.items[k]}}}if(m||this.options.dropOnEmpty){this.currentContainer=this.containers[n];m?this._rearrange(i,m,null,true):this._rearrange(i,null,this.containers[n].element,true);this._trigger("change",i,this._uiHash());this.containers[n]._trigger("change",i,this._uiHash(this));this.options.placeholder.update(this.currentContainer,this.placeholder);this.containers[n]._trigger("over",i,this._uiHash(this));this.containers[n].containerCache.over=1}}}}},_createHelper:function(d){var c=this.options;d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[d,this.currentItem])):c.helper=="clone"?this.currentItem.clone():this.currentItem;d.parents("body").length||a(c.appendTo!="parent"?c.appendTo:this.currentItem[0].parentNode)[0].appendChild(d[0]);if(d[0]==this.currentItem[0]){this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}}if(d[0].style.width==""||c.forceHelperSize){d.width(this.currentItem.width())}if(d[0].style.height==""||c.forceHelperSize){d.height(this.currentItem.height())}return d},_adjustOffsetFromHelper:function(b){if(typeof b=="string"){b=b.split(" ")}if(a.isArray(b)){b={left:+b[0],top:+b[1]||0}}if("left" in b){this.offset.click.left=b.left+this.margins.left}if("right" in b){this.offset.click.left=this.helperProportions.width-b.right+this.margins.left}if("top" in b){this.offset.click.top=b.top+this.margins.top}if("bottom" in b){this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top}},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])){b.left+=this.scrollParent.scrollLeft();b.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie){b={top:0,left:0}}return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var b=this.currentItem.position();return{top:b.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:b.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else{return{top:0,left:0}}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e=this.options;if(e.containment=="parent"){e.containment=this.helper[0].parentNode}if(e.containment=="document"||e.containment=="window"){this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a(e.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a(e.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]}if(!/^(document|window|parent)$/.test(e.containment)){var d=a(e.containment)[0];e=a(e.containment).offset();var f=a(d).css("overflow")!="hidden";this.containment=[e.left+(parseInt(a(d).css("borderLeftWidth"),10)||0)+(parseInt(a(d).css("paddingLeft"),10)||0)-this.margins.left,e.top+(parseInt(a(d).css("borderTopWidth"),10)||0)+(parseInt(a(d).css("paddingTop"),10)||0)-this.margins.top,e.left+(f?Math.max(d.scrollWidth,d.offsetWidth):d.offsetWidth)-(parseInt(a(d).css("borderLeftWidth"),10)||0)-(parseInt(a(d).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,e.top+(f?Math.max(d.scrollHeight,d.offsetHeight):d.offsetHeight)-(parseInt(a(d).css("borderTopWidth"),10)||0)-(parseInt(a(d).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(f,d){if(!d){d=this.position}f=f=="absolute"?1:-1;var h=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=/(html|body)/i.test(h[0].tagName);return{top:d.top+this.offset.relative.top*f+this.offset.parent.top*f-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:h.scrollTop())*f),left:d.left+this.offset.relative.left*f+this.offset.parent.left*f-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:h.scrollLeft())*f)}},_generatePosition:function(h){var d=this.options,l=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,k=/(html|body)/i.test(l[0].tagName);if(this.cssPosition=="relative"&&!(this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0])){this.offset.relative=this._getRelativeOffset()}var j=h.pageX,i=h.pageY;if(this.originalPosition){if(this.containment){if(h.pageX-this.offset.click.left<this.containment[0]){j=this.containment[0]+this.offset.click.left}if(h.pageY-this.offset.click.top<this.containment[1]){i=this.containment[1]+this.offset.click.top}if(h.pageX-this.offset.click.left>this.containment[2]){j=this.containment[2]+this.offset.click.left}if(h.pageY-this.offset.click.top>this.containment[3]){i=this.containment[3]+this.offset.click.top}}if(d.grid){i=this.originalPageY+Math.round((i-this.originalPageY)/d.grid[1])*d.grid[1];i=this.containment?!(i-this.offset.click.top<this.containment[1]||i-this.offset.click.top>this.containment[3])?i:!(i-this.offset.click.top<this.containment[1])?i-d.grid[1]:i+d.grid[1]:i;j=this.originalPageX+Math.round((j-this.originalPageX)/d.grid[0])*d.grid[0];j=this.containment?!(j-this.offset.click.left<this.containment[0]||j-this.offset.click.left>this.containment[2])?j:!(j-this.offset.click.left<this.containment[0])?j-d.grid[0]:j+d.grid[0]:j}}return{top:i-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():k?0:l.scrollTop()),left:j-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():k?0:l.scrollLeft())}},_rearrange:function(h,d,l,k){l?l[0].appendChild(this.placeholder[0]):d.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?d.item[0]:d.item[0].nextSibling);this.counter=this.counter?++this.counter:1;var j=this,i=this.counter;window.setTimeout(function(){i==j.counter&&j.refreshPositions(!k)},0)},_clear:function(f,d){this.reverting=false;var h=[];!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem);this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var g in this._storedCSS){if(this._storedCSS[g]=="auto"||this._storedCSS[g]=="static"){this._storedCSS[g]=""}}this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else{this.currentItem.show()}this.fromOutside&&!d&&h.push(function(b){this._trigger("receive",b,this._uiHash(this.fromOutside))});if((this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!d){h.push(function(b){this._trigger("update",b,this._uiHash())})}if(!a.ui.contains(this.element[0],this.currentItem[0])){d||h.push(function(b){this._trigger("remove",b,this._uiHash())});for(g=this.containers.length-1;g>=0;g--){if(a.ui.contains(this.containers[g].element[0],this.currentItem[0])&&!d){h.push(function(b){return function(c){b._trigger("receive",c,this._uiHash(this))}}.call(this,this.containers[g]));h.push(function(b){return function(c){b._trigger("update",c,this._uiHash(this))}}.call(this,this.containers[g]))}}}for(g=this.containers.length-1;g>=0;g--){d||h.push(function(b){return function(c){b._trigger("deactivate",c,this._uiHash(this))}}.call(this,this.containers[g]));if(this.containers[g].containerCache.over){h.push(function(b){return function(c){b._trigger("out",c,this._uiHash(this))}}.call(this,this.containers[g]));this.containers[g].containerCache.over=0}}this._storedCursor&&a("body").css("cursor",this._storedCursor);this._storedOpacity&&this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex){this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex)}this.dragging=false;if(this.cancelHelperRemoval){if(!d){this._trigger("beforeStop",f,this._uiHash());for(g=0;g<h.length;g++){h[g].call(this,f)}this._trigger("stop",f,this._uiHash())}return false}d||this._trigger("beforeStop",f,this._uiHash());this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.helper[0]!=this.currentItem[0]&&this.helper.remove();this.helper=null;if(!d){for(g=0;g<h.length;g++){h[g].call(this,f)}this._trigger("stop",f,this._uiHash())}this.fromOutside=false;return true},_trigger:function(){a.Widget.prototype._trigger.apply(this,arguments)===false&&this.cancel()},_uiHash:function(d){var c=d||this;return{helper:c.helper,placeholder:c.placeholder||a([]),position:c.position,originalPosition:c.originalPosition,offset:c.positionAbs,item:c.currentItem,sender:d?d.element:null}}});a.extend(a.ui.sortable,{version:"1.8.16"})})(jQuery);(function(a){a.widget("ui.accordion",{options:{active:0,animated:"slide",autoHeight:true,clearStyle:false,collapsible:false,event:"click",fillSpace:false,header:"> li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:false,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var e=this,c=e.options;e.running=0;e.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix");e.headers=e.element.find(c.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){c.disabled||a(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){c.disabled||a(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){c.disabled||a(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){c.disabled||a(this).removeClass("ui-state-focus")});e.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");if(c.navigation){var g=e.element.find("a").filter(c.navigationFilter).eq(0);if(g.length){var f=g.closest(".ui-accordion-header");e.active=f.length?f:g.closest(".ui-accordion-content").prev()}}e.active=e._findActive(e.active||c.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");e.active.next().addClass("ui-accordion-content-active");e._createIcons();e.resize();e.element.attr("role","tablist");e.headers.attr("role","tab").bind("keydown.accordion",function(b){return e._keydown(b)}).next().attr("role","tabpanel");e.headers.not(e.active||"").attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).next().hide();e.active.length?e.active.attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}):e.headers.eq(0).attr("tabIndex",0);a.browser.safari||e.headers.find("a").attr("tabIndex",-1);c.event&&e.headers.bind(c.event.split(" ").join(".accordion ")+".accordion",function(b){e._clickHandler.call(e,b,this);b.preventDefault()})},_createIcons:function(){var b=this.options;if(b.icons){a("<span></span>").addClass("ui-icon "+b.icons.header).prependTo(this.headers);this.active.children(".ui-icon").toggleClass(b.icons.header).toggleClass(b.icons.headerSelected);this.element.addClass("ui-accordion-icons")}},_destroyIcons:function(){this.headers.children(".ui-icon").remove();this.element.removeClass("ui-accordion-icons")},destroy:function(){var d=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role");this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("tabIndex");this.headers.find("a").removeAttr("tabIndex");this._destroyIcons();var c=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");if(d.autoHeight||d.fillHeight){c.css("height","")}return a.Widget.prototype.destroy.call(this)},_setOption:function(d,c){a.Widget.prototype._setOption.apply(this,arguments);d=="active"&&this.activate(c);if(d=="icons"){this._destroyIcons();c&&this._createIcons()}if(d=="disabled"){this.headers.add(this.headers.next())[c?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")}},_keydown:function(e){if(!(this.options.disabled||e.altKey||e.ctrlKey)){var c=a.ui.keyCode,j=this.headers.length,g=this.headers.index(e.target),i=false;switch(e.keyCode){case c.RIGHT:case c.DOWN:i=this.headers[(g+1)%j];break;case c.LEFT:case c.UP:i=this.headers[(g-1+j)%j];break;case c.SPACE:case c.ENTER:this._clickHandler({target:e.target},e.target);e.preventDefault()}if(i){a(e.target).attr("tabIndex",-1);a(i).attr("tabIndex",0);i.focus();return false}return true}},resize:function(){var e=this.options,c;if(e.fillSpace){if(a.browser.msie){var f=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}c=this.element.parent().height();a.browser.msie&&this.element.parent().css("overflow",f);this.headers.each(function(){c-=a(this).outerHeight(true)});this.headers.next().each(function(){a(this).height(Math.max(0,c-a(this).innerHeight()+a(this).height()))}).css("overflow","auto")}else{if(e.autoHeight){c=0;this.headers.next().each(function(){c=Math.max(c,a(this).height("").height())}).height(c)}}return this},activate:function(b){this.options.active=b;b=this._findActive(b)[0];this._clickHandler({target:b},b);return this},_findActive:function(b){return b?typeof b==="number"?this.headers.filter(":eq("+b+")"):this.headers.not(this.headers.not(b)):b===false?a([]):this.headers.filter(":eq(0)")},_clickHandler:function(i,c){var p=this.options;if(!p.disabled){if(i.target){i=a(i.currentTarget||c);c=i[0]===this.active[0];p.active=p.collapsible&&c?false:this.headers.index(i);if(!(this.running||!p.collapsible&&c)){var l=this.active;k=i.next();m=this.active.next();o={options:p,newHeader:c&&p.collapsible?a([]):i,oldHeader:this.active,newContent:c&&p.collapsible?a([]):k,oldContent:m};var n=this.headers.index(this.active[0])>this.headers.index(i[0]);this.active=c?a([]):i;this._toggle(k,m,o,c,n);l.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(p.icons.headerSelected).addClass(p.icons.header);if(!c){i.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(p.icons.header).addClass(p.icons.headerSelected);i.next().addClass("ui-accordion-content-active")}}}else{if(p.collapsible){this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(p.icons.headerSelected).addClass(p.icons.header);this.active.next().addClass("ui-accordion-content-active");var m=this.active.next(),o={options:p,newHeader:a([]),oldHeader:p.active,newContent:a([]),oldContent:m},k=this.active=a([]);this._toggle(k,m,o)}}}},_toggle:function(u,s,r,n,p){var o=this,q=o.options;o.toShow=u;o.toHide=s;o.data=r;var l=function(){if(o){return o._completed.apply(o,arguments)}};o._trigger("changestart",null,o.data);o.running=s.size()===0?u.size():s.size();if(q.animated){r={};r=q.collapsible&&n?{toShow:a([]),toHide:s,complete:l,down:p,autoHeight:q.autoHeight||q.fillSpace}:{toShow:u,toHide:s,complete:l,down:p,autoHeight:q.autoHeight||q.fillSpace};if(!q.proxied){q.proxied=q.animated}if(!q.proxiedDuration){q.proxiedDuration=q.duration}q.animated=a.isFunction(q.proxied)?q.proxied(r):q.proxied;q.duration=a.isFunction(q.proxiedDuration)?q.proxiedDuration(r):q.proxiedDuration;n=a.ui.accordion.animations;var m=q.duration,c=q.animated;if(c&&!n[c]&&!a.easing[c]){c="slide"}n[c]||(n[c]=function(b){this.slide(b,{easing:c,duration:m||700})});n[c](r)}else{if(q.collapsible&&n){u.toggle()}else{s.hide();u.show()}l(true)}s.prev().attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).blur();u.prev().attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}).focus()},_completed:function(b){this.running=b?0:--this.running;if(!this.running){this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""});this.toHide.removeClass("ui-accordion-content-active");if(this.toHide.length){this.toHide.parent()[0].className=this.toHide.parent()[0].className}this._trigger("change",null,this.data)}}});a.extend(a.ui.accordion,{version:"1.8.16",animations:{slide:function(i,c){i=a.extend({easing:"swing",duration:300},i,c);if(i.toHide.size()){if(i.toShow.size()){var n=i.toShow.css("overflow"),j=0,l={},k={},m;c=i.toShow;m=c[0].style.width;c.width(parseInt(c.parent().width(),10)-parseInt(c.css("paddingLeft"),10)-parseInt(c.css("paddingRight"),10)-(parseInt(c.css("borderLeftWidth"),10)||0)-(parseInt(c.css("borderRightWidth"),10)||0));a.each(["height","paddingTop","paddingBottom"],function(b,d){k[d]="hide";b=(""+a.css(i.toShow[0],d)).match(/^([\d+-.]+)(.*)$/);l[d]={value:b[1],unit:b[2]||"px"}});i.toShow.css({height:0,overflow:"hidden"}).show();i.toHide.filter(":hidden").each(i.complete).end().filter(":visible").animate(k,{step:function(b,d){if(d.prop=="height"){j=d.end-d.start===0?0:(d.now-d.start)/(d.end-d.start)}i.toShow[0].style[d.prop]=j*l[d.prop].value+l[d.prop].unit},duration:i.duration,easing:i.easing,complete:function(){i.autoHeight||i.toShow.css("height","");i.toShow.css({width:m,overflow:n});i.complete()}})}else{i.toHide.animate({height:"hide",paddingTop:"hide",paddingBottom:"hide"},i)}}else{i.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},i)}},bounceslide:function(b){this.slide(b,{easing:b.down?"easeOutBounce":"swing",duration:b.down?1000:200})}}})})(jQuery);(function(b){var a=0;b.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var d=this,c=this.element[0].ownerDocument,e;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(h){if(!(d.options.disabled||d.element.propAttr("readOnly"))){e=false;var g=b.ui.keyCode;switch(h.keyCode){case g.PAGE_UP:d._move("previousPage",h);break;case g.PAGE_DOWN:d._move("nextPage",h);break;case g.UP:d._move("previous",h);h.preventDefault();break;case g.DOWN:d._move("next",h);h.preventDefault();break;case g.ENTER:case g.NUMPAD_ENTER:if(d.menu.active){e=true;h.preventDefault()}case g.TAB:if(!d.menu.active){return}d.menu.select(h);break;case g.ESCAPE:d.element.val(d.term);d.close(h);break;default:clearTimeout(d.searching);d.searching=setTimeout(function(){if(d.term!=d.element.val()){d.selectedItem=null;d.search(null,h)}},d.options.delay);break}}}).bind("keypress.autocomplete",function(f){if(e){e=false;f.preventDefault()}}).bind("focus.autocomplete",function(){if(!d.options.disabled){d.selectedItem=null;d.previous=d.element.val()}}).bind("blur.autocomplete",function(f){if(!d.options.disabled){clearTimeout(d.searching);d.closing=setTimeout(function(){d.close(f);d._change(f)},150)}});this._initSource();this.response=function(){return d._response.apply(d,arguments)};this.menu=b("<ul></ul>").addClass("ui-autocomplete").appendTo(b(this.options.appendTo||"body",c)[0]).mousedown(function(h){var g=d.menu.element[0];b(h.target).closest(".ui-menu-item").length||setTimeout(function(){b(document).one("mousedown",function(f){f.target!==d.element[0]&&f.target!==g&&!b.ui.contains(g,f.target)&&d.close()})},1);setTimeout(function(){clearTimeout(d.closing)},13)}).menu({focus:function(h,g){g=g.item.data("item.autocomplete");false!==d._trigger("focus",h,{item:g})&&/^key/.test(h.originalEvent.type)&&d.element.val(g.value)},selected:function(l,k){var j=k.item.data("item.autocomplete"),g=d.previous;if(d.element[0]!==c.activeElement){d.element.focus();d.previous=g;setTimeout(function(){d.previous=g;d.selectedItem=j},1)}false!==d._trigger("select",l,{item:j})&&d.element.val(j.value);d.term=d.element.val();d.close(l);d.selectedItem=j},blur:function(){d.menu.element.is(":visible")&&d.element.val()!==d.term&&d.element.val(d.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");b.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();b.Widget.prototype.destroy.call(this)},_setOption:function(d,c){b.Widget.prototype._setOption.apply(this,arguments);d==="source"&&this._initSource();if(d==="appendTo"){this.menu.element.appendTo(b(c||"body",this.element[0].ownerDocument)[0])}d==="disabled"&&c&&this.xhr&&this.xhr.abort()},_initSource:function(){var d=this,c,e;if(b.isArray(this.options.source)){c=this.options.source;this.source=function(h,g){g(b.ui.autocomplete.filter(c,h.term))}}else{if(typeof this.options.source==="string"){e=this.options.source;this.source=function(h,g){d.xhr&&d.xhr.abort();d.xhr=b.ajax({url:e,data:h,dataType:"json",autocompleteRequest:++a,success:function(f){this.autocompleteRequest===a&&g(f)},error:function(){this.autocompleteRequest===a&&g([])}})}}else{this.source=this.options.source}}},search:function(d,c){d=d!=null?d:this.element.val();this.term=this.element.val();if(d.length<this.options.minLength){return this.close(c)}clearTimeout(this.closing);if(this._trigger("search",c)!==false){return this._search(d)}},_search:function(c){this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:c},this.response)},_response:function(c){if(!this.options.disabled&&c&&c.length){c=this._normalize(c);this._suggest(c);this._trigger("open")}else{this.close()}this.pending--;this.pending||this.element.removeClass("ui-autocomplete-loading")},close:function(c){clearTimeout(this.closing);if(this.menu.element.is(":visible")){this.menu.element.hide();this.menu.deactivate();this._trigger("close",c)}},_change:function(c){this.previous!==this.element.val()&&this._trigger("change",c,{item:this.selectedItem})},_normalize:function(c){if(c.length&&c[0].label&&c[0].value){return c}return b.map(c,function(d){if(typeof d==="string"){return{label:d,value:d}}return b.extend({label:d.label||d.value,value:d.value||d.label},d)})},_suggest:function(d){var c=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(c,d);this.menu.deactivate();this.menu.refresh();c.show();this._resizeMenu();c.position(b.extend({of:this.element},this.options.position));this.options.autoFocus&&this.menu.next(new b.Event("mouseover"))},_resizeMenu:function(){var c=this.menu.element;c.outerWidth(Math.max(c.width("").outerWidth(),this.element.outerWidth()))},_renderMenu:function(d,c){var e=this;b.each(c,function(h,g){e._renderItem(d,g)})},_renderItem:function(d,c){return b("<li></li>").data("item.autocomplete",c).append(b("<a></a>").text(c.label)).appendTo(d)},_move:function(d,c){if(this.menu.element.is(":visible")){if(this.menu.first()&&/^previous/.test(d)||this.menu.last()&&/^next/.test(d)){this.element.val(this.term);this.menu.deactivate()}else{this.menu[d](c)}}else{this.search(null,c)}},widget:function(){return this.menu.element}});b.extend(b.ui.autocomplete,{escapeRegex:function(c){return c.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(d,c){var e=new RegExp(b.ui.autocomplete.escapeRegex(c),"i");return b.grep(d,function(f){return e.test(f.label||f.value||f)})}})})(jQuery);(function(a){a.widget("ui.menu",{_create:function(){var b=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(c){if(a(c.target).closest(".ui-menu-item a").length){c.preventDefault();b.select(c)}});this.refresh()},refresh:function(){var b=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",-1).mouseenter(function(c){b.activate(c,a(this).parent())}).mouseleave(function(){b.deactivate()})},activate:function(i,f){this.deactivate();if(this.hasScroll()){var d=f.offset().top-this.element.offset().top,h=this.element.scrollTop(),j=this.element.height();if(d<0){this.element.scrollTop(h+d)}else{d>=j&&this.element.scrollTop(h+d-j+f.height())}}this.active=f.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",i,{item:f})},deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id");this._trigger("blur");this.active=null}},next:function(b){this.move("next",".ui-menu-item:first",b)},previous:function(b){this.move("prev",".ui-menu-item:last",b)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(f,d,c){if(this.active){f=this.active[f+"All"](".ui-menu-item").eq(0);f.length?this.activate(c,f):this.activate(c,this.element.children(d))}else{this.activate(c,this.element.children(d))}},nextPage:function(h){if(this.hasScroll()){if(!this.active||this.last()){this.activate(h,this.element.children(".ui-menu-item:first"))}else{var d=this.active.offset().top,c=this.element.height(),f=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-d-c+a(this).height();return b<10&&b>-10});f.length||(f=this.element.children(".ui-menu-item:last"));this.activate(h,f)}}else{this.activate(h,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))}},previousPage:function(f){if(this.hasScroll()){if(!this.active||this.first()){this.activate(f,this.element.children(".ui-menu-item:last"))}else{var d=this.active.offset().top,c=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-d+c-a(this).height();return b<10&&b>-10});result.length||(result=this.element.children(".ui-menu-item:first"));this.activate(f,result)}}else{this.activate(f,this.element.children(".ui-menu-item").filter(!this.active||this.first()?":last":":first"))}},hasScroll:function(){return this.element.height()<this.element[a.fn.prop?"prop":"attr"]("scrollHeight")},select:function(b){this._trigger("selected",b,{item:this.active})}})})(jQuery);(function(a){var m,f,e,n,c=function(){var b=a(this).find(":ui-button");setTimeout(function(){b.button("refresh")},1)},d=function(b){var i=b.name,h=b.form,g=a([]);if(i){g=h?a(h).find("[name='"+i+"']"):a("[name='"+i+"']",b.ownerDocument).filter(function(){return !this.form})}return g};a.widget("ui.button",{options:{disabled:null,text:true,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset.button").bind("reset.button",c);if(typeof this.options.disabled!=="boolean"){this.options.disabled=this.element.propAttr("disabled")}this._determineButtonType();this.hasTitle=!!this.buttonElement.attr("title");var b=this,i=this.options,h=this.type==="checkbox"||this.type==="radio",g="ui-state-hover"+(!h?" ui-state-active":"");if(i.label===null){i.label=this.buttonElement.html()}if(this.element.is(":disabled")){i.disabled=true}this.buttonElement.addClass("ui-button ui-widget ui-state-default ui-corner-all").attr("role","button").bind("mouseenter.button",function(){if(!i.disabled){a(this).addClass("ui-state-hover");this===m&&a(this).addClass("ui-state-active")}}).bind("mouseleave.button",function(){i.disabled||a(this).removeClass(g)}).bind("click.button",function(j){if(i.disabled){j.preventDefault();j.stopImmediatePropagation()}});this.element.bind("focus.button",function(){b.buttonElement.addClass("ui-state-focus")}).bind("blur.button",function(){b.buttonElement.removeClass("ui-state-focus")});if(h){this.element.bind("change.button",function(){n||b.refresh()});this.buttonElement.bind("mousedown.button",function(j){if(!i.disabled){n=false;f=j.pageX;e=j.pageY}}).bind("mouseup.button",function(j){if(!i.disabled){if(f!==j.pageX||e!==j.pageY){n=true}}})}if(this.type==="checkbox"){this.buttonElement.bind("click.button",function(){if(i.disabled||n){return false}a(this).toggleClass("ui-state-active");b.buttonElement.attr("aria-pressed",b.element[0].checked)})}else{if(this.type==="radio"){this.buttonElement.bind("click.button",function(){if(i.disabled||n){return false}a(this).addClass("ui-state-active");b.buttonElement.attr("aria-pressed","true");var j=b.element[0];d(j).not(j).map(function(){return a(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed","false")})}else{this.buttonElement.bind("mousedown.button",function(){if(i.disabled){return false}a(this).addClass("ui-state-active");m=this;a(document).one("mouseup",function(){m=null})}).bind("mouseup.button",function(){if(i.disabled){return false}a(this).removeClass("ui-state-active")}).bind("keydown.button",function(j){if(i.disabled){return false}if(j.keyCode==a.ui.keyCode.SPACE||j.keyCode==a.ui.keyCode.ENTER){a(this).addClass("ui-state-active")}}).bind("keyup.button",function(){a(this).removeClass("ui-state-active")});this.buttonElement.is("a")&&this.buttonElement.keyup(function(j){j.keyCode===a.ui.keyCode.SPACE&&a(this).click()})}}this._setOption("disabled",i.disabled);this._resetButton()},_determineButtonType:function(){this.type=this.element.is(":checkbox")?"checkbox":this.element.is(":radio")?"radio":this.element.is("input")?"input":"button";if(this.type==="checkbox"||this.type==="radio"){var b=this.element.parents().filter(":last"),g="label[for='"+this.element.attr("id")+"']";this.buttonElement=b.find(g);if(!this.buttonElement.length){b=b.length?b.siblings():this.element.siblings();this.buttonElement=b.filter(g);if(!this.buttonElement.length){this.buttonElement=b.find(g)}}this.element.addClass("ui-helper-hidden-accessible");(b=this.element.is(":checked"))&&this.buttonElement.addClass("ui-state-active");this.buttonElement.attr("aria-pressed",b)}else{this.buttonElement=this.element}},widget:function(){return this.buttonElement},destroy:function(){this.element.removeClass("ui-helper-hidden-accessible");this.buttonElement.removeClass("ui-button ui-widget ui-state-default ui-corner-all ui-state-hover ui-state-active ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only").removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html());this.hasTitle||this.buttonElement.removeAttr("title");a.Widget.prototype.destroy.call(this)},_setOption:function(b,g){a.Widget.prototype._setOption.apply(this,arguments);if(b==="disabled"){g?this.element.propAttr("disabled",true):this.element.propAttr("disabled",false)}else{this._resetButton()}},refresh:function(){var b=this.element.is(":disabled");b!==this.options.disabled&&this._setOption("disabled",b);if(this.type==="radio"){d(this.element[0]).each(function(){a(this).is(":checked")?a(this).button("widget").addClass("ui-state-active").attr("aria-pressed","true"):a(this).button("widget").removeClass("ui-state-active").attr("aria-pressed","false")})}else{if(this.type==="checkbox"){this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed","true"):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed","false")}}},_resetButton:function(){if(this.type==="input"){this.options.label&&this.element.val(this.options.label)}else{var b=this.buttonElement.removeClass("ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only"),j=a("<span></span>").addClass("ui-button-text").html(this.options.label).appendTo(b.empty()).text(),h=this.options.icons,g=h.primary&&h.secondary,i=[];if(h.primary||h.secondary){if(this.options.text){i.push("ui-button-text-icon"+(g?"s":h.primary?"-primary":"-secondary"))}h.primary&&b.prepend("<span class='ui-button-icon-primary ui-icon "+h.primary+"'></span>");h.secondary&&b.append("<span class='ui-button-icon-secondary ui-icon "+h.secondary+"'></span>");if(!this.options.text){i.push(g?"ui-button-icons-only":"ui-button-icon-only");this.hasTitle||b.attr("title",j)}}else{i.push("ui-button-text-only")}b.addClass(i.join(" "))}}});a.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(b,g){b==="disabled"&&this.buttons.button("option",b,g);a.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var b=this.element.css("direction")==="ltr";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(b?"ui-corner-left":"ui-corner-right").end().filter(":last").addClass(b?"ui-corner-right":"ui-corner-left").end().end()},destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy");a.Widget.prototype.destroy.call(this)}})})(jQuery);(function(f,b){var a={buttons:true,height:true,maxHeight:true,maxWidth:true,minHeight:true,minWidth:true,width:true},e={maxHeight:true,maxWidth:true,minHeight:true,minWidth:true},d=f.attrFn||{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true,click:true};f.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,position:{my:"center",at:"center",collision:"fit",using:function(g){var c=f(this).css(g).offset().top;c<0&&f(this).css("top",g.top-c)}},resizable:true,show:null,stack:true,title:"",width:300,zIndex:1000},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string"){this.originalTitle=""}this.options.title=this.options.title||this.originalTitle;var i=this,c=i.options,n=c.title||"&#160;",m=f.ui.dialog.getTitleId(i.element),k=(i.uiDialog=f("<div></div>")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+c.dialogClass).css({zIndex:c.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(g){if(c.closeOnEscape&&!g.isDefaultPrevented()&&g.keyCode&&g.keyCode===f.ui.keyCode.ESCAPE){i.close(g);g.preventDefault()}}).attr({role:"dialog","aria-labelledby":m}).mousedown(function(g){i.moveToTop(false,g)});i.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(k);var l=(i.uiDialogTitlebar=f("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(k),j=f('<a href="#"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){j.addClass("ui-state-hover")},function(){j.removeClass("ui-state-hover")}).focus(function(){j.addClass("ui-state-focus")}).blur(function(){j.removeClass("ui-state-focus")}).click(function(g){i.close(g);return false}).appendTo(l);(i.uiDialogTitlebarCloseText=f("<span></span>")).addClass("ui-icon ui-icon-closethick").text(c.closeText).appendTo(j);f("<span></span>").addClass("ui-dialog-title").attr("id",m).html(n).prependTo(l);if(f.isFunction(c.beforeclose)&&!f.isFunction(c.beforeClose)){c.beforeClose=c.beforeclose}l.find("*").add(l).disableSelection();c.draggable&&f.fn.draggable&&i._makeDraggable();c.resizable&&f.fn.resizable&&i._makeResizable();i._createButtons(c.buttons);i._isOpen=false;f.fn.bgiframe&&k.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var c=this;c.overlay&&c.overlay.destroy();c.uiDialog.hide();c.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");c.uiDialog.remove();c.originalTitle&&c.element.attr("title",c.originalTitle);return c},widget:function(){return this.uiDialog},close:function(g){var c=this,i,h;if(false!==c._trigger("beforeClose",g)){c.overlay&&c.overlay.destroy();c.uiDialog.unbind("keypress.ui-dialog");c._isOpen=false;if(c.options.hide){c.uiDialog.hide(c.options.hide,function(){c._trigger("close",g)})}else{c.uiDialog.hide();c._trigger("close",g)}f.ui.dialog.overlay.resize();if(c.options.modal){i=0;f(".ui-dialog").each(function(){if(this!==c.uiDialog[0]){h=f(this).css("z-index");isNaN(h)||(i=Math.max(i,h))}});f.ui.dialog.maxZ=i}return c}},isOpen:function(){return this._isOpen},moveToTop:function(g,c){var i=this,h=i.options;if(h.modal&&!g||!h.stack&&!h.modal){return i._trigger("focus",c)}if(h.zIndex>f.ui.dialog.maxZ){f.ui.dialog.maxZ=h.zIndex}if(i.overlay){f.ui.dialog.maxZ+=1;i.overlay.$el.css("z-index",f.ui.dialog.overlay.maxZ=f.ui.dialog.maxZ)}g={scrollTop:i.element.scrollTop(),scrollLeft:i.element.scrollLeft()};f.ui.dialog.maxZ+=1;i.uiDialog.css("z-index",f.ui.dialog.maxZ);i.element.attr(g);i._trigger("focus",c);return i},open:function(){if(!this._isOpen){var g=this,c=g.options,h=g.uiDialog;g.overlay=c.modal?new f.ui.dialog.overlay(g):null;g._size();g._position(c.position);h.show(c.show);g.moveToTop(true);c.modal&&h.bind("keypress.ui-dialog",function(k){if(k.keyCode===f.ui.keyCode.TAB){var i=f(":tabbable",this),j=i.filter(":first");i=i.filter(":last");if(k.target===i[0]&&!k.shiftKey){j.focus(1);return false}else{if(k.target===j[0]&&k.shiftKey){i.focus(1);return false}}}});f(g.element.find(":tabbable").get().concat(h.find(".ui-dialog-buttonpane :tabbable").get().concat(h.get()))).eq(0).focus();g._isOpen=true;g._trigger("open");return g}},_createButtons:function(h){var c=this,k=false,j=f("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),i=f("<div></div>").addClass("ui-dialog-buttonset").appendTo(j);c.uiDialog.find(".ui-dialog-buttonpane").remove();typeof h==="object"&&h!==null&&f.each(h,function(){return !(k=true)});if(k){f.each(h,function(m,l){l=f.isFunction(l)?{click:l,text:m}:l;var g=f('<button type="button"></button>').click(function(){l.click.apply(c.element[0],arguments)}).appendTo(i);f.each(l,function(o,n){if(o!=="click"){o in d?g[o](n):g.attr(o,n)}});f.fn.button&&g.button()});j.appendTo(c.uiDialog)}},_makeDraggable:function(){function h(g){return{position:g.position,offset:g.offset}}var c=this,k=c.options,j=f(document),i;c.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(l,g){i=k.height==="auto"?"auto":f(this).height();f(this).height(f(this).height()).addClass("ui-dialog-dragging");c._trigger("dragStart",l,h(g))},drag:function(l,g){c._trigger("drag",l,h(g))},stop:function(l,g){k.position=[g.position.left-j.scrollLeft(),g.position.top-j.scrollTop()];f(this).removeClass("ui-dialog-dragging").height(i);c._trigger("dragStop",l,h(g));f.ui.dialog.overlay.resize()}})},_makeResizable:function(h){function c(g){return{originalPosition:g.originalPosition,originalSize:g.originalSize,position:g.position,size:g.size}}h=h===b?this.options.resizable:h;var k=this,j=k.options,i=k.uiDialog.css("position");h=typeof h==="string"?h:"n,e,s,w,se,sw,ne,nw";k.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:k.element,maxWidth:j.maxWidth,maxHeight:j.maxHeight,minWidth:j.minWidth,minHeight:k._minHeight(),handles:h,start:function(l,g){f(this).addClass("ui-dialog-resizing");k._trigger("resizeStart",l,c(g))},resize:function(l,g){k._trigger("resize",l,c(g))},stop:function(l,g){f(this).removeClass("ui-dialog-resizing");j.height=f(this).height();j.width=f(this).width();k._trigger("resizeStop",l,c(g));f.ui.dialog.overlay.resize()}}).css("position",i).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var c=this.options;return c.height==="auto"?c.minHeight:Math.min(c.minHeight,c.height)},_position:function(g){var c=[],i=[0,0],h;if(g){if(typeof g==="string"||typeof g==="object"&&"0" in g){c=g.split?g.split(" "):[g[0],g[1]];if(c.length===1){c[1]=c[0]}f.each(["left","top"],function(j,k){if(+c[j]===c[j]){i[j]=c[j];c[j]=k}});g={my:c.join(" "),at:c.join(" "),offset:i.join(" ")}}g=f.extend({},f.ui.dialog.prototype.options.position,g)}else{g=f.ui.dialog.prototype.options.position}(h=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(f.extend({of:window},g));h||this.uiDialog.hide()},_setOptions:function(g){var c=this,i={},h=false;f.each(g,function(j,k){c._setOption(j,k);if(j in a){h=true}if(j in e){i[j]=k}});h&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",i)},_setOption:function(h,c){var k=this,j=k.uiDialog;switch(h){case"beforeclose":h="beforeClose";break;case"buttons":k._createButtons(c);break;case"closeText":k.uiDialogTitlebarCloseText.text(""+c);break;case"dialogClass":j.removeClass(k.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+c);break;case"disabled":c?j.addClass("ui-dialog-disabled"):j.removeClass("ui-dialog-disabled");break;case"draggable":var i=j.is(":data(draggable)");i&&!c&&j.draggable("destroy");!i&&c&&k._makeDraggable();break;case"position":k._position(c);break;case"resizable":(i=j.is(":data(resizable)"))&&!c&&j.resizable("destroy");i&&typeof c==="string"&&j.resizable("option","handles",c);!i&&c!==false&&k._makeResizable(c);break;case"title":f(".ui-dialog-title",k.uiDialogTitlebar).html(""+(c||"&#160;"));break}f.Widget.prototype._setOption.apply(k,arguments)},_size:function(){var g=this.options,c,i,h=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});if(g.minWidth>g.width){g.width=g.minWidth}c=this.uiDialog.css({height:"auto",width:g.width}).height();i=Math.max(0,g.minHeight-c);if(g.height==="auto"){if(f.support.minHeight){this.element.css({minHeight:i,height:"auto"})}else{this.uiDialog.show();g=this.element.css("height","auto").height();h||this.uiDialog.hide();this.element.height(Math.max(g,i))}}else{this.element.height(Math.max(g.height-c,0))}this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}});f.extend(f.ui.dialog,{version:"1.8.16",uuid:0,maxZ:0,getTitleId:function(c){c=c.attr("id");if(!c){this.uuid+=1;c=this.uuid}return"ui-dialog-title-"+c},overlay:function(c){this.$el=f.ui.dialog.overlay.create(c)}});f.extend(f.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:f.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(c){return c+".dialog-overlay"}).join(" "),create:function(g){if(this.instances.length===0){setTimeout(function(){f.ui.dialog.overlay.instances.length&&f(document).bind(f.ui.dialog.overlay.events,function(h){if(f(h.target).zIndex()<f.ui.dialog.overlay.maxZ){return false}})},1);f(document).bind("keydown.dialog-overlay",function(h){if(g.options.closeOnEscape&&!h.isDefaultPrevented()&&h.keyCode&&h.keyCode===f.ui.keyCode.ESCAPE){g.close(h);h.preventDefault()}});f(window).bind("resize.dialog-overlay",f.ui.dialog.overlay.resize)}var c=(this.oldInstances.pop()||f("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});f.fn.bgiframe&&c.bgiframe();this.instances.push(c);return c},destroy:function(g){var c=f.inArray(g,this.instances);c!=-1&&this.oldInstances.push(this.instances.splice(c,1)[0]);this.instances.length===0&&f([document,window]).unbind(".dialog-overlay");g.remove();var h=0;f.each(this.instances,function(){h=Math.max(h,this.css("z-index"))});this.maxZ=h},height:function(){var g,c;if(f.browser.msie&&f.browser.version<7){g=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);c=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);return g<c?f(window).height()+"px":g+"px"}else{return f(document).height()+"px"}},width:function(){var g,c;if(f.browser.msie){g=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);c=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);return g<c?f(window).width()+"px":g+"px"}else{return f(document).width()+"px"}},resize:function(){var c=f([]);f.each(f.ui.dialog.overlay.instances,function(){c=c.add(this)});c.css({width:0,height:0}).css({width:f.ui.dialog.overlay.width(),height:f.ui.dialog.overlay.height()})}});f.extend(f.ui.dialog.overlay.prototype,{destroy:function(){f.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);(function(a){a.widget("ui.slider",a.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var g=this,d=this.options,l=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),i=d.values&&d.values.length||1,k=[];this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget ui-widget-content ui-corner-all"+(d.disabled?" ui-slider-disabled ui-disabled":""));this.range=a([]);if(d.range){if(d.range===true){if(!d.values){d.values=[this._valueMin(),this._valueMin()]}if(d.values.length&&d.values.length!==2){d.values=[d.values[0],d.values[0]]}}this.range=a("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(d.range==="min"||d.range==="max"?" ui-slider-range-"+d.range:""))}for(var h=l.length;h<i;h+=1){k.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>")}this.handles=l.add(a(k.join("")).appendTo(g.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(b){b.preventDefault()}).hover(function(){d.disabled||a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).focus(function(){if(d.disabled){a(this).blur()}else{a(".ui-slider .ui-state-focus").removeClass("ui-state-focus");a(this).addClass("ui-state-focus")}}).blur(function(){a(this).removeClass("ui-state-focus")});this.handles.each(function(b){a(this).data("index.ui-slider-handle",b)});this.handles.keydown(function(n){var e=true,c=a(this).data("index.ui-slider-handle"),f,j,b;if(!g.options.disabled){switch(n.keyCode){case a.ui.keyCode.HOME:case a.ui.keyCode.END:case a.ui.keyCode.PAGE_UP:case a.ui.keyCode.PAGE_DOWN:case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:e=false;if(!g._keySliding){g._keySliding=true;a(this).addClass("ui-state-active");f=g._start(n,c);if(f===false){return}}break}b=g.options.step;f=g.options.values&&g.options.values.length?(j=g.values(c)):(j=g.value());switch(n.keyCode){case a.ui.keyCode.HOME:j=g._valueMin();break;case a.ui.keyCode.END:j=g._valueMax();break;case a.ui.keyCode.PAGE_UP:j=g._trimAlignValue(f+(g._valueMax()-g._valueMin())/5);break;case a.ui.keyCode.PAGE_DOWN:j=g._trimAlignValue(f-(g._valueMax()-g._valueMin())/5);break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(f===g._valueMax()){return}j=g._trimAlignValue(f+b);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(f===g._valueMin()){return}j=g._trimAlignValue(f-b);break}g._slide(n,c,j);return e}}).keyup(function(c){var b=a(this).data("index.ui-slider-handle");if(g._keySliding){g._keySliding=false;g._stop(c,b);g._change(c,b);a(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();return this},_mouseCapture:function(h){var d=this.options,n,l,m,i,k;if(d.disabled){return false}this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();n=this._normValueFromMouse({x:h.pageX,y:h.pageY});l=this._valueMax()-this._valueMin()+1;i=this;this.handles.each(function(c){var b=Math.abs(n-i.values(c));if(l>b){l=b;m=a(this);k=c}});if(d.range===true&&this.values(1)===d.min){k+=1;m=a(this.handles[k])}if(this._start(h,k)===false){return false}this._mouseSliding=true;i._handleIndex=k;m.addClass("ui-state-active").focus();d=m.offset();this._clickOffset=!a(h.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:h.pageX-d.left-m.width()/2,top:h.pageY-d.top-m.height()/2-(parseInt(m.css("borderTopWidth"),10)||0)-(parseInt(m.css("borderBottomWidth"),10)||0)+(parseInt(m.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(h,k,n);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(d){var c=this._normValueFromMouse({x:d.pageX,y:d.pageY});this._slide(d,this._handleIndex,c);return false},_mouseStop:function(b){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(b,this._handleIndex);this._change(b,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(d){var c;if(this.orientation==="horizontal"){c=this.elementSize.width;d=d.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{c=this.elementSize.height;d=d.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}c=d/c;if(c>1){c=1}if(c<0){c=0}if(this.orientation==="vertical"){c=1-c}d=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+c*d)},_start:function(e,d){var f={handle:this.handles[d],value:this.value()};if(this.options.values&&this.options.values.length){f.value=this.values(d);f.values=this.values()}return this._trigger("start",e,f)},_slide:function(e,d,h){var g;if(this.options.values&&this.options.values.length){g=this.values(d?0:1);if(this.options.values.length===2&&this.options.range===true&&(d===0&&h>g||d===1&&h<g)){h=g}if(h!==this.values(d)){g=this.values();g[d]=h;e=this._trigger("slide",e,{handle:this.handles[d],value:h,values:g});this.values(d?0:1);e!==false&&this.values(d,h,true)}}else{if(h!==this.value()){e=this._trigger("slide",e,{handle:this.handles[d],value:h});e!==false&&this.value(h)}}},_stop:function(e,d){var f={handle:this.handles[d],value:this.value()};if(this.options.values&&this.options.values.length){f.value=this.values(d);f.values=this.values()}this._trigger("stop",e,f)},_change:function(e,d){if(!this._keySliding&&!this._mouseSliding){var f={handle:this.handles[d],value:this.value()};if(this.options.values&&this.options.values.length){f.value=this.values(d);f.values=this.values()}this._trigger("change",e,f)}},value:function(b){if(arguments.length){this.options.value=this._trimAlignValue(b);this._refreshValue();this._change(null,0)}else{return this._value()}},values:function(g,d){var j,h,i;if(arguments.length>1){this.options.values[g]=this._trimAlignValue(d);this._refreshValue();this._change(null,g)}else{if(arguments.length){if(a.isArray(arguments[0])){j=this.options.values;h=arguments[0];for(i=0;i<j.length;i+=1){j[i]=this._trimAlignValue(h[i]);this._change(null,i)}this._refreshValue()}else{return this.options.values&&this.options.values.length?this._values(g):this.value()}}else{return this._values()}}},_setOption:function(e,d){var h,g=0;if(a.isArray(this.options.values)){g=this.options.values.length}a.Widget.prototype._setOption.apply(this,arguments);switch(e){case"disabled":if(d){this.handles.filter(".ui-state-focus").blur();this.handles.removeClass("ui-state-hover");this.handles.propAttr("disabled",true);this.element.addClass("ui-disabled")}else{this.handles.propAttr("disabled",false);this.element.removeClass("ui-disabled")}break;case"orientation":this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case"value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case"values":this._animateOff=true;this._refreshValue();for(h=0;h<g;h+=1){this._change(null,h)}this._animateOff=false;break}},_value:function(){var b=this.options.value;return b=this._trimAlignValue(b)},_values:function(e){var d,f;if(arguments.length){d=this.options.values[e];return d=this._trimAlignValue(d)}else{d=this.options.values.slice();for(f=0;f<d.length;f+=1){d[f]=this._trimAlignValue(d[f])}return d}},_trimAlignValue:function(e){if(e<=this._valueMin()){return this._valueMin()}if(e>=this._valueMax()){return this._valueMax()}var d=this.options.step>0?this.options.step:1,f=(e-this._valueMin())%d;e=e-f;if(Math.abs(f)*2>=d){e+=f>0?d:-d}return parseFloat(e.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var u=this.options.range,s=this.options,r=this,p=!this._animateOff?s.animate:false,q,m={},o,h,d,n;if(this.options.values&&this.options.values.length){this.handles.each(function(b){q=(r.values(b)-r._valueMin())/(r._valueMax()-r._valueMin())*100;m[r.orientation==="horizontal"?"left":"bottom"]=q+"%";a(this).stop(1,1)[p?"animate":"css"](m,s.animate);if(r.options.range===true){if(r.orientation==="horizontal"){if(b===0){r.range.stop(1,1)[p?"animate":"css"]({left:q+"%"},s.animate)}if(b===1){r.range[p?"animate":"css"]({width:q-o+"%"},{queue:false,duration:s.animate})}}else{if(b===0){r.range.stop(1,1)[p?"animate":"css"]({bottom:q+"%"},s.animate)}if(b===1){r.range[p?"animate":"css"]({height:q-o+"%"},{queue:false,duration:s.animate})}}}o=q})}else{h=this.value();d=this._valueMin();n=this._valueMax();q=n!==d?(h-d)/(n-d)*100:0;m[r.orientation==="horizontal"?"left":"bottom"]=q+"%";this.handle.stop(1,1)[p?"animate":"css"](m,s.animate);if(u==="min"&&this.orientation==="horizontal"){this.range.stop(1,1)[p?"animate":"css"]({width:q+"%"},s.animate)}if(u==="max"&&this.orientation==="horizontal"){this.range[p?"animate":"css"]({width:100-q+"%"},{queue:false,duration:s.animate})}if(u==="min"&&this.orientation==="vertical"){this.range.stop(1,1)[p?"animate":"css"]({height:q+"%"},s.animate)}if(u==="max"&&this.orientation==="vertical"){this.range[p?"animate":"css"]({height:100-q+"%"},{queue:false,duration:s.animate})}}}});a.extend(a.ui.slider,{version:"1.8.16"})})(jQuery);(function(g,f){function e(){return ++c}function b(){return ++a}var c=0,a=0;g.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading&#8230;</em>",tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},_create:function(){this._tabify(true)},_setOption:function(d,h){if(d=="selected"){this.options.collapsible&&h==this.options.selected||this.select(h)}else{this.options[d]=h;this._tabify()}},_tabId:function(d){return d.title&&d.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+e()},_sanitizeSelector:function(d){return d.replace(/:/g,"\\:")},_cookie:function(){var d=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+b());return g.cookie.apply(null,[d].concat(g.makeArray(arguments)))},_ui:function(d,h){return{tab:d,panel:h,index:this.anchors.index(d)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var d=g(this);d.html(d.data("label.tabs")).removeData("label.tabs")})},_tabify:function(y){function w(h,j){h.css("display","");!g.support.opacity&&j.opacity&&h[0].style.removeAttribute("filter")}var z=this,x=this.options,v=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=g(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return g("a",this)[0]});this.panels=g([]);this.anchors.each(function(k,n){var j=g(n).attr("href"),h=j.split("#")[0],m;if(h&&(h===location.toString().split("#")[0]||(m=g("base")[0])&&h===m.href)){j=n.hash;n.href=j}if(v.test(j)){z.panels=z.panels.add(z.element.find(z._sanitizeSelector(j)))}else{if(j&&j!=="#"){g.data(n,"href.tabs",j);g.data(n,"load.tabs",j.replace(/#.*$/,""));j=z._tabId(n);n.href="#"+j;n=z.element.find("#"+j);if(!n.length){n=g(x.panelTemplate).attr("id",j).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(z.panels[k-1]||z.list);n.data("destroy.tabs",true)}z.panels=z.panels.add(n)}else{x.disabled.push(k)}}});if(y){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(x.selected===f){location.hash&&this.anchors.each(function(h,j){if(j.hash==location.hash){x.selected=h;return false}});if(typeof x.selected!=="number"&&x.cookie){x.selected=parseInt(z._cookie(),10)}if(typeof x.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length){x.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"))}x.selected=x.selected||(this.lis.length?0:-1)}else{if(x.selected===null){x.selected=-1}}x.selected=x.selected>=0&&this.anchors[x.selected]||x.selected<0?x.selected:0;x.disabled=g.unique(x.disabled.concat(g.map(this.lis.filter(".ui-state-disabled"),function(h){return z.lis.index(h)}))).sort();g.inArray(x.selected,x.disabled)!=-1&&x.disabled.splice(g.inArray(x.selected,x.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");if(x.selected>=0&&this.anchors.length){z.element.find(z._sanitizeSelector(z.anchors[x.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(x.selected).addClass("ui-tabs-selected ui-state-active");z.element.queue("tabs",function(){z._trigger("show",null,z._ui(z.anchors[x.selected],z.element.find(z._sanitizeSelector(z.anchors[x.selected].hash))[0]))});this.load(x.selected)}g(window).bind("unload",function(){z.lis.add(z.anchors).unbind(".tabs");z.lis=z.anchors=z.panels=null})}else{x.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"))}this.element[x.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");x.cookie&&this._cookie(x.selected,x.cookie);y=0;for(var u;u=this.lis[y];y++){g(u)[g.inArray(y,x.disabled)!=-1&&!g(u).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled")}x.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(x.event!=="mouseover"){var q=function(h,j){j.is(":not(.ui-state-disabled)")&&j.addClass("ui-state-"+h)},l=function(h,j){j.removeClass("ui-state-"+h)};this.lis.bind("mouseover.tabs",function(){q("hover",g(this))});this.lis.bind("mouseout.tabs",function(){l("hover",g(this))});this.anchors.bind("focus.tabs",function(){q("focus",g(this).closest("li"))});this.anchors.bind("blur.tabs",function(){l("focus",g(this).closest("li"))})}var p,i;if(x.fx){if(g.isArray(x.fx)){p=x.fx[0];i=x.fx[1]}else{p=i=x.fx}}var d=i?function(h,j){g(h).closest("li").addClass("ui-tabs-selected ui-state-active");j.hide().removeClass("ui-tabs-hide").animate(i,i.duration||"normal",function(){w(j,i);z._trigger("show",null,z._ui(h,j[0]))})}:function(h,j){g(h).closest("li").addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");z._trigger("show",null,z._ui(h,j[0]))},A=p?function(h,j){j.animate(p,p.duration||"normal",function(){z.lis.removeClass("ui-tabs-selected ui-state-active");j.addClass("ui-tabs-hide");w(j,p);z.element.dequeue("tabs")})}:function(h,j){z.lis.removeClass("ui-tabs-selected ui-state-active");j.addClass("ui-tabs-hide");z.element.dequeue("tabs")};this.anchors.bind(x.event+".tabs",function(){var k=this,m=g(k).closest("li"),j=z.panels.filter(":not(.ui-tabs-hide)"),h=z.element.find(z._sanitizeSelector(k.hash));if(m.hasClass("ui-tabs-selected")&&!x.collapsible||m.hasClass("ui-state-disabled")||m.hasClass("ui-state-processing")||z.panels.filter(":animated").length||z._trigger("select",null,z._ui(this,h[0]))===false){this.blur();return false}x.selected=z.anchors.index(this);z.abort();if(x.collapsible){if(m.hasClass("ui-tabs-selected")){x.selected=-1;x.cookie&&z._cookie(x.selected,x.cookie);z.element.queue("tabs",function(){A(k,j)}).dequeue("tabs");this.blur();return false}else{if(!j.length){x.cookie&&z._cookie(x.selected,x.cookie);z.element.queue("tabs",function(){d(k,h)});z.load(z.anchors.index(this));this.blur();return false}}}x.cookie&&z._cookie(x.selected,x.cookie);if(h.length){j.length&&z.element.queue("tabs",function(){A(k,j)});z.element.queue("tabs",function(){d(k,h)});z.load(z.anchors.index(this))}else{throw"jQuery UI Tabs: Mismatching fragment identifier."}g.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(d){if(typeof d=="string"){d=this.anchors.index(this.anchors.filter("[href$="+d+"]"))}return d},destroy:function(){var d=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var i=g.data(this,"href.tabs");if(i){this.href=i}var h=g(this).unbind(".tabs");g.each(["href","load","cache"],function(k,j){h.removeData(j+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){g.data(this,"destroy.tabs")?g(this).remove():g(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});d.cookie&&this._cookie(null,d.cookie);return this},add:function(d,m,i){if(i===f){i=this.anchors.length}var n=this,l=this.options;m=g(l.tabTemplate.replace(/#\{href\}/g,d).replace(/#\{label\}/g,m));d=!d.indexOf("#")?d.replace("#",""):this._tabId(g("a",m)[0]);m.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var k=n.element.find("#"+d);k.length||(k=g(l.panelTemplate).attr("id",d).data("destroy.tabs",true));k.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(i>=this.lis.length){m.appendTo(this.list);k.appendTo(this.list[0].parentNode)}else{m.insertBefore(this.lis[i]);k.insertBefore(this.panels[i])}l.disabled=g.map(l.disabled,function(h){return h>=i?++h:h});this._tabify();if(this.anchors.length==1){l.selected=0;m.addClass("ui-tabs-selected ui-state-active");k.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){n._trigger("show",null,n._ui(n.anchors[0],n.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[i],this.panels[i]));return this},remove:function(d){d=this._getIndex(d);var i=this.options,h=this.lis.eq(d).remove(),j=this.panels.eq(d).remove();if(h.hasClass("ui-tabs-selected")&&this.anchors.length>1){this.select(d+(d+1<this.anchors.length?1:-1))}i.disabled=g.map(g.grep(i.disabled,function(k){return k!=d}),function(k){return k>=d?--k:k});this._tabify();this._trigger("remove",null,this._ui(h.find("a")[0],j[0]));return this},enable:function(d){d=this._getIndex(d);var h=this.options;if(g.inArray(d,h.disabled)!=-1){this.lis.eq(d).removeClass("ui-state-disabled");h.disabled=g.grep(h.disabled,function(i){return i!=d});this._trigger("enable",null,this._ui(this.anchors[d],this.panels[d]));return this}},disable:function(d){d=this._getIndex(d);var h=this.options;if(d!=h.selected){this.lis.eq(d).addClass("ui-state-disabled");h.disabled.push(d);h.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[d],this.panels[d]))}return this},select:function(d){d=this._getIndex(d);if(d==-1){if(this.options.collapsible&&this.options.selected!=-1){d=this.options.selected}else{return this}}this.anchors.eq(d).trigger(this.options.event+".tabs");return this},load:function(d){d=this._getIndex(d);var m=this,i=this.options,n=this.anchors.eq(d)[0],l=g.data(n,"load.tabs");this.abort();if(!l||this.element.queue("tabs").length!==0&&g.data(n,"cache.tabs")){this.element.dequeue("tabs")}else{this.lis.eq(d).addClass("ui-state-processing");if(i.spinner){var k=g("span",n);k.data("label.tabs",k.html()).html(i.spinner)}this.xhr=g.ajax(g.extend({},i.ajaxOptions,{url:l,success:function(j,o){m.element.find(m._sanitizeSelector(n.hash)).html(j);m._cleanup();i.cache&&g.data(n,"cache.tabs",true);m._trigger("load",null,m._ui(m.anchors[d],m.panels[d]));try{i.ajaxOptions.success(j,o)}catch(h){}},error:function(j,o){m._cleanup();m._trigger("load",null,m._ui(m.anchors[d],m.panels[d]));try{i.ajaxOptions.error(j,o,d,n)}catch(h){}}}));m.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this},url:function(d,h){this.anchors.eq(d).removeData("cache.tabs").data("load.tabs",h);return this},length:function(){return this.anchors.length}});g.extend(g.ui.tabs,{version:"1.8.16"});g.extend(g.ui.tabs.prototype,{rotation:null,rotate:function(d,k){var i=this,l=this.options,j=i._rotate||(i._rotate=function(h){clearTimeout(i.rotation);i.rotation=setTimeout(function(){var m=l.selected;i.select(++m<i.anchors.length?m:0)},d);h&&h.stopPropagation()});k=i._unrotate||(i._unrotate=!k?function(h){h.clientX&&i.rotate(null)}:function(){t=l.selected;j()});if(d){this.element.bind("tabsshow",j);this.anchors.bind(l.event+".tabs",k);j()}else{clearTimeout(i.rotation);this.element.unbind("tabsshow",j);this.anchors.unbind(l.event+".tabs",k);delete this._rotate;delete this._unrotate}return this}})})(jQuery);(function(d,C){function M(){this.debug=false;this._curInst=null;this._keyEvent=false;this._disabledInputs=[];this._inDialog=this._datepickerShowing=false;this._mainDivId="ui-datepicker-div";this._inlineClass="ui-datepicker-inline";this._appendClass="ui-datepicker-append";this._triggerClass="ui-datepicker-trigger";this._dialogClass="ui-datepicker-dialog";this._disableClass="ui-datepicker-disabled";this._unselectableClass="ui-datepicker-unselectable";this._currentClass="ui-datepicker-current-day";this._dayOverClass="ui-datepicker-days-cell-over";this.regional=[];this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:false,showMonthAfterYear:false,yearSuffix:""};this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:false,hideIfNoPrevNext:false,navigationAsDateFormat:false,gotoCurrent:false,changeMonth:false,changeYear:false,yearRange:"c-10:c+10",showOtherMonths:false,selectOtherMonths:false,showWeek:false,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:true,showButtonPanel:false,autoSize:false,disabled:false};d.extend(this._defaults,this.regional[""]);this.dpDiv=N(d('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}function N(a){return a.bind("mouseout",function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");b.length&&b.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");if(!(d.datepicker._isDisabledDatepicker(J.inline?a.parent()[0]:J.input[0])||!b.length)){b.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");b.addClass("ui-state-hover");b.hasClass("ui-datepicker-prev")&&b.addClass("ui-datepicker-prev-hover");b.hasClass("ui-datepicker-next")&&b.addClass("ui-datepicker-next-hover")}})}function H(a,b){d.extend(a,b);for(var c in b){if(b[c]==null||b[c]==C){a[c]=b[c]}}return a}d.extend(d.ui,{datepicker:{version:"1.8.16"}});var B=(new Date).getTime(),J;d.extend(M.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(a){H(this._defaults,a||{});return this},_attachDatepicker:function(a,b){var c=null;for(var e in this._defaults){var f=a.getAttribute("date:"+e);if(f){c=c||{};try{c[e]=eval(f)}catch(h){c[e]=f}}}e=a.nodeName.toLowerCase();f=e=="div"||e=="span";if(!a.id){this.uuid+=1;a.id="dp"+this.uuid}var i=this._newInst(d(a),f);i.settings=d.extend({},b||{},c||{});if(e=="input"){this._connectDatepicker(a,i)}else{f&&this._inlineDatepicker(a,i)}},_newInst:function(a,b){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:!b?this.dpDiv:N(d('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}},_connectDatepicker:function(a,b){var c=d(a);b.append=d([]);b.trigger=d([]);if(!c.hasClass(this.markerClassName)){this._attachments(c,b);c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});this._autoSize(b);d.data(a,"datepicker",b);b.settings.disabled&&this._disableDatepicker(a)}},_attachments:function(a,b){var c=this._get(b,"appendText"),e=this._get(b,"isRTL");b.append&&b.append.remove();if(c){b.append=d('<span class="'+this._appendClass+'">'+c+"</span>");a[e?"before":"after"](b.append)}a.unbind("focus",this._showDatepicker);b.trigger&&b.trigger.remove();c=this._get(b,"showOn");if(c=="focus"||c=="both"){a.focus(this._showDatepicker)}if(c=="button"||c=="both"){c=this._get(b,"buttonText");var f=this._get(b,"buttonImage");b.trigger=d(this._get(b,"buttonImageOnly")?d("<img/>").addClass(this._triggerClass).attr({src:f,alt:c,title:c}):d('<button type="button"></button>').addClass(this._triggerClass).html(f==""?c:d("<img/>").attr({src:f,alt:c,title:c})));a[e?"before":"after"](b.trigger);b.trigger.click(function(){d.datepicker._datepickerShowing&&d.datepicker._lastInput==a[0]?d.datepicker._hideDatepicker():d.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var e=function(f){for(var h=0,i=0,g=0;g<f.length;g++){if(f[g].length>h){h=f[g].length;i=g}}return i};b.setMonth(e(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort")));b.setDate(e(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a,b){var c=d(a);if(!c.hasClass(this.markerClassName)){c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});d.data(a,"datepicker",b);this._setDate(b,this._getDefaultDate(b),true);this._updateDatepicker(b);this._updateAlternate(b);b.settings.disabled&&this._disableDatepicker(a);b.dpDiv.css("display","block")}},_dialogDatepicker:function(a,b,c,e,f){a=this._dialogInst;if(!a){this.uuid+=1;this._dialogInput=d('<input type="text" id="'+("dp"+this.uuid)+'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');this._dialogInput.keydown(this._doKeyDown);d("body").append(this._dialogInput);a=this._dialogInst=this._newInst(this._dialogInput,false);a.settings={};d.data(this._dialogInput[0],"datepicker",a)}H(a.settings,e||{});b=b&&b.constructor==Date?this._formatDate(a,b):b;this._dialogInput.val(b);this._pos=f?f.length?f:[f.pageX,f.pageY]:null;if(!this._pos){this._pos=[document.documentElement.clientWidth/2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)]}this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px");a.settings.onSelect=c;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);d.blockUI&&d.blockUI(this.dpDiv);d.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();d.removeData(a,"datepicker");if(e=="input"){c.append.remove();c.trigger.remove();b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)}else{if(e=="div"||e=="span"){b.removeClass(this.markerClassName).empty()}}}},_enableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=false;c.trigger.filter("button").each(function(){this.disabled=false}).end().filter("img").css({opacity:"1.0",cursor:""})}else{if(e=="div"||e=="span"){b=b.children("."+this._inlineClass);b.children().removeClass("ui-state-disabled");b.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled")}}this._disabledInputs=d.map(this._disabledInputs,function(f){return f==a?null:f})}},_disableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=true;c.trigger.filter("button").each(function(){this.disabled=true}).end().filter("img").css({opacity:"0.5",cursor:"default"})}else{if(e=="div"||e=="span"){b=b.children("."+this._inlineClass);b.children().addClass("ui-state-disabled");b.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled")}}this._disabledInputs=d.map(this._disabledInputs,function(f){return f==a?null:f});this._disabledInputs[this._disabledInputs.length]=a}},_isDisabledDatepicker:function(a){if(!a){return false}for(var b=0;b<this._disabledInputs.length;b++){if(this._disabledInputs[b]==a){return true}}return false},_getInst:function(a){try{return d.data(a,"datepicker")}catch(b){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(a,b,c){var e=this._getInst(a);if(arguments.length==2&&typeof b=="string"){return b=="defaults"?d.extend({},d.datepicker._defaults):e?b=="all"?d.extend({},e.settings):this._get(e,b):null}var f=b||{};if(typeof b=="string"){f={};f[b]=c}if(e){this._curInst==e&&this._hideDatepicker();var h=this._getDateDatepicker(a,true),i=this._getMinMaxDate(e,"min"),g=this._getMinMaxDate(e,"max");H(e.settings,f);if(i!==null&&f.dateFormat!==C&&f.minDate===C){e.settings.minDate=this._formatDate(e,i)}if(g!==null&&f.dateFormat!==C&&f.maxDate===C){e.settings.maxDate=this._formatDate(e,g)}this._attachments(d(a),e);this._autoSize(e);this._setDate(e,h);this._updateAlternate(e);this._updateDatepicker(e)}},_changeDatepicker:function(a,b,c){this._optionDatepicker(a,b,c)},_refreshDatepicker:function(a){(a=this._getInst(a))&&this._updateDatepicker(a)},_setDateDatepicker:function(a,b){if(a=this._getInst(a)){this._setDate(a,b);this._updateDatepicker(a);this._updateAlternate(a)}},_getDateDatepicker:function(a,b){(a=this._getInst(a))&&!a.inline&&this._setDateFromField(a,b);return a?this._getDate(a):null},_doKeyDown:function(a){var b=d.datepicker._getInst(a.target),c=true,e=b.dpDiv.is(".ui-datepicker-rtl");b._keyEvent=true;if(d.datepicker._datepickerShowing){switch(a.keyCode){case 9:d.datepicker._hideDatepicker();c=false;break;case 13:c=d("td."+d.datepicker._dayOverClass+":not(."+d.datepicker._currentClass+")",b.dpDiv);c[0]&&d.datepicker._selectDay(a.target,b.selectedMonth,b.selectedYear,c[0]);if(a=d.datepicker._get(b,"onSelect")){c=d.datepicker._formatDate(b);a.apply(b.input?b.input[0]:null,[c,b])}else{d.datepicker._hideDatepicker()}return false;case 27:d.datepicker._hideDatepicker();break;case 33:d.datepicker._adjustDate(a.target,a.ctrlKey?-d.datepicker._get(b,"stepBigMonths"):-d.datepicker._get(b,"stepMonths"),"M");break;case 34:d.datepicker._adjustDate(a.target,a.ctrlKey?+d.datepicker._get(b,"stepBigMonths"):+d.datepicker._get(b,"stepMonths"),"M");break;case 35:if(a.ctrlKey||a.metaKey){d.datepicker._clearDate(a.target)}c=a.ctrlKey||a.metaKey;break;case 36:if(a.ctrlKey||a.metaKey){d.datepicker._gotoToday(a.target)}c=a.ctrlKey||a.metaKey;break;case 37:if(a.ctrlKey||a.metaKey){d.datepicker._adjustDate(a.target,e?+1:-1,"D")}c=a.ctrlKey||a.metaKey;if(a.originalEvent.altKey){d.datepicker._adjustDate(a.target,a.ctrlKey?-d.datepicker._get(b,"stepBigMonths"):-d.datepicker._get(b,"stepMonths"),"M")}break;case 38:if(a.ctrlKey||a.metaKey){d.datepicker._adjustDate(a.target,-7,"D")}c=a.ctrlKey||a.metaKey;break;case 39:if(a.ctrlKey||a.metaKey){d.datepicker._adjustDate(a.target,e?-1:+1,"D")}c=a.ctrlKey||a.metaKey;if(a.originalEvent.altKey){d.datepicker._adjustDate(a.target,a.ctrlKey?+d.datepicker._get(b,"stepBigMonths"):+d.datepicker._get(b,"stepMonths"),"M")}break;case 40:if(a.ctrlKey||a.metaKey){d.datepicker._adjustDate(a.target,+7,"D")}c=a.ctrlKey||a.metaKey;break;default:c=false}}else{if(a.keyCode==36&&a.ctrlKey){d.datepicker._showDatepicker(this)}else{c=false}}if(c){a.preventDefault();a.stopPropagation()}},_doKeyPress:function(a){var b=d.datepicker._getInst(a.target);if(d.datepicker._get(b,"constrainInput")){b=d.datepicker._possibleChars(d.datepicker._get(b,"dateFormat"));var c=String.fromCharCode(a.charCode==C?a.keyCode:a.charCode);return a.ctrlKey||a.metaKey||c<" "||!b||b.indexOf(c)>-1}},_doKeyUp:function(a){a=d.datepicker._getInst(a.target);if(a.input.val()!=a.lastVal){try{if(d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),a.input?a.input.val():null,d.datepicker._getFormatConfig(a))){d.datepicker._setDateFromField(a);d.datepicker._updateAlternate(a);d.datepicker._updateDatepicker(a)}}catch(b){d.datepicker.log(b)}}return true},_showDatepicker:function(a){a=a.target||a;if(a.nodeName.toLowerCase()!="input"){a=d("input",a.parentNode)[0]}if(!(d.datepicker._isDisabledDatepicker(a)||d.datepicker._lastInput==a)){var b=d.datepicker._getInst(a);if(d.datepicker._curInst&&d.datepicker._curInst!=b){d.datepicker._datepickerShowing&&d.datepicker._triggerOnClose(d.datepicker._curInst);d.datepicker._curInst.dpDiv.stop(true,true)}var c=d.datepicker._get(b,"beforeShow");c=c?c.apply(a,[a,b]):{};if(c!==false){H(b.settings,c);b.lastVal=null;d.datepicker._lastInput=a;d.datepicker._setDateFromField(b);if(d.datepicker._inDialog){a.value=""}if(!d.datepicker._pos){d.datepicker._pos=d.datepicker._findPos(a);d.datepicker._pos[1]+=a.offsetHeight}var e=false;d(a).parents().each(function(){e|=d(this).css("position")=="fixed";return !e});if(e&&d.browser.opera){d.datepicker._pos[0]-=document.documentElement.scrollLeft;d.datepicker._pos[1]-=document.documentElement.scrollTop}c={left:d.datepicker._pos[0],top:d.datepicker._pos[1]};d.datepicker._pos=null;b.dpDiv.empty();b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"});d.datepicker._updateDatepicker(b);c=d.datepicker._checkOffset(b,c,e);b.dpDiv.css({position:d.datepicker._inDialog&&d.blockUI?"static":e?"fixed":"absolute",display:"none",left:c.left+"px",top:c.top+"px"});if(!b.inline){c=d.datepicker._get(b,"showAnim");var f=d.datepicker._get(b,"duration"),h=function(){var i=b.dpDiv.find("iframe.ui-datepicker-cover");if(i.length){var g=d.datepicker._getBorders(b.dpDiv);i.css({left:-g[0],top:-g[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})}};b.dpDiv.zIndex(d(a).zIndex()+1);d.datepicker._datepickerShowing=true;d.effects&&d.effects[c]?b.dpDiv.show(c,d.datepicker._get(b,"showOptions"),f,h):b.dpDiv[c||"show"](c?f:null,h);if(!c||!f){h()}b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus();d.datepicker._curInst=b}}}},_updateDatepicker:function(a){this.maxRows=4;var b=d.datepicker._getBorders(a.dpDiv);J=a;a.dpDiv.empty().append(this._generateHTML(a));var c=a.dpDiv.find("iframe.ui-datepicker-cover");c.length&&c.css({left:-b[0],top:-b[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()});a.dpDiv.find("."+this._dayOverClass+" a").mouseover();b=this._getNumberOfMonths(a);c=b[1];a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");c>1&&a.dpDiv.addClass("ui-datepicker-multi-"+c).css("width",17*c+"em");a.dpDiv[(b[0]!=1||b[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi");a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl");a==d.datepicker._curInst&&d.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&&!a.input.is(":disabled")&&a.input[0]!=document.activeElement&&a.input.focus();if(a.yearshtml){var e=a.yearshtml;setTimeout(function(){e===a.yearshtml&&a.yearshtml&&a.dpDiv.find("select.ui-datepicker-year:first").replaceWith(a.yearshtml);e=a.yearshtml=null},0)}},_getBorders:function(a){var b=function(c){return{thin:1,medium:2,thick:3}[c]||c};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var e=a.dpDiv.outerWidth(),f=a.dpDiv.outerHeight(),h=a.input?a.input.outerWidth():0,i=a.input?a.input.outerHeight():0,g=document.documentElement.clientWidth+d(document).scrollLeft(),j=document.documentElement.clientHeight+d(document).scrollTop();b.left-=this._get(a,"isRTL")?e-h:0;b.left-=c&&b.left==a.input.offset().left?d(document).scrollLeft():0;b.top-=c&&b.top==a.input.offset().top+i?d(document).scrollTop():0;b.left-=Math.min(b.left,b.left+e>g&&g>e?Math.abs(b.left+e-g):0);b.top-=Math.min(b.top,b.top+f>j&&j>f?Math.abs(f+i):0);return b},_findPos:function(a){for(var b=this._get(this._getInst(a),"isRTL");a&&(a.type=="hidden"||a.nodeType!=1||d.expr.filters.hidden(a));){a=a[b?"previousSibling":"nextSibling"]}a=d(a).offset();return[a.left,a.top]},_triggerOnClose:function(a){var b=this._get(a,"onClose");if(b){b.apply(a.input?a.input[0]:null,[a.input?a.input.val():"",a])}},_hideDatepicker:function(a){var b=this._curInst;if(!(!b||a&&b!=d.data(a,"datepicker"))){if(this._datepickerShowing){a=this._get(b,"showAnim");var c=this._get(b,"duration"),e=function(){d.datepicker._tidyDialog(b);this._curInst=null};d.effects&&d.effects[a]?b.dpDiv.hide(a,d.datepicker._get(b,"showOptions"),c,e):b.dpDiv[a=="slideDown"?"slideUp":a=="fadeIn"?"fadeOut":"hide"](a?c:null,e);a||e();d.datepicker._triggerOnClose(b);this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:"absolute",left:"0",top:"-100px"});if(d.blockUI){d.unblockUI();d("body").append(this.dpDiv)}}this._inDialog=false}}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(a){if(d.datepicker._curInst){a=d(a.target);a[0].id!=d.datepicker._mainDivId&&a.parents("#"+d.datepicker._mainDivId).length==0&&!a.hasClass(d.datepicker.markerClassName)&&!a.hasClass(d.datepicker._triggerClass)&&d.datepicker._datepickerShowing&&!(d.datepicker._inDialog&&d.blockUI)&&d.datepicker._hideDatepicker()}},_adjustDate:function(a,b,c){a=d(a);var e=this._getInst(a[0]);if(!this._isDisabledDatepicker(a[0])){this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"):0),c);this._updateDatepicker(e)}},_gotoToday:function(a){a=d(a);var b=this._getInst(a[0]);if(this._get(b,"gotoCurrent")&&b.currentDay){b.selectedDay=b.currentDay;b.drawMonth=b.selectedMonth=b.currentMonth;b.drawYear=b.selectedYear=b.currentYear}else{var c=new Date;b.selectedDay=c.getDate();b.drawMonth=b.selectedMonth=c.getMonth();b.drawYear=b.selectedYear=c.getFullYear()}this._notifyChange(b);this._adjustDate(a)},_selectMonthYear:function(a,b,c){a=d(a);var e=this._getInst(a[0]);e["selected"+(c=="M"?"Month":"Year")]=e["draw"+(c=="M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10);this._notifyChange(e);this._adjustDate(a)},_selectDay:function(a,b,c,e){var f=d(a);if(!(d(e).hasClass(this._unselectableClass)||this._isDisabledDatepicker(f[0]))){f=this._getInst(f[0]);f.selectedDay=f.currentDay=d("a",e).html();f.selectedMonth=f.currentMonth=b;f.selectedYear=f.currentYear=c;this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))}},_clearDate:function(a){a=d(a);this._getInst(a[0]);this._selectDate(a,"")},_selectDate:function(a,b){a=this._getInst(d(a)[0]);b=b!=null?b:this._formatDate(a);a.input&&a.input.val(b);this._updateAlternate(a);var c=this._get(a,"onSelect");if(c){c.apply(a.input?a.input[0]:null,[b,a])}else{a.input&&a.input.trigger("change")}if(a.inline){this._updateDatepicker(a)}else{this._hideDatepicker();this._lastInput=a.input[0];typeof a.input[0]!="object"&&a.input.focus();this._lastInput=null}},_updateAlternate:function(a){var b=this._get(a,"altField");if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),e=this._getDate(a),f=this.formatDate(c,e,this._getFormatConfig(a));d(b).each(function(){d(this).val(f)})}},noWeekends:function(a){a=a.getDay();return[a>0&&a<6,""]},iso8601Week:function(a){a=new Date(a.getTime());a.setDate(a.getDate()+4-(a.getDay()||7));var b=a.getTime();a.setMonth(0);a.setDate(1);return Math.floor(Math.round((b-a)/86400000)/7)+1},parseDate:function(a,b,c){if(a==null||b==null){throw"Invalid arguments"}b=typeof b=="object"?b.toString():b+"";if(b==""){return null}var e=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff;e=typeof e!="string"?e:(new Date).getFullYear()%100+parseInt(e,10);for(var f=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,h=(c?c.dayNames:null)||this._defaults.dayNames,i=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?c.monthNames:null)||this._defaults.monthNames,j=c=-1,l=-1,u=-1,k=false,o=function(p){(p=A+1<a.length&&a.charAt(A+1)==p)&&A++;return p},m=function(p){var D=o(p);p=new RegExp("^\\d{1,"+(p=="@"?14:p=="!"?20:p=="y"&&D?4:p=="o"?3:2)+"}");p=b.substring(q).match(p);if(!p){throw"Missing number at position "+q}q+=p[0].length;return parseInt(p[0],10)},n=function(p,D,K){p=d.map(o(p)?K:D,function(w,x){return[[x,w]]}).sort(function(w,x){return -(w[1].length-x[1].length)});var E=-1;d.each(p,function(w,x){w=x[1];if(b.substr(q,w.length).toLowerCase()==w.toLowerCase()){E=x[0];q+=w.length;return false}});if(E!=-1){return E+1}else{throw"Unknown name at position "+q}},s=function(){if(b.charAt(q)!=a.charAt(A)){throw"Unexpected literal at position "+q}q++},q=0,A=0;A<a.length;A++){if(k){if(a.charAt(A)=="'"&&!o("'")){k=false}else{s()}}else{switch(a.charAt(A)){case"d":l=m("d");break;case"D":n("D",f,h);break;case"o":u=m("o");break;case"m":j=m("m");break;case"M":j=n("M",i,g);break;case"y":c=m("y");break;case"@":var v=new Date(m("@"));c=v.getFullYear();j=v.getMonth()+1;l=v.getDate();break;case"!":v=new Date((m("!")-this._ticksTo1970)/10000);c=v.getFullYear();j=v.getMonth()+1;l=v.getDate();break;case"'":if(o("'")){s()}else{k=true}break;default:s()}}}if(q<b.length){throw"Extra/unparsed characters found in date: "+b.substring(q)}if(c==-1){c=(new Date).getFullYear()}else{if(c<100){c+=(new Date).getFullYear()-(new Date).getFullYear()%100+(c<=e?0:-100)}}if(u>-1){j=1;l=u;do{e=this._getDaysInMonth(c,j-1);if(l<=e){break}j++;l-=e}while(1)}v=this._daylightSavingAdjust(new Date(c,j-1,l));if(v.getFullYear()!=c||v.getMonth()+1!=j||v.getDate()!=l){throw"Invalid date"}return v},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*10000000,formatDate:function(a,b,c){if(!b){return""}var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,h=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort;c=(c?c.monthNames:null)||this._defaults.monthNames;var i=function(o){(o=k+1<a.length&&a.charAt(k+1)==o)&&k++;return o},g=function(o,m,n){m=""+m;if(i(o)){for(;m.length<n;){m="0"+m}}return m},j=function(o,m,n,s){return i(o)?s[m]:n[m]},l="",u=false;if(b){for(var k=0;k<a.length;k++){if(u){if(a.charAt(k)=="'"&&!i("'")){u=false}else{l+=a.charAt(k)}}else{switch(a.charAt(k)){case"d":l+=g("d",b.getDate(),2);break;case"D":l+=j("D",b.getDay(),e,f);break;case"o":l+=g("o",Math.round(((new Date(b.getFullYear(),b.getMonth(),b.getDate())).getTime()-(new Date(b.getFullYear(),0,0)).getTime())/86400000),3);break;case"m":l+=g("m",b.getMonth()+1,2);break;case"M":l+=j("M",b.getMonth(),h,c);break;case"y":l+=i("y")?b.getFullYear():(b.getYear()%100<10?"0":"")+b.getYear()%100;break;case"@":l+=b.getTime();break;case"!":l+=b.getTime()*10000+this._ticksTo1970;break;case"'":if(i("'")){l+="'"}else{u=true}break;default:l+=a.charAt(k)}}}}return l},_possibleChars:function(a){for(var b="",c=false,e=function(h){(h=f+1<a.length&&a.charAt(f+1)==h)&&f++;return h},f=0;f<a.length;f++){if(c){if(a.charAt(f)=="'"&&!e("'")){c=false}else{b+=a.charAt(f)}}else{switch(a.charAt(f)){case"d":case"m":case"y":case"@":b+="0123456789";break;case"D":case"M":return null;case"'":if(e("'")){b+="'"}else{c=true}break;default:b+=a.charAt(f)}}}return b},_get:function(a,b){return a.settings[b]!==C?a.settings[b]:this._defaults[b]},_setDateFromField:function(a,b){if(a.input.val()!=a.lastVal){var c=this._get(a,"dateFormat"),e=a.lastVal=a.input?a.input.val():null,f,h;f=h=this._getDefaultDate(a);var i=this._getFormatConfig(a);try{f=this.parseDate(c,e,i)||h}catch(g){this.log(g);e=b?"":e}a.selectedDay=f.getDate();a.drawMonth=a.selectedMonth=f.getMonth();a.drawYear=a.selectedYear=f.getFullYear();a.currentDay=e?f.getDate():0;a.currentMonth=e?f.getMonth():0;a.currentYear=e?f.getFullYear():0;this._adjustInstDate(a)}},_getDefaultDate:function(a){return this._restrictMinMax(a,this._determineDate(a,this._get(a,"defaultDate"),new Date))},_determineDate:function(a,b,c){var e=function(h){var i=new Date;i.setDate(i.getDate()+h);return i},f=function(h){try{return d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),h,d.datepicker._getFormatConfig(a))}catch(i){}var g=(h.toLowerCase().match(/^c/)?d.datepicker._getDate(a):null)||new Date,j=g.getFullYear(),l=g.getMonth();g=g.getDate();for(var u=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,k=u.exec(h);k;){switch(k[2]||"d"){case"d":case"D":g+=parseInt(k[1],10);break;case"w":case"W":g+=parseInt(k[1],10)*7;break;case"m":case"M":l+=parseInt(k[1],10);g=Math.min(g,d.datepicker._getDaysInMonth(j,l));break;case"y":case"Y":j+=parseInt(k[1],10);g=Math.min(g,d.datepicker._getDaysInMonth(j,l));break}k=u.exec(h)}return new Date(j,l,g)};if(b=(b=b==null||b===""?c:typeof b=="string"?f(b):typeof b=="number"?isNaN(b)?c:e(b):new Date(b.getTime()))&&b.toString()=="Invalid Date"?c:b){b.setHours(0);b.setMinutes(0);b.setSeconds(0);b.setMilliseconds(0)}return this._daylightSavingAdjust(b)},_daylightSavingAdjust:function(a){if(!a){return null}a.setHours(a.getHours()>12?a.getHours()+2:0);return a},_setDate:function(a,b,c){var e=!b,f=a.selectedMonth,h=a.selectedYear;b=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=a.currentDay=b.getDate();a.drawMonth=a.selectedMonth=a.currentMonth=b.getMonth();a.drawYear=a.selectedYear=a.currentYear=b.getFullYear();if((f!=a.selectedMonth||h!=a.selectedYear)&&!c){this._notifyChange(a)}this._adjustInstDate(a);if(a.input){a.input.val(e?"":this._formatDate(a))}},_getDate:function(a){return !a.currentYear||a.input&&a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay))},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),e=this._get(a,"showButtonPanel"),f=this._get(a,"hideIfNoPrevNext"),h=this._get(a,"navigationAsDateFormat"),i=this._getNumberOfMonths(a),g=this._get(a,"showCurrentAtPos"),j=this._get(a,"stepMonths"),l=i[0]!=1||i[1]!=1,u=this._daylightSavingAdjust(!a.currentDay?new Date(9999,9,9):new Date(a.currentYear,a.currentMonth,a.currentDay)),k=this._getMinMaxDate(a,"min"),o=this._getMinMaxDate(a,"max");g=a.drawMonth-g;var m=a.drawYear;if(g<0){g+=12;m--}if(o){var n=this._daylightSavingAdjust(new Date(o.getFullYear(),o.getMonth()-i[0]*i[1]+1,o.getDate()));for(n=k&&n<k?k:n;this._daylightSavingAdjust(new Date(m,g,1))>n;){g--;if(g<0){g=11;m--}}}a.drawMonth=g;a.drawYear=m;n=this._get(a,"prevText");n=!h?n:this.formatDate(n,this._daylightSavingAdjust(new Date(m,g-j,1)),this._getFormatConfig(a));n=this._canAdjustMonth(a,-1,m,g)?'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_'+B+".datepicker._adjustDate('#"+a.id+"', -"+j+", 'M');\" title=\""+n+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"e":"w")+'">'+n+"</span></a>":f?"":'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+n+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"e":"w")+'">'+n+"</span></a>";var s=this._get(a,"nextText");s=!h?s:this.formatDate(s,this._daylightSavingAdjust(new Date(m,g+j,1)),this._getFormatConfig(a));f=this._canAdjustMonth(a,+1,m,g)?'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_'+B+".datepicker._adjustDate('#"+a.id+"', +"+j+", 'M');\" title=\""+s+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"w":"e")+'">'+s+"</span></a>":f?"":'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+s+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"w":"e")+'">'+s+"</span></a>";j=this._get(a,"currentText");s=this._get(a,"gotoCurrent")&&a.currentDay?u:b;j=!h?j:this.formatDate(j,s,this._getFormatConfig(a));h=!a.inline?'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_'+B+'.datepicker._hideDatepicker();">'+this._get(a,"closeText")+"</button>":"";e=e?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(c?h:"")+(this._isInRange(a,s)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_'+B+".datepicker._gotoToday('#"+a.id+"');\">"+j+"</button>":"")+(c?"":h)+"</div>":"";h=parseInt(this._get(a,"firstDay"),10);h=isNaN(h)?0:h;j=this._get(a,"showWeek");s=this._get(a,"dayNames");this._get(a,"dayNamesShort");var q=this._get(a,"dayNamesMin"),A=this._get(a,"monthNames"),v=this._get(a,"monthNamesShort"),p=this._get(a,"beforeShowDay"),D=this._get(a,"showOtherMonths"),K=this._get(a,"selectOtherMonths");this._get(a,"calculateWeek");for(var E=this._getDefaultDate(a),w="",x=0;x<i[0];x++){var O="";this.maxRows=4;for(var G=0;G<i[1];G++){var P=this._daylightSavingAdjust(new Date(m,g,a.selectedDay)),t=" ui-corner-all",y="";if(l){y+='<div class="ui-datepicker-group';if(i[1]>1){switch(G){case 0:y+=" ui-datepicker-group-first";t=" ui-corner-"+(c?"right":"left");break;case i[1]-1:y+=" ui-datepicker-group-last";t=" ui-corner-"+(c?"left":"right");break;default:y+=" ui-datepicker-group-middle";t="";break}}y+='">'}y+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+t+'">'+(/all|left/.test(t)&&x==0?c?f:n:"")+(/all|right/.test(t)&&x==0?c?n:f:"")+this._generateMonthYearHeader(a,g,m,k,o,x>0||G>0,A,v)+'</div><table class="ui-datepicker-calendar"><thead><tr>';var z=j?'<th class="ui-datepicker-week-col">'+this._get(a,"weekHeader")+"</th>":"";for(t=0;t<7;t++){var r=(t+h)%7;z+="<th"+((t+h+6)%7>=5?' class="ui-datepicker-week-end"':"")+'><span title="'+s[r]+'">'+q[r]+"</span></th>"}y+=z+"</tr></thead><tbody>";z=this._getDaysInMonth(m,g);if(m==a.selectedYear&&g==a.selectedMonth){a.selectedDay=Math.min(a.selectedDay,z)}t=(this._getFirstDayOfMonth(m,g)-h+7)%7;z=Math.ceil((t+z)/7);this.maxRows=z=l?this.maxRows>z?this.maxRows:z:z;r=this._daylightSavingAdjust(new Date(m,g,1-t));for(var Q=0;Q<z;Q++){y+="<tr>";var R=!j?"":'<td class="ui-datepicker-week-col">'+this._get(a,"calculateWeek")(r)+"</td>";for(t=0;t<7;t++){var I=p?p.apply(a.input?a.input[0]:null,[r]):[true,""],F=r.getMonth()!=g,L=F&&!K||!I[0]||k&&r<k||o&&r>o;R+='<td class="'+((t+h+6)%7>=5?" ui-datepicker-week-end":"")+(F?" ui-datepicker-other-month":"")+(r.getTime()==P.getTime()&&g==a.selectedMonth&&a._keyEvent||E.getTime()==r.getTime()&&E.getTime()==P.getTime()?" "+this._dayOverClass:"")+(L?" "+this._unselectableClass+" ui-state-disabled":"")+(F&&!D?"":" "+I[1]+(r.getTime()==u.getTime()?" "+this._currentClass:"")+(r.getTime()==b.getTime()?" ui-datepicker-today":""))+'"'+((!F||D)&&I[2]?' title="'+I[2]+'"':"")+(L?"":' onclick="DP_jQuery_'+B+".datepicker._selectDay('#"+a.id+"',"+r.getMonth()+","+r.getFullYear()+', this);return false;"')+">"+(F&&!D?"&#xa0;":L?'<span class="ui-state-default">'+r.getDate()+"</span>":'<a class="ui-state-default'+(r.getTime()==b.getTime()?" ui-state-highlight":"")+(r.getTime()==u.getTime()?" ui-state-active":"")+(F?" ui-priority-secondary":"")+'" href="#">'+r.getDate()+"</a>")+"</td>";r.setDate(r.getDate()+1);r=this._daylightSavingAdjust(r)}y+=R+"</tr>"}g++;if(g>11){g=0;m++}y+="</tbody></table>"+(l?"</div>"+(i[0]>0&&G==i[1]-1?'<div class="ui-datepicker-row-break"></div>':""):"");O+=y}w+=O}w+=e+(d.browser.msie&&parseInt(d.browser.version,10)<7&&!a.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':"");a._keyEvent=false;return w},_generateMonthYearHeader:function(a,b,c,e,f,h,i,g){var j=this._get(a,"changeMonth"),l=this._get(a,"changeYear"),u=this._get(a,"showMonthAfterYear"),k='<div class="ui-datepicker-title">',o="";if(h||!j){o+='<span class="ui-datepicker-month">'+i[b]+"</span>"}else{i=e&&e.getFullYear()==c;var m=f&&f.getFullYear()==c;o+='<select class="ui-datepicker-month" onchange="DP_jQuery_'+B+".datepicker._selectMonthYear('#"+a.id+"', this, 'M');\" >";for(var n=0;n<12;n++){if((!i||n>=e.getMonth())&&(!m||n<=f.getMonth())){o+='<option value="'+n+'"'+(n==b?' selected="selected"':"")+">"+g[n]+"</option>"}}o+="</select>"}u||(k+=o+(h||!(j&&l)?"&#xa0;":""));if(!a.yearshtml){a.yearshtml="";if(h||!l){k+='<span class="ui-datepicker-year">'+c+"</span>"}else{g=this._get(a,"yearRange").split(":");var s=(new Date).getFullYear();i=function(q){q=q.match(/c[+-].*/)?c+parseInt(q.substring(1),10):q.match(/[+-].*/)?s+parseInt(q,10):parseInt(q,10);return isNaN(q)?s:q};b=i(g[0]);g=Math.max(b,i(g[1]||""));b=e?Math.max(b,e.getFullYear()):b;g=f?Math.min(g,f.getFullYear()):g;for(a.yearshtml+='<select class="ui-datepicker-year" onchange="DP_jQuery_'+B+".datepicker._selectMonthYear('#"+a.id+"', this, 'Y');\" >";b<=g;b++){a.yearshtml+='<option value="'+b+'"'+(b==c?' selected="selected"':"")+">"+b+"</option>"}a.yearshtml+="</select>";k+=a.yearshtml;a.yearshtml=null}}k+=this._get(a,"yearSuffix");if(u){k+=(h||!(j&&l)?"&#xa0;":"")+o}k+="</div>";return k},_adjustInstDate:function(a,b,c){var e=a.drawYear+(c=="Y"?b:0),f=a.drawMonth+(c=="M"?b:0);b=Math.min(a.selectedDay,this._getDaysInMonth(e,f))+(c=="D"?b:0);e=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(e,f,b)));a.selectedDay=e.getDate();a.drawMonth=a.selectedMonth=e.getMonth();a.drawYear=a.selectedYear=e.getFullYear();if(c=="M"||c=="Y"){this._notifyChange(a)}},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");b=c&&b<c?c:b;return b=a&&b>a?a:b},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");if(b){b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])}},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return a==null?[1,1]:typeof a=="number"?[1,a]:a},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,e){var f=this._getNumberOfMonths(a);c=this._daylightSavingAdjust(new Date(c,e+(b<0?b:f[0]*f[1]),1));b<0&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(a,c)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!a||b.getTime()<=a.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10);return{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,e){if(!b){a.currentDay=a.selectedDay;a.currentMonth=a.selectedMonth;a.currentYear=a.selectedYear}b=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(e,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),b,this._getFormatConfig(a))}});d.fn.datepicker=function(a){if(!this.length){return this}if(!d.datepicker.initialized){d(document).mousedown(d.datepicker._checkExternalClick).find("body").append(d.datepicker.dpDiv);d.datepicker.initialized=true}var b=Array.prototype.slice.call(arguments,1);if(typeof a=="string"&&(a=="isDisabled"||a=="getDate"||a=="widget")){return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b))}if(a=="option"&&arguments.length==2&&typeof arguments[1]=="string"){return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b))}return this.each(function(){typeof a=="string"?d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this].concat(b)):d.datepicker._attachDatepicker(this,a)})};d.datepicker=new M;d.datepicker.initialized=false;d.datepicker.uuid=(new Date).getTime();d.datepicker.version="1.8.16";window["DP_jQuery_"+B]=d})(jQuery);(function(a,c){a.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()});this.valueDiv=a("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>").appendTo(this.element);this.oldValue=this._value();this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow");this.valueDiv.remove();a.Widget.prototype.destroy.apply(this,arguments)},value:function(b){if(b===c){return this._value()}this._setOption("value",b);return this},_setOption:function(b,d){if(b==="value"){this.options.value=d;this._refreshValue();this._value()===this.options.max&&this._trigger("complete")}a.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var b=this.options.value;if(typeof b!=="number"){b=0}return Math.min(this.options.max,Math.max(this.min,b))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var b=this.value(),d=this._percentage();if(this.oldValue!==b){this.oldValue=b;this._trigger("change")}this.valueDiv.toggle(b>this.min).toggleClass("ui-corner-right",b===this.options.max).width(d.toFixed(0)+"%");this.element.attr("aria-valuenow",b)}});a.extend(a.ui.progressbar,{version:"1.8.16"})})(jQuery);jQuery.effects||function(r,i){function e(j){var f;if(j&&j.constructor==Array&&j.length==3){return j}if(f=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(j)){return[parseInt(f[1],10),parseInt(f[2],10),parseInt(f[3],10)]}if(f=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(j)){return[parseFloat(f[1])*2.55,parseFloat(f[2])*2.55,parseFloat(f[3])*2.55]}if(f=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(j)){return[parseInt(f[1],16),parseInt(f[2],16),parseInt(f[3],16)]}if(f=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(j)){return[parseInt(f[1]+f[1],16),parseInt(f[2]+f[2],16),parseInt(f[3]+f[3],16)]}if(/rgba\(0, 0, 0, 0\)/.exec(j)){return d.transparent}return d[r.trim(j).toLowerCase()]}function x(k,j){var f;do{f=r.curCSS(k,j);if(f!=""&&f!="transparent"||r.nodeName(k,"body")){break}j="backgroundColor"}while(k=k.parentNode);return e(f)}function c(){var m=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,j={},f,l;if(m&&m.length&&m[0]&&m[m[0]]){for(var k=m.length;k--;){f=m[k];if(typeof m[f]=="string"){l=f.replace(/\-(\w)/g,function(o,n){return n.toUpperCase()});j[l]=m[f]}}}else{for(f in m){if(typeof m[f]==="string"){j[f]=m[f]}}}return j}function b(k){var j,f;for(j in k){f=k[j];if(f==null||r.isFunction(f)||j in w||/scrollbar/.test(j)||!/color/i.test(j)&&isNaN(parseFloat(f))){delete k[j]}}return k}function v(l,j){var f={_:0},k;for(k in j){if(l[k]!=j[k]){f[k]=j[k]}}return f}function h(l,j,f,k){if(typeof l=="object"){k=j;f=null;j=l;l=j.effect}if(r.isFunction(j)){k=j;f=null;j={}}if(typeof j=="number"||r.fx.speeds[j]){k=f;f=j;j={}}if(r.isFunction(f)){k=f;f=null}j=j||{};f=f||j.duration;f=r.fx.off?0:typeof f=="number"?f:f in r.fx.speeds?r.fx.speeds[f]:r.fx.speeds._default;k=k||j.complete;return[l,j,f,k]}function g(f){if(!f||typeof f==="number"||r.fx.speeds[f]){return true}if(typeof f==="string"&&!r.effects[f]){return true}return false}r.effects={};r.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","borderColor","color","outlineColor"],function(j,f){r.fx.step[f]=function(k){if(!k.colorInit){k.start=x(k.elem,f);k.end=e(k.end);k.colorInit=true}k.elem.style[f]="rgb("+Math.max(Math.min(parseInt(k.pos*(k.end[0]-k.start[0])+k.start[0],10),255),0)+","+Math.max(Math.min(parseInt(k.pos*(k.end[1]-k.start[1])+k.start[1],10),255),0)+","+Math.max(Math.min(parseInt(k.pos*(k.end[2]-k.start[2])+k.start[2],10),255),0)+")"}});var d={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},a=["add","remove","toggle"],w={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};r.effects.animateClass=function(l,j,f,k){if(r.isFunction(f)){k=f;f=null}return this.queue(function(){var q=r(this),p=q.attr("style")||" ",n=b(c.call(this)),o,m=q.attr("class");r.each(a,function(s,u){l[u]&&q[u+"Class"](l[u])});o=b(c.call(this));q.attr("class",m);q.animate(v(n,o),{queue:false,duration:j,easing:f,complete:function(){r.each(a,function(s,u){l[u]&&q[u+"Class"](l[u])});if(typeof q.attr("style")=="object"){q.attr("style").cssText="";q.attr("style").cssText=p}else{q.attr("style",p)}k&&k.apply(this,arguments);r.dequeue(this)}})})};r.fn.extend({_addClass:r.fn.addClass,addClass:function(l,j,f,k){return j?r.effects.animateClass.apply(this,[{add:l},j,f,k]):this._addClass(l)},_removeClass:r.fn.removeClass,removeClass:function(l,j,f,k){return j?r.effects.animateClass.apply(this,[{remove:l},j,f,k]):this._removeClass(l)},_toggleClass:r.fn.toggleClass,toggleClass:function(m,j,f,l,k){return typeof j=="boolean"||j===i?f?r.effects.animateClass.apply(this,[j?{add:m}:{remove:m},f,l,k]):this._toggleClass(m,j):r.effects.animateClass.apply(this,[{toggle:m},j,f,l])},switchClass:function(m,j,f,l,k){return r.effects.animateClass.apply(this,[{add:j,remove:m},f,l,k])}});r.extend(r.effects,{version:"1.8.16",save:function(k,j){for(var f=0;f<j.length;f++){j[f]!==null&&k.data("ec.storage."+j[f],k[0].style[j[f]])}},restore:function(k,j){for(var f=0;f<j.length;f++){j[f]!==null&&k.css(j[f],k.data("ec.storage."+j[f]))}},setMode:function(j,f){if(f=="toggle"){f=j.is(":hidden")?"show":"hide"}return f},getBaseline:function(k,j){var f;switch(k[0]){case"top":f=0;break;case"middle":f=0.5;break;case"bottom":f=1;break;default:f=k[0]/j.height}switch(k[1]){case"left":k=0;break;case"center":k=0.5;break;case"right":k=1;break;default:k=k[1]/j.width}return{x:k,y:f}},createWrapper:function(l){if(l.parent().is(".ui-effects-wrapper")){return l.parent()}var j={width:l.outerWidth(true),height:l.outerHeight(true),"float":l.css("float")},f=r("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),k=document.activeElement;l.wrap(f);if(l[0]===k||r.contains(l[0],k)){r(k).focus()}f=l.parent();if(l.css("position")=="static"){f.css({position:"relative"});l.css({position:"relative"})}else{r.extend(j,{position:l.css("position"),zIndex:l.css("z-index")});r.each(["top","left","bottom","right"],function(n,m){j[m]=l.css(m);if(isNaN(parseInt(j[m],10))){j[m]="auto"}});l.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})}return f.css(j).show()},removeWrapper:function(k){var j,f=document.activeElement;if(k.parent().is(".ui-effects-wrapper")){j=k.parent().replaceWith(k);if(k[0]===f||r.contains(k[0],f)){r(f).focus()}return j}return k},setTransition:function(l,j,f,k){k=k||{};r.each(j,function(n,m){unit=l.cssUnit(m);if(unit[0]>0){k[m]=unit[0]*f+unit[1]}});return k}});r.fn.extend({effect:function(l){var j=h.apply(this,arguments),f={options:j[1],duration:j[2],callback:j[3]};j=f.options.mode;var k=r.effects[l];if(r.fx.off||!k){return j?this[j](f.duration,f.callback):this.each(function(){f.callback&&f.callback.call(this)})}return k.call(this,f)},_show:r.fn.show,show:function(j){if(g(j)){return this._show.apply(this,arguments)}else{var f=h.apply(this,arguments);f[1].mode="show";return this.effect.apply(this,f)}},_hide:r.fn.hide,hide:function(j){if(g(j)){return this._hide.apply(this,arguments)}else{var f=h.apply(this,arguments);f[1].mode="hide";return this.effect.apply(this,f)}},__toggle:r.fn.toggle,toggle:function(j){if(g(j)||typeof j==="boolean"||r.isFunction(j)){return this.__toggle.apply(this,arguments)}else{var f=h.apply(this,arguments);f[1].mode="toggle";return this.effect.apply(this,f)}},cssUnit:function(k){var j=this.css(k),f=[];r.each(["em","px","%","pt"],function(m,l){if(j.indexOf(l)>0){f=[parseFloat(j),l]}});return f}});r.easing.jswing=r.easing.swing;r.extend(r.easing,{def:"easeOutQuad",swing:function(m,j,f,l,k){return r.easing[r.easing.def](m,j,f,l,k)},easeInQuad:function(m,j,f,l,k){return l*(j/=k)*j+f},easeOutQuad:function(m,j,f,l,k){return -l*(j/=k)*(j-2)+f},easeInOutQuad:function(m,j,f,l,k){if((j/=k/2)<1){return l/2*j*j+f}return -l/2*(--j*(j-2)-1)+f},easeInCubic:function(m,j,f,l,k){return l*(j/=k)*j*j+f},easeOutCubic:function(m,j,f,l,k){return l*((j=j/k-1)*j*j+1)+f},easeInOutCubic:function(m,j,f,l,k){if((j/=k/2)<1){return l/2*j*j*j+f}return l/2*((j-=2)*j*j+2)+f},easeInQuart:function(m,j,f,l,k){return l*(j/=k)*j*j*j+f},easeOutQuart:function(m,j,f,l,k){return -l*((j=j/k-1)*j*j*j-1)+f},easeInOutQuart:function(m,j,f,l,k){if((j/=k/2)<1){return l/2*j*j*j*j+f}return -l/2*((j-=2)*j*j*j-2)+f},easeInQuint:function(m,j,f,l,k){return l*(j/=k)*j*j*j*j+f},easeOutQuint:function(m,j,f,l,k){return l*((j=j/k-1)*j*j*j*j+1)+f},easeInOutQuint:function(m,j,f,l,k){if((j/=k/2)<1){return l/2*j*j*j*j*j+f}return l/2*((j-=2)*j*j*j*j+2)+f},easeInSine:function(m,j,f,l,k){return -l*Math.cos(j/k*(Math.PI/2))+l+f},easeOutSine:function(m,j,f,l,k){return l*Math.sin(j/k*(Math.PI/2))+f},easeInOutSine:function(m,j,f,l,k){return -l/2*(Math.cos(Math.PI*j/k)-1)+f},easeInExpo:function(m,j,f,l,k){return j==0?f:l*Math.pow(2,10*(j/k-1))+f},easeOutExpo:function(m,j,f,l,k){return j==k?f+l:l*(-Math.pow(2,-10*j/k)+1)+f},easeInOutExpo:function(m,j,f,l,k){if(j==0){return f}if(j==k){return f+l}if((j/=k/2)<1){return l/2*Math.pow(2,10*(j-1))+f}return l/2*(-Math.pow(2,-10*--j)+2)+f},easeInCirc:function(m,j,f,l,k){return -l*(Math.sqrt(1-(j/=k)*j)-1)+f},easeOutCirc:function(m,j,f,l,k){return l*Math.sqrt(1-(j=j/k-1)*j)+f},easeInOutCirc:function(m,j,f,l,k){if((j/=k/2)<1){return -l/2*(Math.sqrt(1-j*j)-1)+f}return l/2*(Math.sqrt(1-(j-=2)*j)+1)+f},easeInElastic:function(o,j,f,n,m){o=1.70158;var l=0,k=n;if(j==0){return f}if((j/=m)==1){return f+n}l||(l=m*0.3);if(k<Math.abs(n)){k=n;o=l/4}else{o=l/(2*Math.PI)*Math.asin(n/k)}return -(k*Math.pow(2,10*(j-=1))*Math.sin((j*m-o)*2*Math.PI/l))+f},easeOutElastic:function(o,j,f,n,m){o=1.70158;var l=0,k=n;if(j==0){return f}if((j/=m)==1){return f+n}l||(l=m*0.3);if(k<Math.abs(n)){k=n;o=l/4}else{o=l/(2*Math.PI)*Math.asin(n/k)}return k*Math.pow(2,-10*j)*Math.sin((j*m-o)*2*Math.PI/l)+n+f},easeInOutElastic:function(o,j,f,n,m){o=1.70158;var l=0,k=n;if(j==0){return f}if((j/=m/2)==2){return f+n}l||(l=m*0.3*1.5);if(k<Math.abs(n)){k=n;o=l/4}else{o=l/(2*Math.PI)*Math.asin(n/k)}if(j<1){return -0.5*k*Math.pow(2,10*(j-=1))*Math.sin((j*m-o)*2*Math.PI/l)+f}return k*Math.pow(2,-10*(j-=1))*Math.sin((j*m-o)*2*Math.PI/l)*0.5+n+f},easeInBack:function(n,j,f,m,l,k){if(k==i){k=1.70158}return m*(j/=l)*j*((k+1)*j-k)+f},easeOutBack:function(n,j,f,m,l,k){if(k==i){k=1.70158}return m*((j=j/l-1)*j*((k+1)*j+k)+1)+f},easeInOutBack:function(n,j,f,m,l,k){if(k==i){k=1.70158}if((j/=l/2)<1){return m/2*j*j*(((k*=1.525)+1)*j-k)+f}return m/2*((j-=2)*j*(((k*=1.525)+1)*j+k)+2)+f},easeInBounce:function(m,j,f,l,k){return l-r.easing.easeOutBounce(m,k-j,0,l,k)+f},easeOutBounce:function(m,j,f,l,k){return(j/=k)<1/2.75?l*7.5625*j*j+f:j<2/2.75?l*(7.5625*(j-=1.5/2.75)*j+0.75)+f:j<2.5/2.75?l*(7.5625*(j-=2.25/2.75)*j+0.9375)+f:l*(7.5625*(j-=2.625/2.75)*j+0.984375)+f},easeInOutBounce:function(m,j,f,l,k){if(j<k/2){return r.easing.easeInBounce(m,j*2,0,l,k)*0.5+f}return r.easing.easeOutBounce(m,j*2-k,0,l,k)*0.5+l*0.5+f}})}(jQuery);(function(a){a.effects.blind=function(b){return this.queue(function(){var c=a(this),l=["position","top","bottom","left","right"],m=a.effects.setMode(c,b.options.mode||"hide"),o=b.options.direction||"vertical";a.effects.save(c,l);c.show();var n=a.effects.createWrapper(c).css({overflow:"hidden"}),k=o=="vertical"?"height":"width";o=o=="vertical"?n.height():n.width();m=="show"&&n.css(k,0);var j={};j[k]=m=="show"?o:0;n.animate(j,b.duration,b.options.easing,function(){m=="hide"&&c.hide();a.effects.restore(c,l);a.effects.removeWrapper(c);b.callback&&b.callback.apply(c[0],arguments);c.dequeue()})})}})(jQuery);(function(a){a.effects.bounce=function(c){return this.queue(function(){var w=a(this),e=["position","top","bottom","left","right"],q=a.effects.setMode(w,c.options.mode||"effect"),u=c.options.direction||"up",v=c.options.distance||20,b=c.options.times||5,p=c.duration||250;/show|hide/.test(q)&&e.push("opacity");a.effects.save(w,e);w.show();a.effects.createWrapper(w);var s=u=="up"||u=="down"?"top":"left";u=u=="up"||u=="left"?"pos":"neg";v=c.options.distance||(s=="top"?w.outerHeight({margin:true})/3:w.outerWidth({margin:true})/3);if(q=="show"){w.css("opacity",0).css(s,u=="pos"?-v:v)}if(q=="hide"){v/=b*2}q!="hide"&&b--;if(q=="show"){var r={opacity:1};r[s]=(u=="pos"?"+=":"-=")+v;w.animate(r,p/2,c.options.easing);v/=2;b--}for(r=0;r<b;r++){var o={},n={};o[s]=(u=="pos"?"-=":"+=")+v;n[s]=(u=="pos"?"+=":"-=")+v;w.animate(o,p/2,c.options.easing).animate(n,p/2,c.options.easing);v=q=="hide"?v*2:v/2}if(q=="hide"){r={opacity:0};r[s]=(u=="pos"?"-=":"+=")+v;w.animate(r,p/2,c.options.easing,function(){w.hide();a.effects.restore(w,e);a.effects.removeWrapper(w);c.callback&&c.callback.apply(this,arguments)})}else{o={};n={};o[s]=(u=="pos"?"-=":"+=")+v;n[s]=(u=="pos"?"+=":"-=")+v;w.animate(o,p/2,c.options.easing).animate(n,p/2,c.options.easing,function(){a.effects.restore(w,e);a.effects.removeWrapper(w);c.callback&&c.callback.apply(this,arguments)})}w.queue("fx",function(){w.dequeue()});w.dequeue()})}})(jQuery);(function(a){a.effects.clip=function(b){return this.queue(function(){var e=a(this),j=["position","top","bottom","left","right","height","width"],m=a.effects.setMode(e,b.options.mode||"hide"),o=b.options.direction||"vertical";a.effects.save(e,j);e.show();var n=a.effects.createWrapper(e).css({overflow:"hidden"});n=e[0].tagName=="IMG"?n:e;var l={size:o=="vertical"?"height":"width",position:o=="vertical"?"top":"left"};o=o=="vertical"?n.height():n.width();if(m=="show"){n.css(l.size,0);n.css(l.position,o/2)}var k={};k[l.size]=m=="show"?o:0;k[l.position]=m=="show"?0:o/2;n.animate(k,{queue:false,duration:b.duration,easing:b.options.easing,complete:function(){m=="hide"&&e.hide();a.effects.restore(e,j);a.effects.removeWrapper(e);b.callback&&b.callback.apply(e[0],arguments);e.dequeue()}})})}})(jQuery);(function(a){a.effects.drop=function(b){return this.queue(function(){var d=a(this),k=["position","top","bottom","left","right","opacity"],n=a.effects.setMode(d,b.options.mode||"hide"),c=b.options.direction||"left";a.effects.save(d,k);d.show();a.effects.createWrapper(d);var m=c=="up"||c=="down"?"top":"left";c=c=="up"||c=="left"?"pos":"neg";var l=b.options.distance||(m=="top"?d.outerHeight({margin:true})/2:d.outerWidth({margin:true})/2);if(n=="show"){d.css("opacity",0).css(m,c=="pos"?-l:l)}var j={opacity:n=="show"?1:0};j[m]=(n=="show"?c=="pos"?"+=":"-=":c=="pos"?"-=":"+=")+l;d.animate(j,{queue:false,duration:b.duration,easing:b.options.easing,complete:function(){n=="hide"&&d.hide();a.effects.restore(d,k);a.effects.removeWrapper(d);b.callback&&b.callback.apply(this,arguments);d.dequeue()}})})}})(jQuery);(function(a){a.effects.explode=function(b){return this.queue(function(){var q=b.options.pieces?Math.round(Math.sqrt(b.options.pieces)):3,p=b.options.pieces?Math.round(Math.sqrt(b.options.pieces)):3;b.options.mode=b.options.mode=="toggle"?a(this).is(":visible")?"hide":"show":b.options.mode;var j=a(this).show().css("visibility","hidden"),m=j.offset();m.top-=parseInt(j.css("marginTop"),10)||0;m.left-=parseInt(j.css("marginLeft"),10)||0;for(var l=j.outerWidth(true),k=j.outerHeight(true),o=0;o<q;o++){for(var n=0;n<p;n++){j.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-n*(l/p),top:-o*(k/q)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:l/p,height:k/q,left:m.left+n*(l/p)+(b.options.mode=="show"?(n-Math.floor(p/2))*(l/p):0),top:m.top+o*(k/q)+(b.options.mode=="show"?(o-Math.floor(q/2))*(k/q):0),opacity:b.options.mode=="show"?0:1}).animate({left:m.left+n*(l/p)+(b.options.mode=="show"?0:(n-Math.floor(p/2))*(l/p)),top:m.top+o*(k/q)+(b.options.mode=="show"?0:(o-Math.floor(q/2))*(k/q)),opacity:b.options.mode=="show"?1:0},b.duration||500)}}setTimeout(function(){b.options.mode=="show"?j.css({visibility:"visible"}):j.css({visibility:"visible"}).hide();b.callback&&b.callback.apply(j[0]);j.dequeue();a("div.ui-effects-explode").remove()},b.duration||500)})}})(jQuery);(function(a){a.effects.fade=function(b){return this.queue(function(){var f=a(this),e=a.effects.setMode(f,b.options.mode||"hide");f.animate({opacity:e},{queue:false,duration:b.duration,easing:b.options.easing,complete:function(){b.callback&&b.callback.apply(this,arguments);f.dequeue()}})})}})(jQuery);(function(a){a.effects.fold=function(b){return this.queue(function(){var v=a(this),n=["position","top","bottom","left","right"],u=a.effects.setMode(v,b.options.mode||"hide"),q=b.options.size||15,p=!!b.options.horizFirst,m=b.duration?b.duration/2:a.fx.speeds._default/2;a.effects.save(v,n);v.show();var s=a.effects.createWrapper(v).css({overflow:"hidden"}),r=u=="show"!=p,c=r?["width","height"]:["height","width"];r=r?[s.width(),s.height()]:[s.height(),s.width()];var o=/([0-9]+)%/.exec(q);if(o){q=parseInt(o[1],10)/100*r[u=="hide"?0:1]}if(u=="show"){s.css(p?{height:0,width:q}:{height:q,width:0})}p={};o={};p[c[0]]=u=="show"?r[0]:q;o[c[1]]=u=="show"?r[1]:0;s.animate(p,m,b.options.easing).animate(o,m,b.options.easing,function(){u=="hide"&&v.hide();a.effects.restore(v,n);a.effects.removeWrapper(v);b.callback&&b.callback.apply(v[0],arguments);v.dequeue()})})}})(jQuery);(function(a){a.effects.highlight=function(b){return this.queue(function(){var c=a(this),h=["backgroundImage","backgroundColor","opacity"],i=a.effects.setMode(c,b.options.mode||"show"),g={backgroundColor:c.css("backgroundColor")};if(i=="hide"){g.opacity=0}a.effects.save(c,h);c.show().css({backgroundImage:"none",backgroundColor:b.options.color||"#ffff99"}).animate(g,{queue:false,duration:b.duration,easing:b.options.easing,complete:function(){i=="hide"&&c.hide();a.effects.restore(c,h);i=="show"&&!a.support.opacity&&this.style.removeAttribute("filter");b.callback&&b.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery);(function(a){a.effects.pulsate=function(b){return this.queue(function(){var d=a(this),e=a.effects.setMode(d,b.options.mode||"show");times=(b.options.times||5)*2-1;duration=b.duration?b.duration/2:a.fx.speeds._default/2;isVisible=d.is(":visible");animateTo=0;if(!isVisible){d.css("opacity",0).show();animateTo=1}if(e=="hide"&&isVisible||e=="show"&&!isVisible){times--}for(e=0;e<times;e++){d.animate({opacity:animateTo},duration,b.options.easing);animateTo=(animateTo+1)%2}d.animate({opacity:animateTo},duration,b.options.easing,function(){animateTo==0&&d.hide();b.callback&&b.callback.apply(this,arguments)});d.queue("fx",function(){d.dequeue()}).dequeue()})}})(jQuery);(function(a){a.effects.puff=function(c){return this.queue(function(){var b=a(this),k=a.effects.setMode(b,c.options.mode||"hide"),j=parseInt(c.options.percent,10)||150,f=j/100,d={height:b.height(),width:b.width()};a.extend(c.options,{fade:true,mode:k,percent:k=="hide"?j:100,from:k=="hide"?d:{height:d.height*f,width:d.width*f}});b.effect("scale",c.options,c.duration,c.callback);b.dequeue()})};a.effects.scale=function(c){return this.queue(function(){var b=a(this),m=a.extend(true,{},c.options),k=a.effects.setMode(b,c.options.mode||"effect"),j=parseInt(c.options.percent,10)||(parseInt(c.options.percent,10)==0?0:k=="hide"?0:100),d=c.options.direction||"both",l=c.options.origin;if(k!="effect"){m.origin=l||["middle","center"];m.restore=true}l={height:b.height(),width:b.width()};b.from=c.options.from||(k=="show"?{height:0,width:0}:l);j={y:d!="horizontal"?j/100:1,x:d!="vertical"?j/100:1};b.to={height:l.height*j.y,width:l.width*j.x};if(c.options.fade){if(k=="show"){b.from.opacity=0;b.to.opacity=1}if(k=="hide"){b.from.opacity=1;b.to.opacity=0}}m.from=b.from;m.to=b.to;m.mode=k;b.effect("size",m,c.duration,c.callback);b.dequeue()})};a.effects.size=function(c){return this.queue(function(){var B=a(this),z=["position","top","bottom","left","right","width","height","overflow","opacity"],x=["position","top","bottom","left","right","overflow","opacity"],w=["width","height","overflow"],v=["fontSize"],y=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],s=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],b=a.effects.setMode(B,c.options.mode||"effect"),o=c.options.restore||false,q=c.options.scale||"both",r=c.options.origin,u={height:B.height(),width:B.width()};B.from=c.options.from||u;B.to=c.options.to||u;if(r){r=a.effects.getBaseline(r,u);B.from.top=(u.height-B.from.height)*r.y;B.from.left=(u.width-B.from.width)*r.x;B.to.top=(u.height-B.to.height)*r.y;B.to.left=(u.width-B.to.width)*r.x}var A={from:{y:B.from.height/u.height,x:B.from.width/u.width},to:{y:B.to.height/u.height,x:B.to.width/u.width}};if(q=="box"||q=="both"){if(A.from.y!=A.to.y){z=z.concat(y);B.from=a.effects.setTransition(B,y,A.from.y,B.from);B.to=a.effects.setTransition(B,y,A.to.y,B.to)}if(A.from.x!=A.to.x){z=z.concat(s);B.from=a.effects.setTransition(B,s,A.from.x,B.from);B.to=a.effects.setTransition(B,s,A.to.x,B.to)}}if(q=="content"||q=="both"){if(A.from.y!=A.to.y){z=z.concat(v);B.from=a.effects.setTransition(B,v,A.from.y,B.from);B.to=a.effects.setTransition(B,v,A.to.y,B.to)}}a.effects.save(B,o?z:x);B.show();a.effects.createWrapper(B);B.css("overflow","hidden").css(B.from);if(q=="content"||q=="both"){y=y.concat(["marginTop","marginBottom"]).concat(v);s=s.concat(["marginLeft","marginRight"]);w=z.concat(y).concat(s);B.find("*[width]").each(function(){child=a(this);o&&a.effects.save(child,w);var d={height:child.height(),width:child.width()};child.from={height:d.height*A.from.y,width:d.width*A.from.x};child.to={height:d.height*A.to.y,width:d.width*A.to.x};if(A.from.y!=A.to.y){child.from=a.effects.setTransition(child,y,A.from.y,child.from);child.to=a.effects.setTransition(child,y,A.to.y,child.to)}if(A.from.x!=A.to.x){child.from=a.effects.setTransition(child,s,A.from.x,child.from);child.to=a.effects.setTransition(child,s,A.to.x,child.to)}child.css(child.from);child.animate(child.to,c.duration,c.options.easing,function(){o&&a.effects.restore(child,w)})})}B.animate(B.to,{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){B.to.opacity===0&&B.css("opacity",B.from.opacity);b=="hide"&&B.hide();a.effects.restore(B,o?z:x);a.effects.removeWrapper(B);c.callback&&c.callback.apply(this,arguments);B.dequeue()}})})}})(jQuery);(function(a){a.effects.shake=function(b){return this.queue(function(){var v=a(this),n=["position","top","bottom","left","right"];a.effects.setMode(v,b.options.mode||"effect");var u=b.options.direction||"left",s=b.options.distance||20,d=b.options.times||3,r=b.duration||b.options.duration||140;a.effects.save(v,n);v.show();a.effects.createWrapper(v);var q=u=="up"||u=="down"?"top":"left",p=u=="up"||u=="left"?"pos":"neg";u={};var o={},m={};u[q]=(p=="pos"?"-=":"+=")+s;o[q]=(p=="pos"?"+=":"-=")+s*2;m[q]=(p=="pos"?"-=":"+=")+s*2;v.animate(u,r,b.options.easing);for(s=1;s<d;s++){v.animate(o,r,b.options.easing).animate(m,r,b.options.easing)}v.animate(o,r,b.options.easing).animate(u,r/2,b.options.easing,function(){a.effects.restore(v,n);a.effects.removeWrapper(v);b.callback&&b.callback.apply(this,arguments)});v.queue("fx",function(){v.dequeue()});v.dequeue()})}})(jQuery);(function(a){a.effects.slide=function(b){return this.queue(function(){var d=a(this),k=["position","top","bottom","left","right"],m=a.effects.setMode(d,b.options.mode||"show"),c=b.options.direction||"left";a.effects.save(d,k);d.show();a.effects.createWrapper(d).css({overflow:"hidden"});var l=c=="up"||c=="down"?"top":"left";c=c=="up"||c=="left"?"pos":"neg";var n=b.options.distance||(l=="top"?d.outerHeight({margin:true}):d.outerWidth({margin:true}));if(m=="show"){d.css(l,c=="pos"?isNaN(n)?"-"+n:-n:n)}var j={};j[l]=(m=="show"?c=="pos"?"+=":"-=":c=="pos"?"-=":"+=")+n;d.animate(j,{queue:false,duration:b.duration,easing:b.options.easing,complete:function(){m=="hide"&&d.hide();a.effects.restore(d,k);a.effects.removeWrapper(d);b.callback&&b.callback.apply(this,arguments);d.dequeue()}})})}})(jQuery);(function(a){a.effects.transfer=function(b){return this.queue(function(){var e=a(this),i=a(b.options.to),h=i.offset();i={top:h.top,left:h.left,height:i.innerHeight(),width:i.innerWidth()};h=e.offset();var g=a('<div class="ui-effects-transfer"></div>').appendTo(document.body).addClass(b.options.className).css({top:h.top,left:h.left,height:e.innerHeight(),width:e.innerWidth(),position:"absolute"}).animate(i,b.duration,b.options.easing,function(){g.remove();b.callback&&b.callback.apply(e[0],arguments);e.dequeue()})})}})(jQuery);
34
- this.JS=this.JS||{};JS.extend=function(e,d){d=d||{};for(var f in d){if(e[f]===d[f]){continue}e[f]=d[f]}return e};JS.extend(JS,{makeFunction:function(){return function(){return this.initialize?(this.initialize.apply(this,arguments)||this):this}},makeBridge:function(d){var c=function(){};c.prototype=d.prototype;return new c},bind:function(){var e=JS.array(arguments),d=e.shift(),f=e.shift()||null;return function(){return d.apply(f,e.concat(JS.array(arguments)))}},callsSuper:function(b){return b.SUPER===undefined?b.SUPER=/\bcallSuper\b/.test(b.toString()):b.SUPER},mask:function(d){var c=d.toString().replace(/callSuper/g,"super");d.toString=function(){return c};return d},array:function(e){if(!e){return[]}if(e.toArray){return e.toArray()}var d=e.length,f=[];while(d--){f[d]=e[d]}return f},indexOf:function(f,e){for(var h=0,g=f.length;h<g;h++){if(f[h]===e){return h}}return -1},isFn:function(b){return b instanceof Function},isType:function(d,c){if(!d||!c){return false}return(c instanceof Function&&d instanceof c)||(typeof c==="string"&&typeof d===c)||(d.isA&&d.isA(c))},ignore:function(d,c){return/^(include|extend)$/.test(d)&&typeof c==="object"}});JS.Module=JS.makeFunction();JS.extend(JS.Module.prototype,{END_WITHOUT_DOT:/([^\.])$/,initialize:function(e,d,f){this.__mod__=this;this.__inc__=[];this.__fns__={};this.__dep__=[];this.__mct__={};if(typeof e==="string"){this.__nom__=this.displayName=e}else{this.__nom__=this.displayName="";f=d;d=e}f=f||{};this.__res__=f._1||null;if(d){this.include(d,false)}if(JS.Module.__chainq__){JS.Module.__chainq__.push(this)}},setName:function(d){this.__nom__=this.displayName=d||"";for(var c in this.__mod__.__fns__){this.__name__(c)}if(d&&this.__meta__){this.__meta__.setName(d+".")}},__name__:function(d){if(!this.__nom__){return}var c=this.__mod__.__fns__[d]||{};d=this.__nom__.replace(this.END_WITHOUT_DOT,"$1#")+d;if(JS.isFn(c.setName)){return c.setName(d)}if(JS.isFn(c)){c.displayName=d}},define:function(g,e,j,i){var h=(i||{})._0||this;this.__fns__[g]=e;this.__name__(g);if(JS.Module._0&&h&&JS.isFn(e)){JS.Module._0(g,h)}if(j!==false){this.resolve()}},instanceMethod:function(d){var c=this.lookup(d).pop();return JS.isFn(c)?c:null},instanceMethods:function(h,g){var l=this.__mod__,g=g||[],k=l.ancestors(),i=k.length,j;for(j in l.__fns__){if(l.__fns__.hasOwnProperty(j)&&JS.isFn(l.__fns__[j])&&JS.indexOf(g,j)===-1){g.push(j)}}if(h===false){return g}while(i--){k[i].instanceMethods(false,g)}return g},include:function(t,s,r){s=(s!==false);if(!t){return s?this.resolve():this.uncache()}r=r||{};if(t.__mod__){t=t.__mod__}var q=t.include,o=t.extend,p=r._4||this,n,m,l,k;if(t.__inc__&&t.__fns__){this.__inc__.push(t);t.__dep__.push(this);if(r._2){t.extended&&t.extended(r._2)}else{t.included&&t.included(p)}}else{if(r._5){for(m in t){if(JS.ignore(m,t[m])){continue}this.define(m,t[m],false,{_0:p||r._2||this})}}else{if(typeof q==="object"||JS.isType(q,JS.Module)){n=[].concat(q);for(l=0,k=n.length;l<k;l++){p.include(n[l],s,r)}}if(typeof o==="object"||JS.isType(o,JS.Module)){n=[].concat(o);for(l=0,k=n.length;l<k;l++){p.extend(n[l],false)}p.extend()}r._5=true;return p.include(t,s,r)}}s?this.resolve():this.uncache()},includes:function(e){var d=this.__mod__,f=d.__inc__.length;if(Object===e||d===e||d.__res__===e.prototype){return true}while(f--){if(d.__inc__[f].includes(e)){return true}}return false},match:function(b){return b.isA&&b.isA(this)},ancestors:function(i){var h=this.__mod__,n=(i===undefined),m=(h.__res__||{}).klass,k=(m&&h.__res__===m.prototype)?m:h,l,j;if(n&&h.__anc__){return h.__anc__.slice()}i=i||[];for(l=0,j=h.__inc__.length;l<j;l++){h.__inc__[l].ancestors(i)}if(JS.indexOf(i,k)===-1){i.push(k)}if(n){h.__anc__=i.slice()}return i},lookup:function(j){var i=this.__mod__,p=i.__mct__;if(p[j]){return p[j].slice()}var o=i.ancestors(),m=[],n,l,k;for(n=0,l=o.length;n<l;n++){k=o[n].__mod__.__fns__[j];if(k){m.push(k)}}p[j]=m.slice();return m},make:function(e,d){if(!JS.isFn(d)||!JS.callsSuper(d)){return d}var f=this;return function(){return f.chain(this,e,arguments)}},chain:JS.mask(function(p,o,m){var n=this.lookup(o),l=n.length-1,k=p.callSuper,b=JS.array(m),a;p.callSuper=function(){var d=arguments.length;while(d--){b[d]=arguments[d]}l-=1;var c=n[l].apply(p,b);l+=1;return c};a=n.pop().apply(p,b);k?p.callSuper=k:delete p.callSuper;return a}),resolve:function(i){var h=this.__mod__,i=i||h,n=i.__res__,m,k,l,j;if(i===h){h.uncache(false);m=h.__dep__.length;while(m--){h.__dep__[m].resolve()}}if(!n){return}for(m=0,k=h.__inc__.length;m<k;m++){h.__inc__[m].resolve(i)}for(l in h.__fns__){j=i.make(l,h.__fns__[l]);if(n[l]!==j){n[l]=j}}},uncache:function(e){var d=this.__mod__,f=d.__dep__.length;d.__anc__=null;d.__mct__={};if(e===false){return}while(f--){d.__dep__[f].uncache()}}});JS.Class=JS.makeFunction();JS.extend(JS.Class.prototype=JS.makeBridge(JS.Module),{initialize:function(f,e,h){if(typeof f==="string"){this.__nom__=this.displayName=f}else{this.__nom__=this.displayName="";h=e;e=f}var g=JS.extend(JS.makeFunction(),this);g.klass=g.constructor=this.klass;if(!JS.isFn(e)){h=e;e=Object}g.inherit(e);g.include(h,false);g.resolve();do{e.inherited&&e.inherited(g)}while(e=e.superclass);return g},inherit:function(d){this.superclass=d;if(this.__eigen__&&d.__eigen__){this.extend(d.__eigen__(),true)}this.subclasses=[];(d.subclasses||[]).push(this);var c=this.prototype=JS.makeBridge(d);c.klass=c.constructor=this;this.__mod__=new JS.Module(this.__nom__,{},{_1:this.prototype});this.include(JS.Kernel,false);if(d!==Object){this.include(d.__mod__||new JS.Module(d.prototype,{_1:d.prototype}),false)}},include:function(f,e,h){if(!f){return}var g=this.__mod__,h=h||{};h._4=this;return g.include(f,e,h)},define:function(g,e,j,i){var h=this.__mod__;i=i||{};i._0=this;h.define(g,e,j,i)}});JS.Module=new JS.Class("Module",JS.Module.prototype);JS.Class=new JS.Class("Class",JS.Module,JS.Class.prototype);JS.Module.klass=JS.Module.constructor=JS.Class.klass=JS.Class.constructor=JS.Class;JS.extend(JS.Module,{_3:[],__chainq__:[],methodAdded:function(d,c){this._3.push([d,c])},_0:function(f,e){var h=this._3,g=h.length;while(g--){h[g][0].call(h[g][1]||null,f,e)}}});JS.Kernel=JS.extend(new JS.Module("Kernel",{__eigen__:function(){if(this.__meta__){return this.__meta__}var f=this.__nom__,e=this.klass.__nom__,h=f||(e?"#<"+e+">":""),g=this.__meta__=new JS.Module(h?h+".":"",{},{_1:this});g.include(this.klass.__mod__,false);return g},equals:function(b){return this===b},extend:function(d,c){return this.__eigen__().include(d,c,{_2:this})},hash:function(){return this.__hashcode__=this.__hashcode__||JS.Kernel.getHashCode()},isA:function(b){return this.__eigen__().includes(b)},method:function(e){var d=this,f=d.__mcache__=d.__mcache__||{};if((f[e]||{}).fn===d[e]){return f[e].bd}return(f[e]={fn:d[e],bd:JS.bind(d[e],d)}).bd},methods:function(){return this.__eigen__().instanceMethods(true)},tap:function(d,c){d.call(c||null,this);return this}}),{__hashIndex__:0,getHashCode:function(){this.__hashIndex__+=1;return(Math.floor(new Date().getTime()/1000)+this.__hashIndex__).toString(16)}});JS.Module.include(JS.Kernel);JS.extend(JS.Module,JS.Kernel.__fns__);JS.Class.include(JS.Kernel);JS.extend(JS.Class,JS.Kernel.__fns__);JS.Interface=new JS.Class({initialize:function(a){this.test=function(e,d){var f=a.length;while(f--){if(!JS.isFn(e[a[f]])){return d?a[f]:false}}return true}},extend:{ensure:function(){var f=JS.array(arguments),e=f.shift(),h,g;while(h=f.shift()){g=h.test(e,true);if(g!==true){throw new Error("object does not implement "+g+"()")}}}}});JS.Singleton=new JS.Class({initialize:function(e,d,f){return new (new JS.Class(e,d,f))}});
35
- if(typeof Crypto=="undefined"||!Crypto.util){(function(){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var d=window.Crypto={};var a=d.util={rotl:function(h,g){return(h<<g)|(h>>>(32-g))},rotr:function(h,g){return(h<<(32-g))|(h>>>g)},endian:function(h){if(h.constructor==Number){return a.rotl(h,8)&16711935|a.rotl(h,24)&4278255360}for(var g=0;g<h.length;g++){h[g]=a.endian(h[g])}return h},randomBytes:function(h){for(var g=[];h>0;h--){g.push(Math.floor(Math.random()*256))}return g},bytesToWords:function(h){for(var k=[],j=0,g=0;j<h.length;j++,g+=8){k[g>>>5]|=h[j]<<(24-g%32)}return k},wordsToBytes:function(i){for(var h=[],g=0;g<i.length*32;g+=8){h.push((i[g>>>5]>>>(24-g%32))&255)}return h},bytesToHex:function(g){for(var j=[],h=0;h<g.length;h++){j.push((g[h]>>>4).toString(16));j.push((g[h]&15).toString(16))}return j.join("")},hexToBytes:function(h){for(var g=[],i=0;i<h.length;i+=2){g.push(parseInt(h.substr(i,2),16))}return g},bytesToBase64:function(h){if(typeof btoa=="function"){return btoa(e.bytesToString(h))}for(var g=[],l=0;l<h.length;l+=3){var m=(h[l]<<16)|(h[l+1]<<8)|h[l+2];for(var k=0;k<4;k++){if(l*8+k*6<=h.length*8){g.push(c.charAt((m>>>6*(3-k))&63))}else{g.push("=")}}}return g.join("")},base64ToBytes:function(h){if(typeof atob=="function"){return e.stringToBytes(atob(h))}h=h.replace(/[^A-Z0-9+\/]/ig,"");for(var g=[],j=0,k=0;j<h.length;k=++j%4){if(k==0){continue}g.push(((c.indexOf(h.charAt(j-1))&(Math.pow(2,-2*k+8)-1))<<(k*2))|(c.indexOf(h.charAt(j))>>>(6-k*2)))}return g}};var b=d.charenc={};var f=b.UTF8={stringToBytes:function(g){return e.stringToBytes(unescape(encodeURIComponent(g)))},bytesToString:function(g){return decodeURIComponent(escape(e.bytesToString(g)))}};var e=b.Binary={stringToBytes:function(j){for(var g=[],h=0;h<j.length;h++){g.push(j.charCodeAt(h)&255)}return g},bytesToString:function(g){for(var j=[],h=0;h<g.length;h++){j.push(String.fromCharCode(g[h]))}return j.join("")}}})()};
36
- (function(){var f=Crypto,a=f.util,b=f.charenc,e=b.UTF8,d=b.Binary;var c=f.SHA1=function(i,g){var h=a.wordsToBytes(c._sha1(i));return g&&g.asBytes?h:g&&g.asString?d.bytesToString(h):a.bytesToHex(h)};c._sha1=function(o){if(o.constructor==String){o=e.stringToBytes(o)}var v=a.bytesToWords(o),x=o.length*8,p=[],r=1732584193,q=-271733879,k=-1732584194,h=271733878,g=-1009589776;v[x>>5]|=128<<(24-x%32);v[((x+64>>>9)<<4)+15]=x;for(var z=0;z<v.length;z+=16){var E=r,D=q,C=k,B=h,A=g;for(var y=0;y<80;y++){if(y<16){p[y]=v[z+y]}else{var u=p[y-3]^p[y-8]^p[y-14]^p[y-16];p[y]=(u<<1)|(u>>>31)}var s=((r<<5)|(r>>>27))+g+(p[y]>>>0)+(y<20?(q&k|~q&h)+1518500249:y<40?(q^k^h)+1859775393:y<60?(q&k|q&h|k&h)-1894007588:(q^k^h)-899497514);g=h;h=k;k=(q<<30)|(q>>>2);q=r;r=s}r+=E;q+=D;k+=C;h+=B;g+=A}return[r,q,k,h,g]};c._blocksize=16;c._digestsize=20})();
37
- Spontaneous.Diff=(function(){var e=function(){this.Diff_Timeout=1;this.Diff_EditCost=4;this.Match_Threshold=0.5;this.Match_Distance=1000;this.Patch_DeleteThreshold=0.5;this.Patch_Margin=4;this.Match_MaxBits=32};var d=-1;var b=1;var a=0;e.Diff;e.prototype.diff_main=function(g,f,i,k){if(typeof k=="undefined"){if(this.Diff_Timeout<=0){k=Number.MAX_VALUE}else{k=(new Date).getTime()+this.Diff_Timeout*1000}}var n=k;if(g==null||f==null){throw new Error("Null input. (diff_main)")}if(g==f){if(g){return[[a,g]]}return[]}if(typeof i=="undefined"){i=true}var o=i;var j=this.diff_commonPrefix(g,f);var m=g.substring(0,j);g=g.substring(j);f=f.substring(j);j=this.diff_commonSuffix(g,f);var h=g.substring(g.length-j);g=g.substring(0,g.length-j);f=f.substring(0,f.length-j);var l=this.diff_compute_(g,f,o,n);if(m){l.unshift([a,m])}if(h){l.push([a,h])}this.diff_cleanupMerge(l);return l};e.prototype.diff_compute_=function(h,g,v,u){var o;if(!h){return[[b,g]]}if(!g){return[[d,h]]}var r=h.length>g.length?h:g;var j=h.length>g.length?g:h;var l=r.indexOf(j);if(l!=-1){o=[[b,r.substring(0,l)],[a,j],[b,r.substring(l+j.length)]];if(h.length>g.length){o[0][0]=o[2][0]=d}return o}if(j.length==1){return[[d,h],[b,g]]}r=j=null;var f=this.diff_halfMatch_(h,g);if(f){var q=f[0];var n=f[1];var t=f[2];var s=f[3];var k=f[4];var p=this.diff_main(q,t,v,u);var m=this.diff_main(n,s,v,u);return p.concat([[a,k]],m)}if(v&&h.length>100&&g.length>100){return this.diff_lineMode_(h,g,u)}return this.diff_bisect_(h,g,u)};e.prototype.diff_lineMode_=function(h,g,r){var o=this.diff_linesToChars_(h,g);h=(o[0]);g=(o[1]);var i=(o[2]);var l=this.diff_bisect_(h,g,r);this.diff_charsToLines_(l,i);this.diff_cleanupSemantic(l);l.push([a,""]);var f=0;var q=0;var p=0;var n="";var m="";while(f<l.length){switch(l[f][0]){case b:p++;m+=l[f][1];break;case d:q++;n+=l[f][1];break;case a:if(q>=1&&p>=1){var o=this.diff_main(n,m,false,r);l.splice(f-q-p,q+p);f=f-q-p;for(var k=o.length-1;k>=0;k--){l.splice(f,0,o[k])}f=f+o.length}p=0;q=0;n="";m="";break}f++}l.pop();return l};e.prototype.diff_bisect_=function(r,p,E){var A=r.length;var k=p.length;var l=Math.ceil((A+k)/2);var v=l;var s=2*l;var i=new Array(s);var g=new Array(s);for(var q=0;q<s;q++){i[q]=-1;g[q]=-1}i[v+1]=0;g[v+1]=0;var F=A-k;var m=(F%2!=0);var w=0;var t=0;var z=0;var y=0;for(var D=0;D<l;D++){if((new Date()).getTime()>E){break}for(var o=-D+w;o<=D-t;o+=2){var u=v+o;var C;if(o==-D||o!=D&&i[u-1]<i[u+1]){C=i[u+1]}else{C=i[u-1]+1}var j=C-o;while(C<A&&j<k&&r.charAt(C)==p.charAt(j)){C++;j++}i[u]=C;if(C>A){t+=2}else{if(j>k){w+=2}else{if(m){var f=v+F-o;if(f>=0&&f<s&&g[f]!=-1){var B=A-g[f];if(C>=B){return this.diff_bisectSplit_(r,p,C,j,E)}}}}}}for(var n=-D+z;n<=D-y;n+=2){var f=v+n;var B;if(n==-D||n!=D&&g[f-1]<g[f+1]){B=g[f+1]}else{B=g[f-1]+1}var h=B-n;while(B<A&&h<k&&r.charAt(A-B-1)==p.charAt(k-h-1)){B++;h++}g[f]=B;if(B>A){y+=2}else{if(h>k){z+=2}else{if(!m){var u=v+F-n;if(u>=0&&u<s&&i[u]!=-1){var C=i[u];var j=v+C-u;B=A-B;if(C>=B){return this.diff_bisectSplit_(r,p,C,j,E)}}}}}}}return[[d,r],[b,p]]};e.prototype.diff_bisectSplit_=function(i,h,n,m,p){var k=i.substring(0,n);var g=h.substring(0,m);var j=i.substring(n);var f=h.substring(m);var l=this.diff_main(k,g,false,p);var o=this.diff_main(j,f,false,p);return l.concat(o)};e.prototype.diff_linesToChars_=function(l,j){var i=[];var f={};i[0]="";function k(r){var p="";var n=0;var q=-1;var o=i.length;while(q<r.length-1){q=r.indexOf("\n",n);if(q==-1){q=r.length-1}var m=r.substring(n,q+1);n=q+1;if(f.hasOwnProperty?f.hasOwnProperty(m):(f[m]!==undefined)){p+=String.fromCharCode(f[m])}else{p+=String.fromCharCode(o);f[m]=o;i[o++]=m}}return p}var h=k(l);var g=k(j);return[h,g,i]};e.prototype.diff_charsToLines_=function(j,g){for(var f=0;f<j.length;f++){var h=j[f][1];var i=[];for(var k=0;k<h.length;k++){i[k]=g[h.charCodeAt(k)]}j[f][1]=i.join("")}};e.prototype.diff_commonPrefix=function(j,i){if(!j||!i||j.charAt(0)!=i.charAt(0)){return 0}var g=0;var k=Math.min(j.length,i.length);var f=k;var h=0;while(g<f){if(j.substring(h,f)==i.substring(h,f)){g=f;h=g}else{k=f}f=Math.floor((k-g)/2+g)}return f};e.prototype.diff_commonSuffix=function(i,h){if(!i||!h||i.charAt(i.length-1)!=h.charAt(h.length-1)){return 0}var g=0;var j=Math.min(i.length,h.length);var f=j;var k=0;while(g<f){if(i.substring(i.length-f,i.length-k)==h.substring(h.length-f,h.length-k)){g=f;k=g}else{j=f}f=Math.floor((j-g)/2+g)}return f};e.prototype.diff_commonOverlap_=function(g,f){var l=g.length;var j=f.length;if(l==0||j==0){return 0}if(l>j){g=g.substring(l-j)}else{if(l<j){f=f.substring(0,l)}}var m=Math.min(l,j);if(g==f){return m}var i=0;var h=1;while(true){var k=g.substring(m-h);var n=f.indexOf(k);if(n==-1){return i}h+=n;if(n==0||g.substring(m-h)==f.substring(0,h)){i=h;h++}}};e.prototype.diff_halfMatch_=function(h,g){if(this.Diff_Timeout<=0){return null}var o=h.length>g.length?h:g;var i=h.length>g.length?g:h;if(o.length<4||i.length*2<o.length){return null}var s=this;function p(A,t,w){var y=A.substring(w,w+Math.floor(A.length/4));var u=-1;var E="";var x,v,D,C;while((u=t.indexOf(y,u+1))!=-1){var z=s.diff_commonPrefix(A.substring(w),t.substring(u));var B=s.diff_commonSuffix(A.substring(0,w),t.substring(0,u));if(E.length<B+z){E=t.substring(u-B,u)+t.substring(u,u+z);x=A.substring(0,w-B);v=A.substring(w+z);D=t.substring(0,u-B);C=t.substring(u+z)}}if(E.length*2>=A.length){return[x,v,D,C,E]}else{return null}}var l=p(o,i,Math.ceil(o.length/4));var k=p(o,i,Math.ceil(o.length/2));var f;if(!l&&!k){return null}else{if(!k){f=l}else{if(!l){f=k}else{f=l[4].length>k[4].length?l:k}}}var n,m,r,q;if(h.length>g.length){n=f[0];m=f[1];r=f[2];q=f[3]}else{r=f[0];q=f[1];n=f[2];m=f[3]}var j=f[4];return[n,m,r,q,j]};e.prototype.diff_cleanupSemantic=function(p){var r=false;var o=[];var h=0;var i=null;var f=0;var n=0;var m=0;var l=0;var k=0;while(f<p.length){if(p[f][0]==a){o[h++]=f;n=l;m=k;l=0;k=0;i=(p[f][1])}else{if(p[f][0]==b){l+=p[f][1].length}else{k+=p[f][1].length}if(i!==null&&(i.length<=Math.max(n,m))&&(i.length<=Math.max(l,k))){p.splice(o[h-1],0,[d,i]);p[o[h-1]+1][0]=b;h--;h--;f=h>0?o[h-1]:-1;n=0;m=0;l=0;k=0;i=null;r=true}}f++}if(r){this.diff_cleanupMerge(p)}this.diff_cleanupSemanticLossless(p);f=1;while(f<p.length){if(p[f-1][0]==d&&p[f][0]==b){var j=(p[f-1][1]);var g=(p[f][1]);var q=this.diff_commonOverlap_(j,g);if(q>=j.length/2||q>=g.length/2){p.splice(f,0,[a,g.substring(0,q)]);p[f-1][1]=j.substring(0,j.length-q);p[f+1][1]=g.substring(q);f++}f++}f++}};e.prototype.diff_cleanupSemanticLossless=function(g){var j=/[^a-zA-Z0-9]/;var u=/\s/;var i=/[\r\n]/;var n=/\n\r?\n$/;var f=/^\r?\n\r?\n/;function w(y,x){if(!y||!x){return 5}var z=0;if(y.charAt(y.length-1).match(j)||x.charAt(0).match(j)){z++;if(y.charAt(y.length-1).match(u)||x.charAt(0).match(u)){z++;if(y.charAt(y.length-1).match(i)||x.charAt(0).match(i)){z++;if(y.match(n)||x.match(f)){z++}}}}return z}var r=1;while(r<g.length-1){if(g[r-1][0]==a&&g[r+1][0]==a){var l=(g[r-1][1]);var p=(g[r][1]);var k=(g[r+1][1]);var v=this.diff_commonSuffix(l,p);if(v){var h=p.substring(p.length-v);l=l.substring(0,l.length-v);p=h+p.substring(0,p.length-v);k=h+k}var s=l;var o=p;var q=k;var m=w(l,p)+w(p,k);while(p.charAt(0)===k.charAt(0)){l+=p.charAt(0);p=p.substring(1)+k.charAt(0);k=k.substring(1);var t=w(l,p)+w(p,k);if(t>=m){m=t;s=l;o=p;q=k}}if(g[r-1][1]!=s){if(s){g[r-1][1]=s}else{g.splice(r-1,1);r--}g[r][1]=o;if(q){g[r+1][1]=q}else{g.splice(r+1,1);r--}}}r++}};e.prototype.diff_cleanupEfficiency=function(l){var n=false;var k=[];var h=0;var i="";var f=0;var m=false;var o=false;var g=false;var j=false;while(f<l.length){if(l[f][0]==a){if(l[f][1].length<this.Diff_EditCost&&(g||j)){k[h++]=f;m=g;o=j;i=l[f][1]}else{h=0;i=""}g=j=false}else{if(l[f][0]==d){j=true}else{g=true}if(i&&((m&&o&&g&&j)||((i.length<this.Diff_EditCost/2)&&(m+o+g+j)==3))){l.splice(k[h-1],0,[d,i]);l[k[h-1]+1][0]=b;h--;i="";if(m&&o){g=j=true;h=0}else{h--;f=h>0?k[h-1]:-1;g=j=false}n=true}}f++}if(n){this.diff_cleanupMerge(l)}};e.prototype.diff_cleanupMerge=function(m){m.push([a,""]);var l=0;var k=0;var j=0;var h="";var g="";var f;while(l<m.length){switch(m[l][0]){case b:j++;g+=m[l][1];l++;break;case d:k++;h+=m[l][1];l++;break;case a:if(k+j>1){if(k!==0&&j!==0){f=this.diff_commonPrefix(g,h);if(f!==0){if((l-k-j)>0&&m[l-k-j-1][0]==a){m[l-k-j-1][1]+=g.substring(0,f)}else{m.splice(0,0,[a,g.substring(0,f)]);l++}g=g.substring(f);h=h.substring(f)}f=this.diff_commonSuffix(g,h);if(f!==0){m[l][1]=g.substring(g.length-f)+m[l][1];g=g.substring(0,g.length-f);h=h.substring(0,h.length-f)}}if(k===0){m.splice(l-k-j,k+j,[b,g])}else{if(j===0){m.splice(l-k-j,k+j,[d,h])}else{m.splice(l-k-j,k+j,[d,h],[b,g])}}l=l-k-j+(k?1:0)+(j?1:0)+1}else{if(l!==0&&m[l-1][0]==a){m[l-1][1]+=m[l][1];m.splice(l,1)}else{l++}}j=0;k=0;h="";g="";break}}if(m[m.length-1][1]===""){m.pop()}var i=false;l=1;while(l<m.length-1){if(m[l-1][0]==a&&m[l+1][0]==a){if(m[l][1].substring(m[l][1].length-m[l-1][1].length)==m[l-1][1]){m[l][1]=m[l-1][1]+m[l][1].substring(0,m[l][1].length-m[l-1][1].length);m[l+1][1]=m[l-1][1]+m[l+1][1];m.splice(l-1,1);i=true}else{if(m[l][1].substring(0,m[l+1][1].length)==m[l+1][1]){m[l-1][1]+=m[l+1][1];m[l][1]=m[l][1].substring(m[l+1][1].length)+m[l+1][1];m.splice(l+1,1);i=true}}}l++}if(i){this.diff_cleanupMerge(m)}};e.prototype.diff_xIndex=function(l,k){var i=0;var g=0;var j=0;var h=0;var f;for(f=0;f<l.length;f++){if(l[f][0]!==b){i+=l[f][1].length}if(l[f][0]!==d){g+=l[f][1].length}if(i>k){break}j=i;h=g}if(l.length!=f&&l[f][0]===d){return h}return h+(k-j)};e.prototype.diff_prettyHtml=function(m){var k=[];var h=0;var o=/&/g;var j=/</g;var f=/>/g;var n=/\n/g;for(var p=0;p<m.length;p++){var l=m[p][0];var g=m[p][1];var q=g.replace(o,"&amp;").replace(j,"&lt;").replace(f,"&gt;").replace(n,'<span class="para">&para;</span><br>');switch(l){case b:k[p]="<ins>"+q+"</ins>";break;case d:k[p]="<del>"+q+"</del>";break;case a:k[p]="<span>"+q+"</span>";break}if(l!==d){h+=g.length}}return k.join("")};e.prototype.diff_text1=function(h){var g=[];for(var f=0;f<h.length;f++){if(h[f][0]!==b){g[f]=h[f][1]}}return g.join("")};e.prototype.diff_text2=function(h){var g=[];for(var f=0;f<h.length;f++){if(h[f][0]!==d){g[f]=h[f][1]}}return g.join("")};e.prototype.diff_levenshtein=function(k){var j=0;var g=0;var i=0;for(var f=0;f<k.length;f++){var l=k[f][0];var h=k[f][1];switch(l){case b:g+=h.length;break;case d:i+=h.length;break;case a:j+=Math.max(g,i);g=0;i=0;break}}j+=Math.max(g,i);return j};e.prototype.diff_toDelta=function(h){var g=[];for(var f=0;f<h.length;f++){switch(h[f][0]){case b:g[f]="+"+encodeURI(h[f][1]);break;case d:g[f]="-"+h[f][1].length;break;case a:g[f]="="+h[f][1].length;break}}return g.join("\t").replace(/%20/g," ")};e.prototype.diff_fromDelta=function(g,p){var k=[];var j=0;var f=0;var m=p.split(/\t/g);for(var o=0;o<m.length;o++){var i=m[o].substring(1);switch(m[o].charAt(0)){case"+":try{k[j++]=[b,decodeURI(i)]}catch(l){throw new Error("Illegal escape in diff_fromDelta: "+i)}break;case"-":case"=":var h=parseInt(i,10);if(isNaN(h)||h<0){throw new Error("Invalid number in diff_fromDelta: "+i)}var q=g.substring(f,f+=h);if(m[o].charAt(0)=="="){k[j++]=[a,q]}else{k[j++]=[d,q]}break;default:if(m[o]){throw new Error("Invalid diff operation in diff_fromDelta: "+m[o])}}}if(f!=g.length){throw new Error("Delta length ("+f+") does not equal source text length ("+g.length+").")}return k};e.prototype.match_main=function(h,f,g){if(h==null||f==null||g==null){throw new Error("Null input. (match_main)")}g=Math.max(0,Math.min(g,h.length));if(h==f){return 0}else{if(!h.length){return -1}else{if(h.substring(g,g+f.length)==f){return g}else{return this.match_bitap_(h,f,g)}}}};e.prototype.match_bitap_=function(p,x,n){if(x.length>this.Match_MaxBits){throw new Error("Pattern too long for this browser.")}var q=this.match_alphabet_(x);var f=this;function g(C,j){var B=C/x.length;var s=Math.abs(n-j);if(!f.Match_Distance){return s?1:B}return B+(s/f.Match_Distance)}var t=this.Match_Threshold;var h=p.indexOf(x,n);if(h!=-1){t=Math.min(g(0,h),t);h=p.lastIndexOf(x,n+x.length);if(h!=-1){t=Math.min(g(0,h),t)}}var z=1<<(x.length-1);h=-1;var k,o;var l=x.length+p.length;var m;for(var y=0;y<x.length;y++){k=0;o=l;while(k<o){if(g(y,n+o)<=t){k=o}else{l=o}o=Math.floor((l-k)/2+k)}l=o;var i=Math.max(1,n-o+1);var r=Math.min(n+o,p.length)+x.length;var u=Array(r+2);u[r+1]=(1<<y)-1;for(var v=r;v>=i;v--){var A=q[p.charAt(v-1)];if(y===0){u[v]=((u[v+1]<<1)|1)&A}else{u[v]=((u[v+1]<<1)|1)&A|(((m[v+1]|m[v])<<1)|1)|m[v+1]}if(u[v]&z){var w=g(y,v-1);if(w<=t){t=w;h=v-1;if(h>n){i=Math.max(1,2*n-h)}else{break}}}}if(g(y+1,n)>t){break}m=u}return h};e.prototype.match_alphabet_=function(h){var g={};for(var f=0;f<h.length;f++){g[h.charAt(f)]=0}for(var f=0;f<h.length;f++){g[h.charAt(f)]|=1<<(h.length-f-1)}return g};e.prototype.patch_addContext_=function(k,j){if(j.length==0){return}var g=j.substring(k.start2,k.start2+k.length1);var i=0;while(j.indexOf(g)!=j.lastIndexOf(g)&&g.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin){i+=this.Patch_Margin;g=j.substring(k.start2-i,k.start2+k.length1+i)}i+=this.Patch_Margin;var f=j.substring(k.start2-i,k.start2);if(f){k.diffs.unshift([a,f])}var h=j.substring(k.start2+k.length1,k.start2+k.length1+i);if(h){k.diffs.push([a,h])}k.start1-=f.length;k.start2-=f.length;k.length1+=f.length+h.length;k.length2+=f.length+h.length};e.prototype.patch_make=function(s,g,t){var h,o;if(typeof s=="string"&&typeof g=="string"&&typeof t=="undefined"){h=(s);o=this.diff_main(h,(g),true);if(o.length>2){this.diff_cleanupSemantic(o);this.diff_cleanupEfficiency(o)}}else{if(s&&typeof s=="object"&&typeof g=="undefined"&&typeof t=="undefined"){o=(s);h=this.diff_text1(o)}else{if(typeof s=="string"&&g&&typeof g=="object"&&typeof t=="undefined"){h=(s);o=(g)}else{if(typeof s=="string"&&typeof g=="string"&&t&&typeof t=="object"){h=(s);o=(t)}else{throw new Error("Unknown call format to patch_make.")}}}}if(o.length===0){return[]}var f=[];var i=new c();var l=0;var n=0;var m=0;var k=h;var q=h;for(var r=0;r<o.length;r++){var j=o[r][0];var p=o[r][1];if(!l&&j!==a){i.start1=n;i.start2=m}switch(j){case b:i.diffs[l++]=o[r];i.length2+=p.length;q=q.substring(0,m)+p+q.substring(m);break;case d:i.length1+=p.length;i.diffs[l++]=o[r];q=q.substring(0,m)+q.substring(m+p.length);break;case a:if(p.length<=2*this.Patch_Margin&&l&&o.length!=r+1){i.diffs[l++]=o[r];i.length1+=p.length;i.length2+=p.length}else{if(p.length>=2*this.Patch_Margin){if(l){this.patch_addContext_(i,k);f.push(i);i=new c();l=0;k=q;n=m}}}break}if(j!==b){n+=p.length}if(j!==d){m+=p.length}}if(l){this.patch_addContext_(i,k);f.push(i)}return f};e.prototype.patch_deepCopy=function(h){var i=[];for(var g=0;g<h.length;g++){var k=h[g];var f=new c();f.diffs=[];for(var j=0;j<k.diffs.length;j++){f.diffs[j]=k.diffs[j].slice()}f.start1=k.start1;f.start2=k.start2;f.length1=k.length1;f.length2=k.length2;i[g]=f}return i};e.prototype.patch_apply=function(f,u){if(f.length==0){return[u,[]]}f=this.patch_deepCopy(f);var h=this.patch_addPadding(f);u=h+u+h;this.patch_splitMax(f);var t=0;var l=[];for(var s=0;s<f.length;s++){var g=f[s].start2+t;var j=this.diff_text1(f[s].diffs);var k;var p=-1;if(j.length>this.Match_MaxBits){k=this.match_main(u,j.substring(0,this.Match_MaxBits),g);if(k!=-1){p=this.match_main(u,j.substring(j.length-this.Match_MaxBits),g+j.length-this.Match_MaxBits);if(p==-1||k>=p){k=-1}}}else{k=this.match_main(u,j,g)}if(k==-1){l[s]=false;t-=f[s].length2-f[s].length1}else{l[s]=true;t=k-g;var i;if(p==-1){i=u.substring(k,k+j.length)}else{i=u.substring(k,p+this.Match_MaxBits)}if(j==i){u=u.substring(0,k)+this.diff_text2(f[s].diffs)+u.substring(k+j.length)}else{var n=this.diff_main(j,i,false);if(j.length>this.Match_MaxBits&&this.diff_levenshtein(n)/j.length>this.Patch_DeleteThreshold){l[s]=false}else{this.diff_cleanupSemanticLossless(n);var o=0;var m;for(var r=0;r<f[s].diffs.length;r++){var q=f[s].diffs[r];if(q[0]!==a){m=this.diff_xIndex(n,o)}if(q[0]===b){u=u.substring(0,k+m)+q[1]+u.substring(k+m)}else{if(q[0]===d){u=u.substring(0,k+m)+u.substring(k+this.diff_xIndex(n,o+q[1].length))}}if(q[0]!==d){o+=q[1].length}}}}}}u=u.substring(h.length,u.length-h.length);return[u,l]};e.prototype.patch_addPadding=function(i){var h=this.Patch_Margin;var g="";for(var f=1;f<=h;f++){g+=String.fromCharCode(f)}for(var f=0;f<i.length;f++){i[f].start1+=h;i[f].start2+=h}var l=i[0];var k=l.diffs;if(k.length==0||k[0][0]!=a){k.unshift([a,g]);l.start1-=h;l.start2-=h;l.length1+=h;l.length2+=h}else{if(h>k[0][1].length){var j=h-k[0][1].length;k[0][1]=g.substring(k[0][1].length)+k[0][1];l.start1-=j;l.start2-=j;l.length1+=j;l.length2+=j}}l=i[i.length-1];k=l.diffs;if(k.length==0||k[k.length-1][0]!=a){k.push([a,g]);l.length1+=h;l.length2+=h}else{if(h>k[k.length-1][1].length){var j=h-k[k.length-1][1].length;k[k.length-1][1]+=g.substring(0,j);l.length1+=j;l.length2+=j}}return g};e.prototype.patch_splitMax=function(f){var n=this.Match_MaxBits;for(var q=0;q<f.length;q++){if(f[q].length1>n){var k=f[q];f.splice(q--,1);var h=k.start1;var g=k.start2;var l="";while(k.diffs.length!==0){var j=new c();var o=true;j.start1=h-l.length;j.start2=g-l.length;if(l!==""){j.length1=j.length2=l.length;j.diffs.push([a,l])}while(k.diffs.length!==0&&j.length1<n-this.Patch_Margin){var m=k.diffs[0][0];var p=k.diffs[0][1];if(m===b){j.length2+=p.length;g+=p.length;j.diffs.push(k.diffs.shift());o=false}else{if(m===d&&j.diffs.length==1&&j.diffs[0][0]==a&&p.length>2*n){j.length1+=p.length;h+=p.length;o=false;j.diffs.push([m,p]);k.diffs.shift()}else{p=p.substring(0,n-j.length1-this.Patch_Margin);j.length1+=p.length;h+=p.length;if(m===a){j.length2+=p.length;g+=p.length}else{o=false}j.diffs.push([m,p]);if(p==k.diffs[0][1]){k.diffs.shift()}else{k.diffs[0][1]=k.diffs[0][1].substring(p.length)}}}}l=this.diff_text2(j.diffs);l=l.substring(l.length-this.Patch_Margin);var i=this.diff_text1(k.diffs).substring(0,this.Patch_Margin);if(i!==""){j.length1+=i.length;j.length2+=i.length;if(j.diffs.length!==0&&j.diffs[j.diffs.length-1][0]===a){j.diffs[j.diffs.length-1][1]+=i}else{j.diffs.push([a,i])}}if(!o){f.splice(++q,0,j)}}}}};e.prototype.patch_toText=function(g){var h=[];for(var f=0;f<g.length;f++){h[f]=g[f]}return h.join("")};e.prototype.patch_fromText=function(l){var f=[];if(!l){return f}var n=l.split("\n");var p=0;var g=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;while(p<n.length){var j=n[p].match(g);if(!j){throw new Error("Invalid patch string: "+n[p])}var h=new c();f.push(h);h.start1=parseInt(j[1],10);if(j[2]===""){h.start1--;h.length1=1}else{if(j[2]=="0"){h.length1=0}else{h.start1--;h.length1=parseInt(j[2],10)}}h.start2=parseInt(j[3],10);if(j[4]===""){h.start2--;h.length2=1}else{if(j[4]=="0"){h.length2=0}else{h.start2--;h.length2=parseInt(j[4],10)}}p++;while(p<n.length){var i=n[p].charAt(0);try{var o=decodeURI(n[p].substring(1))}catch(k){throw new Error("Illegal escape in patch_fromText: "+o)}if(i=="-"){h.diffs.push([d,o])}else{if(i=="+"){h.diffs.push([b,o])}else{if(i==" "){h.diffs.push([a,o])}else{if(i=="@"){break}else{if(i===""){}else{throw new Error('Invalid patch mode "'+i+'" in: '+o)}}}}}p++}}return f};function c(){this.diffs=[];this.start1=null;this.start2=null;this.length1=0;this.length2=0}c.prototype.toString=function(){var g,j;if(this.length1===0){g=this.start1+",0"}else{if(this.length1==1){g=this.start1+1}else{g=(this.start1+1)+","+this.length1}}if(this.length2===0){j=this.start2+",0"}else{if(this.length2==1){j=this.start2+1}else{j=(this.start2+1)+","+this.length2}}var h=["@@ -"+g+" +"+j+" @@\n"];var i;for(var f=0;f<this.diffs.length;f++){switch(this.diffs[f][0]){case b:i="+";break;case d:i="-";break;case a:i=" ";break}h[f+1]=i+encodeURI(this.diffs[f][1])+"\n"}return h.join("").replace(/%20/g," ")};return e}());
38
- if(!window.console){window.console={log:function(){},warn:function(){},error:function(){},}}else{}function $A(c){if(!c){return[]}if(c.toArray){return c.toArray()}var b=c.length||0,a=new Array(b);while(b--){a[b]=c[b]}return a}(function(b){var c=0;if(!(typeof Function.prototype.bind==="function")){Function.prototype.bind=function(){var e=this,g=$A(arguments),f=g.shift();return function(){return e.apply(f,g.concat($A(arguments)))}}}b.extend(Function.prototype,{cache:function(g){var f=this,h=g||("__cached__"+(++c)),e;return function(){if(this[h]===e){this[h]=f.apply(this,arguments)||null}return this[h]}}});b.extend(Number.prototype,{to_filesize:function(){var e=1000,f=[" bytes"," KB"," MB"," GB"],g=Math.floor(Math.log(this)/Math.log(e));return this/(Math.pow(e,g))+f[g]}});var a=200,d=200;b.fn.appear=function(h){var f=this,g=f.siblings(),e=function(){f.animate({opacity:1},{duration:a,complete:h})};if(g.length==0){f.css({opacity:0}).show();e()}else{f.hide().css({opacity:0}).animate({height:"show"},{duration:d,complete:e})}};b.fn.appear.height_change_duration=d;b.fn.disappear=function(f){var e=this;this.animate({opacity:0},{duration:a,complete:function(){e.animate({height:"hide"},{duration:d,complete:f})}})}}(jQuery));
39
- Spontaneous.page=function(){return Spontaneous.Editing.get("page")};
40
- Spontaneous.Properties=(function(c,b){var a=new JS.Module({_props_debug:false,_props_properties:function(){if(!this._props_property_store){this._props_property_store={}}return this._props_property_store},_props_listeners:function(){if(!this._props_listener_store){this._props_listener_store={}}return this._props_listener_store},_props_notify_changed:function(j){for(var g=0,d=j.length;g<d;g++){var f=j[g],k=this._props_properties()[f];var h=this._props_listeners_for(f);for(var e=0,m=h.length;e<m;e++){var l=h[e].callback;l(k)}}},_props_set_individual:function(d,e){if(this._props_set_individual_wo_callbacks(d,e)){this._props_notify_changed([d])}},_props_set_individual_wo_callbacks:function(d,e){if(this._props_debug){console.log("setting ",d,e)}orig_value=this._props_properties()[d];this._props_properties()[d]=e;var f=(e!==orig_value);return f},_props_set_multiple:function(e){var f=[],d;for(d in e){if(e.hasOwnProperty(d)){if(this._props_set_individual_wo_callbacks(d,e[d])){f.push(d)}}}this._props_notify_changed(f)},_props_listeners_for:function(d){return this._props_listeners()[d]||[]},_props_add_listener:function(e,f){var d=this._props_listeners()[e]||[];d.push({callback:f});this._props_listeners()[e]=d},get:function(d){return this._props_properties()[d]},set:function(){if(arguments.length===1&&typeof arguments[0]==="object"){this._props_set_multiple(arguments[0])}else{if(arguments.length===2){this._props_set_individual(arguments[0],arguments[1])}}},watch:function(d,e){return this._props_add_listener(d,e)},bind:function(d,e){return this._props_add_listener(d,e)},trigger:function(){var d=Array.prototype.slice.call(arguments);var h=d.shift(),g=this._props_listeners_for(h);for(var e=0,f=g.length;e<f;e++){g[e].callback.apply(null,d)}}});return a}(jQuery,Spontaneous));
41
- Spontaneous.Dom=(function(g,d){var b="div p iframe a span img select option label ul li dl dt dd table tr td h1 h2 h3 h4 header input button form textarea".split(" ");var f={body:function(){return g(document.body)},id:function(h){return"#"+h},px:function(h){return h+"px"},cmd_key_label:function(j,h){var i=((window.navigator.platform.indexOf("Mac")===0)?"Cmd":"Ctrl");return this.key_label(j,i+"+"+h)},key_label:function(j,h){var i='<span class="key-combo">('+h+")</span>";return j+" "+i},parse_selector:function(n){var k,j="",m=[],s={};n=n||"";if(typeof n==="string"){k=n.split(".")}else{if(g.isArray(n)){k=n}}for(var o=0,q=k.length;o<q;o++){var l=k[o];if(l===""){}else{if(l.indexOf("#")===0){j=l.substr(1)}else{if(l.indexOf(".")===0){var h=this.parse_selector(l);m.push(h["class"])}else{m.push(l)}}}}if(j!==""){s.id=j}if(m.length>0){s["class"]=m.join(" ")}return s}};var a=function(i){var h="<"+i+"/>";return function(j,l){if(typeof j==="object"){if(!g.isArray(j)){l=j;j=""}}var k=g.extend((l||{}),f.parse_selector(j));return g(h,k)}};for(var c=0,e=b.length;c<e;c++){f[b[c]]=a(b[c])}return f})(jQuery,Spontaneous);
42
- Spontaneous.Auth=(function(b,a){return{Key:{key:function(c){return c+"_api_key"},save:function(c,d){localStorage.setItem(this.key(c),d)},load:function(c){return localStorage.getItem(this.key(c))||this.loadAutoLogin()},loadAutoLogin:function(){if(!this._autoLoginKey){console.warn("Using auto login key for user","'"+a.auto_login+"'");this._autoLoginKey=a.user_key}return this._autoLoginKey},remove:function(c){localStorage.removeItem(this.key(c));return false}}}}(jQuery,Spontaneous));
43
- Spontaneous.User=(function(c,b){var d=new JS.Class({initialize:function(e){this.attrs=e},name:function(){return this.attrs.name},email:function(){return this.attrs.email},login:function(){return this.attrs.login},is_developer:function(){return this.attrs.developer}});var a=new JS.Singleton({include:Spontaneous.Properties,load:function(){b.Ajax.get("/user",this.loaded.bind(this))},loaded:function(e){this.user=new d(e);this.set("user",this.user)},name:function(){return this.user.name()},email:function(){return this.user.email()},login:function(){return this.user.login()},is_developer:function(){return this.user.is_developer()}});return a}(jQuery,Spontaneous));
44
- Spontaneous.Popover=(function(d,b){var e=b.Dom;var a=0;var c=new JS.Class({initialize:function(f){this.id=(++a);this.view=f;this.view.set_manager(this);this.depth=0},open:function(g){var q=this.view;var t=c.div();var f=e.div(".pop-over");var n=e.div(".menuHandle");var m=e.header();var s=e.h3().text(q.title());var u=e.div().css("width",q.width());u.append(q.view());if(q.has_navigation){var j=e.a(".button.back").append(e.span(".pointer")).append(e.span(".label").text("Back")).css("visibility","hidden");m.append(j)}m.append(s);if(q.close_text()){var l=e.a(".button.close").text(q.close_text()).click(this.close.bind(this));m.append(l)}f.append(n).append(m).append(u);var h=q.position_from_event(g),r=30,k=10,i=-30,p=18;if(q.align==="right"){n.css("left",(q.width()-(k+r))+"px");i=-(q.width()-(k+r/2)+8)}p-=31-c.div().scrollTop();f.offset({top:(h.top+p),left:(h.left+i)});f.hide();t.append(f);this.wrapper=f;this.is_open=true;f.fadeIn(200,this.after_open.bind(this))},after_open:function(){this.view.after_open()},close:function(){c.close();return false},do_close:function(){var f=this.view;f.before_close();f.do_close();f.after_close();this.is_open=false;this.wrapper.fadeOut(100,function(){d(this).remove()})}});c.extend({_instance:false,div:function(){if(!this._div){this._div=d("#content")}return this._div},open:function(g,f){this.close();this._instance=new c(f);this._instance.open(g);return this._instance},close:function(){if(this._instance){this._instance.do_close();this._instance=null}}});d(document).bind("keydown.popover",function(f){if(f.keyCode===27){c.close()}});return c})(jQuery,Spontaneous);
45
- Spontaneous.PopoverView=(function(b,a){var c=a.Dom;var d=new JS.Class({initialize:function(){},set_manager:function(e){this.manager=e},view:function(){},align:"left",has_navigation:true,title:function(){return"Popover"},width:function(){return 400},position_from_event:function(e){return this.position_from_element(e)},position_from_element:function(f){var e=b(f.currentTarget),g=e.offset();g.top+=e.outerHeight();g.left+=e.outerWidth()/2;return g},position_from_mouse:function(e){return{top:e.clientX,left:e.clientY}},after_open:function(){},close_text:function(){return"Close"},close:function(){this.manager.close()},before_close:function(){},do_close:function(){},after_close:function(){}});return d})(jQuery,Spontaneous);
46
- Spontaneous.Ajax=(function(b,a){b.ajaxSetup({async:true,cache:false,dataType:"json",ifModified:true});return{namespace:"/@spontaneous",get:function(d,e){var c=function(f,h,g){if(h!=="success"){g=f;f={}}e(f,h,g)};b.ajax({url:this.request_url(d),success:c,data:this.api_access_key(),error:c})},post:function(d,f,g){var e=function(i,j,h){g(i,j,h)};var c=function(h,l,k){var i=false;try{i=b.parseJSON(h.responseText)}catch(j){}g(i,l,h)};f=b.extend(f,this.api_access_key());b.ajax({url:this.request_url(d,true),type:"post",data:f,success:e,error:c})},test_field_versions:function(f,e,l,c){var h={},k=0;for(var d=0,m=e.length;d<m;d++){var g=e[d],j="[fields]["+g.schema_id()+"]";if(g.is_modified()){h[j]=g.version();k++}}if(k===0){l()}this.post(["/version",f.id()].join("/"),h,function(p,o,x){if(o==="success"){l()}else{if(x.status===409){var u={};for(var q=0,w=e.length;q<w;q++){var r=e[q];u[r.schema_id()]=r}var t=[];for(var n in p){if(p.hasOwnProperty(n)){var v=p[n],s=u[n];t.push({field:s,version:v[0],values:{server_original:v[1],local_edited:s.edited_value(),local_original:s.original_value()}})}}c(t)}}})},api_access_key:function(){return{__key:Spontaneous.Auth.Key.load(a.site_id)}},request_url:function(c,e){var d=this.namespace+c;if(e){d+="?"+b.param(this.api_access_key())}return d}}}(jQuery,Spontaneous));
47
- Spontaneous.EventSource=(function(b,a){var c=new JS.Singleton({eventSource:function(){if(!this._eventSource){this._eventSource=new window.EventSource(a.Ajax.request_url("/events",true))}return this._eventSource},addEventListener:function(d,e){this.eventSource().addEventListener(d,e)}});return c})(jQuery,Spontaneous);
48
- Spontaneous.Types=(function(f,c){var e=c.Ajax,a={};var d=new JS.Class({initialize:function(m){this.data=m;this.title=m.title;var h=this.data.fields;this.field_prototypes={};this.field_names=[];for(var j=0,k=h.length;j<k;j++){var l=h[j];this.field_names.push(l.name);this.field_prototypes[l.name]=l}},allowed_types:function(){var j=[];if(this.data.allowed_types.length>0){for(var h=0,k=this.data.allowed_types.length;h<k;h++){j.push(Spontaneous.Types.type(this.data.allowed_types[h]))}}return j}});var b=new JS.Class({initialize:function(o){this.data=o;this.schema_id=o.id;this.type=o.type;this.title=o.title;this.title_field_name=o.title_field;this.field_prototypes={};this.field_names=[];this.box_prototypes={};this.box_ids=[];var j=this.data.fields,l=this.data.boxes;for(var k=0,m=j.length;k<m;k++){var n=j[k];this.field_names.push(n.name);this.field_prototypes[n.name]=n}for(var k=0,m=l.length;k<m;k++){var h=l[k];this.box_ids.push(h.id);this.box_prototypes[h.id]=new d(h)}},box_prototype:function(h){return this.box_prototypes[h]},allowed_types:function(){var j=[];if(this.data.allowed_types.length>0){for(var h=0,k=this.data.allowed_types.length;h<k;h++){j.push(Spontaneous.Types.type(this.data.allowed_types[h]))}}return j},is_page:function(){return this.data.is_page},is_alias:function(){return this.data.is_alias},edit_url:function(){return c.editor_protocol+"://open?url=file://"+this.data.source}});var g=new JS.Singleton({include:Spontaneous.Properties,init:function(i){var h=(function(j){return function(l){var k={};for(id in l){if(l.hasOwnProperty(id)){k[id]=new b(l[id])}}Spontaneous.Types.set("types",k);if(j){j.call(a)}}})(i);e.get("/types",h)},type:function(h){return this.get("types")[h]},box_prototype:function(){}});return g}(jQuery,Spontaneous));
49
- Spontaneous.Image=(function(c,b){var d=Spontaneous.Dom;var a=new JS.Class({initialize:function(e){this.field=e},fit:function(f,e){if(this.is_empty()){return d.span()}var g=this.fit_dimensions(f,e);return d.img({src:this.src()}).attr("width",g.width).attr("height",g.height)},fit_dimensions:function(g,e){var f=1;if(this.is_landscape()){if(this.width()>g){f=g/this.width()}}else{if(this.height()>e){f=e/this.height()}}return{width:(this.width()*f),height:(this.height()*f)}},fit_dimensions_inverse:function(g,e){var f=1;if(this.is_portrait()){if(this.width()>g){f=g/this.width()}}else{if(this.height()>e){f=e/this.height()}}return{width:(this.width()*f),height:(this.height()*f)}},icon:function(g,e){if(this.is_empty()){return d.span()}var h=this.fit_dimensions_inverse(g,e),f=d.div(".icon-wrap",{width:d.px(g),height:d.px(e)});f.append(d.img({src:this.src()}).css({left:d.px((g-h.width)/2),top:d.px((e-h.height)/2)}).attr("width",h.width).attr("height",h.height));return f},src:function(){return this.field.attributes.original.src},width:function(){if(this.is_empty()){return 0}return this.field.attributes.original.width},height:function(){if(this.is_empty()){return 0}return this.field.attributes.original.height},is_landscape:function(){return this.width()>=this.height()},is_portrait:function(){return this.height()>this.width()},is_empty:function(){return !this.field.attributes.original}});return a}());
50
- Spontaneous.Content=(function(c,b){var d=b.Dom;var a=new JS.Class({include:Spontaneous.Properties,initialize:function(e){this.content=e},uid:function(){return(this.container?this.container.uid():"")+"/"+this.content.id},id:function(){return this.content.id},is_page:function(){return this.type().is_page()},target:function(){return this.content.target},developer_description:function(){return this.type().type+"["+this.id()+"]"},developer_edit_url:function(){return this.type().edit_url()},type:function(){return b.Types.type(this.content.type)}.cache(),slug:function(){return this.content.slug},constantize:function(g){var j=g.split(/\./),h=window;for(var e=0,f=j.length;e<f;e++){h=h[j[e]]}return h},unload:function(){c.each(this.field_list(),function(e,g){g.unload()});c.each(this.entries(),function(f,g){g.unload()})},has_fields:function(){return this.field_list().length>0},field_list:function(){var h=this.type(),l=h.field_prototypes,k=h.field_names;var e=this.fields(),j=[];for(var f=0,g=k.length;f<g;f++){j.push(e[k[f]])}return j}.cache(),text_fields:function(){var e=[],g=this.field_list();for(var h=0,j=g.length;h<j;h++){var k=g[h];if(!k.is_image()){e.push(k)}}return e},image_fields:function(){var e=[],g=this.field_list();for(var h=0,j=g.length;h<j;h++){var k=g[h];if(k.is_image()){e.push(k)}}return e},file_fields:function(){var e=[],g=this.field_list();for(var h=0,j=g.length;h<j;h++){var k=g[h];if(k.is_file()){e.push(k)}}return e},fields:function(){var h={},k=this.type(),o=k.field_prototypes;for(var g=0,n=this.content.fields.length;g<n;g++){var j=this.content.fields[g],m=o[j.name],e=this.constantize(m.type);if(!e){console.warn("Content#fields:","Field has invalid type",m.type,"content_id:",this.content.id,"type:","'"+k.title+"'","field_name:",j.name);e=Spontaneous.FieldTypes.StringField}var l=new e(this,j);h[j.name]=l}return h}.cache(),field:function(e){return this.fields()[e]},field_updated:function(f,e){this.save_field(f)},save_field:function(e){var f={field:{}};f.field[e.name]={value:e.value()};Spontaneous.Ajax.post(this.save_path(),f,this.save_complete.bind(this))},save_path:function(){return["/save",this.content.id].join("/")},save_complete:function(g){if(g){var e=g.fields;for(var h=0,j=e.length;h<j;h++){var f=e[h],k=this.field(f.name);k.update(f)}}},has_fields:function(){return(this.content.fields.length>0)},title:function(){return this.title_field().value()},title_field:function(){return this.fields()[this.type().title_field_name]},hidden:function(){return this.content.hidden},entries:function(){if(!this.content.entries){return[]}var j=[];for(var f=0,e=this.content.entries,g=e.length;f<g;f++){var h=this.wrap_entry(e[f]);j.push(h)}return j}.cache(),boxes:function(){var h=[];if(this.content.boxes){for(var f=0,e=this.content.boxes,g=e.length;f<g;f++){h.push(new b.Box(e[f],this))}}return h}.cache(),has_boxes:function(){return(this.boxes().length>0)},wrap_entry:function(e){var f=Spontaneous.Entry;if(e.is_page){f=Spontaneous.PageEntry}return new f(e,this)},allowed_types:function(){return this.type().allowed_types()},depth:function(){return this.content.depth},destroy:function(){Spontaneous.Ajax.post(["/destroy",this.content.id].join("/"),{},this.destroyed.bind(this))},toggle_visibility:function(){Spontaneous.Ajax.post(["/toggle",this.content.id].join("/"),{},this.visibility_toggled.bind(this))},visibility_toggled:function(e){console.log("visibility_toggled",e);this.set("hidden",e.hidden)},destroyed:function(){var e=b.Editing.get("page");this.trigger("destroyed",this);e.trigger("removed_entry",this)},reposition:function(e){Spontaneous.Ajax.post(["/content",this.content.id,"position",e].join("/"),{},function(){this.repositioned()}.bind(this))},repositioned:function(){this.trigger("repositioned")}});return a}(jQuery,Spontaneous));
51
- Spontaneous.Views=(function(b,a){var d=a.Dom;var c=new JS.Class({include:Spontaneous.Properties,initialize:function(e){this.content=e},id:function(){return this.content.id()},uid:function(){return this.content.uid()},depth_class:function(){return"depth-"+this.content.depth()},depth:function(){return this.content.depth()},visibility_class:function(){return this.content.hidden()?"hidden":"visible"},boxes_class:function(){return this.content.has_boxes()?"boxes":"no-boxes"},has_fields:function(){return this.content.field_list().length>0},field_list:function(){return this.content.field_list()},image_fields:function(){return this.content.image_fields()},text_fields:function(){return this.content.text_fields()},file_fields:function(){return this.content.file_fields()},mouseover:function(e){},mouseout:function(e){},save_path:function(){return this.content.save_path()},create_edit_wrapper:function(i){var h={style:"position: relative; overflow: hidden;"};var f=d.div(h);var g=d.div({style:"position: absolute; height: 0; overflow: hidden;"});var j=d.div();var k=d.div(h);var e=d.div();g.append(j);e.append(i);k.append(e);f.append(g).append(k);this.editing_area={outer:f,write:g,write_inner:j,read:k,read_inner:e};return f},edit:function(t){var q=300,k=10,j=20,p=this.editing_area,i=p.outer,s=p.write,g=p.read,f=p.write_inner,n=p.read_inner;var e=new Spontaneous.EditPanel(this),m=e.view();g.css("z-index",j);s.css("z-index",k).css("height","auto").show();f.append(m);var l=f.outerHeight();i.add(g).animate({height:l},{queue:false,duration:q});s.css({position:"relative"});g.css({position:"absolute",top:0,right:0,left:0}).animate({top:l},{queue:false,duration:q,complete:function(){s.css({"z-index":j,position:"relative",height:"auto"});g.css({"z-index":k,position:"absolute",display:"none"});i.css("height","auto");e.on_show(t)}})},edit_closing:false,edit_closed:function(){if(this.edit_closing){return}this.edit_closing=true;var p=300,j=10,i=20,n=this.editing_area,g=n.outer,q=n.write,e=n.read.css("display","block"),f=n.write_inner,m=n.read_inner,l=this,k=m.outerHeight();g.add(e).animate({height:k},{queue:false,duration:p});e.css({"z-index":i,height:k,top:f.outerHeight()+"px"}).animate({top:0},{queue:true,duration:p,complete:function(){q.css({position:"absolute","z-index":j});e.css({position:"relative",height:"auto","z-index":i});g.css("height","auto");f.empty();l.edit_closing=false}})},save_complete:function(e){this.content.save_complete(e)}});return{View:c}}(jQuery,Spontaneous));
52
- Spontaneous.Views.BoxView=(function(c,b){var d=b.Dom;var a=new JS.Class(Spontaneous.Views.View,{include:Spontaneous.Properties,initialize:function(e,f){this.callSuper(e);this.box=e;this.dom_container=f;this.box.bind("entry_added",this.insert_entry.bind(this));this.box.bind("entry_removed",this.remove_entry.bind(this))},name:function(){return this.box.name()},schema_id:function(){return this.box.schema_id()},activate:function(){c("> .slot-content",this.dom_container).hide();this.panel().show()},mouseover:function(){if(this.fields_preview){this.fields_preview.addClass("hover")}},mouseout:function(){if(this.fields_preview){this.fields_preview.removeClass("hover")}},panel:function(){if(!this._panel){var e=d.div(".slot-content");e.addClass("empty");if(this.box.has_fields()){var o=d.div(".box-fields");var l=new Spontaneous.FieldPreview(this,"");var m=l.panel();m.prepend(d.div(".overlay"));var f=this.create_edit_wrapper(m);o.append(f);e.append(o);this.fields_preview=m}e.append(this.add_allowed_types_bar("top",0));var k=d.div(".slot-entries");var g=d.div(".slot-instructions").text("Add items using the buttons above");k.append(g);for(var h=0,j=this.entries(),p=j.length;h<p;h++){var n=j[h];k.append(this.claim_entry(n))}k.sortable({items:"> ."+this.entry_class(),axis:"y",distance:5,tolerance:"pointer",scrollSpeed:40,containment:"parent",cursor:"move",stop:function(i,q){this.re_sort(q.item)}.bind(this)});e.append(k);e.hide();this.dom_container.append(e);this._panel=e;this._entry_container=k}this.check_if_empty();return this._panel},check_if_empty:function(){var f=this,e=this._panel;if(f.box.entries().length==0){e.addClass("empty")}else{e.removeClass("empty")}},add_allowed_types_bar:function(h,k){var m=this.box.allowed_types(),l=this,g=d.div(".slot-addable"),i=g,e=function(p){i.removeClass("drop-active").addClass("uploading");p.stopPropagation();p.preventDefault();var o=p.dataTransfer.files;if(o.length>0){b.UploadManager.wrap(this,o,k)}return false}.bind(this),j=function(o){c(this).addClass("drop-active");o.stopPropagation();o.preventDefault();return false}.bind(i),f=function(o){o.stopPropagation();o.preventDefault();return false}.bind(i),n=function(o){c(this).removeClass("drop-active");o.stopPropagation();o.preventDefault();return false}.bind(i);g.addClass(h);i.get(0).addEventListener("drop",e,true);i.bind("dragenter",j).bind("dragover",f).bind("dragleave",n);c.each(m,function(q,r){var o=d.a().text(r.title),p;if(r.is_alias()){o.addClass("alias");p=function(s){var t=new Spontaneous.AddAliasDialogue(l,s,k);t.open()}.bind(l,r)}else{p=function(s){this.add_content(s,k)}.bind(l,r)}o.click(p);g.append(o)});g.append(d.span(".down"));return g},re_sort:function(o){var k=this.entries(),g=this._entry_container.sortable("toArray"),f=o.attr("id"),h=0;for(var j=0,n=g.length;j<n;j++){if(g[j]===f){h=j;break}}var e=f.split("-")[1],m,l=0;for(var j=0,n=k.length;j<n;j++){if(k[j].id()==e){l=j;m=k[j];break}}k.splice(l,1);k.splice(h,0,m);m.reposition(h,function(i){this.sorted(i)}.bind(this))},sorted:function(e){},upload_complete:function(e){this.box.entry_added(e)},upload_progress:function(e,f){},entries:function(){var e=[];for(var g=0,f=this.box.entries(),h=f.length;g<h;g++){var j=f[g];e.push(this.view_for_entry(j))}return e}.cache(),view_for_entry:function(h){var g=b.Views.PieceView,f,e;if(h.is_page()){g=b.Views.PagePieceView}f=new g(h,this);return f},claim_entry:function(e){var f=e.panel();e.bind("removed",this.entry_removed.bind(this));return f.attr("id",this.entry_id(e)).addClass(this.entry_class())},entry_id:function(e){return"entry-"+e.content.id()},entry_class:function(){return"container-"+this.box.schema_id()},save_path:function(){return["/savebox",this.id()].join("/")},add_content:function(f,e){this.box.add_entry(f,e)},add_alias:function(f,g,e){this.box.add_alias(f,g,e)},insert_entry:function(l,g){this.trigger("entry_added",l,g);var f=this.entries(),j=this.entry_wrappers(),m=this.view_for_entry(l),k=this.claim_entry(m),i=this;if(g===-1){f.push(m)}else{f.splice(g,0,m)}if(g===-1||j.length===0){this._entry_container.append(k)}else{if(g===0){this._entry_container.prepend(k)}else{this.entry_wrappers().slice(g-1,g).after(k)}}if(g===-1){b.ContentArea.scroll_to_bottom(c.fn.appear.height_change_duration)}i.check_if_empty();k.hide().appear(function(){if(m.content.has_fields()){m.edit()}})},remove_entry:function(e){},entry_removed:function(h){var e=this.entries();for(var f=0,g=e.length;f<g;f++){if(e[f]===h){e.splice(f,1)}}this.check_if_empty()},entry_wrappers:function(){return this._entry_container.find("> ."+this.entry_class())},show_add_after:function(l,g){var k,f=0;for(var h=0,e=this.entries(),j=e.length;h<j;h++){if(e[h]===l){f=h;break}}k=this.add_allowed_types_bar("floating",f+1);g.addClass("add-entry").append(k.show())},hide_add_after:function(f,e){e.empty();e.removeClass("add-entry")}});return a})(jQuery,Spontaneous);
53
- Spontaneous.Views.PageView=(function(c,b){var e=b.Dom,a=b.User;var d=function(g){this.page=g};d.prototype={panel:function(){this.panel=e.div("#page-info");this.title=c("<h1/>");this.set_title();this.panel.append(this.title);var g=e.div(".path");this.page.title_field().watch("value",function(k){this.set_title(k)}.bind(this));var j=e.h3(".path").text(this.page.get("path")).click(function(){if(this.page.get("path")!=="/"){this.open_url_editor()}}.bind(this));g.append(j);if(a.is_developer()){var i=e.h3(".developer.uid"+(!this.page.content.uid?".missing":"")).text("#"+(this.page.content.uid||"----")).click(function(){this.open_uid_editor()}.bind(this));var h=e.h3(".developer").append(e.a().attr("href",this.page.developer_edit_url()).text(this.page.developer_description()));g.append(i,h)}g.append(e.div(".edit"));this.page.watch("path",function(k){j.text(k)}.bind(this));this.panel.append(g);this.path_wrap=g;return this.panel},set_title:function(g){g=g||this.page.title();this.title.html(g);if(this.page.content.hidden){this.title.append(e.span().text(" (hidden)"))}},unavailable_loaded:function(g){var h={};for(var j=0,k=g.length;j<k;j++){h[g[j]]=true}this.unavailable=h},open_uid_editor:function(){this.panel.animate({height:"+=14"},200,function(){var g=c("h3",this.panel),k=c(".edit",this.panel);g.hide();k.hide().empty();var i=e.input({type:"text",autofocus:"autofocus"}).val(this.page.content.uid).select();var h=e.div(".input-error.uid-input");var m=e.div(".hash").text("#");var j=e.label().text("UID");var l=function(){this.save_uid(i.val())}.bind(this);h.append(m,i);k.append(j,h);k.append(e.a(".button.save").text("Save").click(l));k.append(e.a(".button.cancel").text("Cancel").click(this.close.bind(this)));i.bind("keydown.uideditor",function(p){var o=83,n=27;if((p.ctrlKey||p.metaKey)&&p.keyCode===o){l();return false}}.bind(this));i.keyup(function(o){if(o.keyCode===13){l()}else{var n=i.val();n=n.toLowerCase().replace(/['"]/g,"");n=n.replace(/[^a-z0-9_]/g,"_").replace(/(\_+|\s+)/g,"_").replace(/(^\-)/,"");i.val(n)}}.bind(this)).keydown(function(n){if(n.keyCode===27){this.close()}}.bind(this));k.fadeIn(200)}.bind(this))},save_uid:function(g){Spontaneous.Ajax.post("/uid/"+this.page.id(),{uid:g},this.uid_save_complete.bind(this))},uid_save_complete:function(i,h,l){if(h==="success"){var g=c("h3.uid",this.panel),k=c(".edit",this.panel),j=(i.uid==""?"----":i.uid);this.page.content.uid=i.uid;g.text("#"+j);this.close()}},open_url_editor:function(){this.unavailable=false;Spontaneous.Ajax.get(["/slug",this.page.id(),"unavailable"].join("/"),this.unavailable_loaded.bind(this));this.panel.animate({height:"+=14"},200,function(){var q=c("h3",this.panel),s=c(".edit",this.panel);q.hide();s.hide().empty();var v=[""],l=this.page.get("path").split("/"),k=l.pop();l.shift();s.append(e.span().text("/"));for(var m=0,t=l.length;m<t;m++){var h=l[m];v.push(h);s.append(e.a(".path").text(h).attr("href",v.join("/")).click(function(){b.Location.load_path(c(this).attr("href"));return false}));s.append(e.span().text("/"))}var g=e.span(".input-error");var r=e.input({type:"text",autofocus:"autofocus"}).val(k).select();var o=e.span().text("Duplicate URL").hide();g.append(r);g.append(o);s.append(g);var n=function(){this.save(r.val())}.bind(this);var j=k;var u=function(){this.close()}.bind(this);s.append(e.a(".button.save").text("Save").click(n));s.append(e.a(".button.cancel").text("Cancel").click(u));r.bind("keydown.urleditor",function(w){var p=83,i=27;if((w.ctrlKey||w.metaKey)&&w.keyCode===p){n();return false}}.bind(this));r.keyup(function(x){if(x.keyCode===13){n()}else{var w=this.input,p=w.val(),z=w[0],y=z.selectionEnd;if(p!==j){p=p.toLowerCase().replace(/['"]/g,"").replace(/\&/,"and");p=p.replace(/[^\w0-9+]/g,"-").replace(/(\-+|\s+)/g,"-").replace(/(^\-)/,"");if(j.length===p.length){y-=1}w.val(p);z.selectionStart=z.selectionEnd=y;j=p;if(p===""){this.show_path_error("Invalid URL")}else{if(this.unavailable[p]){this.show_path_error()}else{this.hide_path_error()}}}}}.bind(this)).keydown(function(i){if(i.keyCode===27){u()}}.bind(this));s.fadeIn(200,function(){r.focus()});this.input=r;this.error=o}.bind(this))},show_path_error:function(g){g=(g||"Duplicate URL");this.error.text(g).fadeIn(100);this.input.addClass("error")},hide_path_error:function(g){this.error.fadeOut(100);if(this.input.hasClass("error")){this.input.removeClass("error")}},save:function(g){Spontaneous.Ajax.post("/slug/"+this.page.id(),{slug:g},this.save_complete.bind(this))},save_complete:function(i,h,k){if(h==="success"){this.hide_path_error();var g=c("h3.path",this.panel),j=c(".edit",this.panel);this.page.set("path",i.path);this.page.set("slug",i.slug);this.close();Spontaneous.Location.set("path",this.page.get("path"))}else{if(k.status===409){this.show_path_error()}if(k.status===406){this.show_path_error("Invalid URL")}}},close:function(){var g=c("h3",this.panel),h=c(".edit",this.panel);g.show();h.hide();this.panel.animate({height:"-=14"},200)}};var f=new JS.Class(Spontaneous.Views.View,{initialize:function(g){this.page=g;this.callSuper(g)},panel:function(){this.panel=e.div("#page-content");this.panel.append(new d(this.page).panel());var g=e.div("#page-fields");var h=new Spontaneous.FieldPreview(this,"");var j=h.panel();j.prepend(e.div(".overlay"));var i=this.create_edit_wrapper(j);g.append(i);this.panel.append(g);this.panel.append(new Spontaneous.BoxContainer(this.page,"page-slots").panel());this.fields_preview=j;return this.panel},mouseover:function(){if(this.fields_preview){this.fields_preview.addClass("hover")}},mouseout:function(){if(this.fields_preview){this.fields_preview.removeClass("hover")}},depth:function(){return this.page.depth()}});return f}(jQuery,Spontaneous));
54
- Spontaneous.Views.PieceView=(function(f,e){var g=e.Dom,c=e.User;var b=0;var a=new JS.Class(Spontaneous.PopoverView,{initialize:function(h){this.parent_view=h},width:function(){return 208},align:"right",has_navigation:false,close_text:function(){return false},title:function(){return"Delete this "+(this.parent_view.content.is_page()?"Page?":"Piece?")},position_from_event:function(h){return this.position_from_element(h)},view:function(){var j=this.parent_view;var h=g.div("#popover-delete").click(function(){j.cancel_destroy();return false});var i=g.a(".ok").text("Delete").click(function(){j.destroy();return false});var k=g.a(".cancel").text("Cancel");h.append(k,i);return h}});var d=new JS.Class(e.Views.View,{initialize:function(i,h){this.callSuper(i);this.container_view=h},panel:function(){var i=g.div(["entry-wrap",this.depth_class(),this.visibility_class(),this.boxes_class()]);var k=g.div(".entry-contents");var m=g.div(".entry-inner");var h=g.div(".white-bg").mouseover(this.mouseover.bind(this)).mouseout(this.mouseout.bind(this)).click(this.edit.bind(this));m.append(h);if(this.content.depth()<4){m.append(g.div(".grey-bg"))}k.append(this.title_bar(k));if(this.content.type().is_alias()){k.append(this.alias_target_panel())}var p=g.div(".entry");var n=new Spontaneous.FieldPreview(this,"");if(n.has_fields()){var o=n.panel();p.append(o)}var l=new Spontaneous.BoxContainer(this.content);m.append(p);m.append(l.panel());var j=this.create_edit_wrapper(m);k.append(j);i.append(k,this.entry_spacer());this.wrapper=i;this.outline=h;this.fields_preview=o;return i},entry_spacer:function(){var h=g.div(".entry-spacer").hover(function(){this.container_view.show_add_after(this,h)}.bind(this),function(){this.container_view.hide_add_after(this,h)}.bind(this));return h},edit:function(h){this.wrapper.addClass("editing");this.callSuper(h)},edit_closed:function(){this.wrapper.removeClass("editing");this.callSuper()},alias_target_panel:function(){var l=this.content,j=g.div(".alias-target"),i=l.alias_icon,k=function(){e.Location.load_id(l.target().id)},m=g.a().html(l.content.alias_title).click(k);if(!l.has_fields()){j.addClass("no-fields")}if(i){var h=new Spontaneous.Image(i);j.append(h.icon(60,60).click(k))}return j.append(m)},title_bar:function(n){if(!this._title_bar){var j=c.is_developer()?g.a(".developer.source").attr("href",this.content.developer_edit_url()).text(this.content.developer_description()):(this.content.type().title);var i=g.div(".title-bar");var m=g.div(".actions",{xstyle:"display: none"});var k=g.a(".delete");var h=g.a(".visibility");m.append(k);m.append(h);i.append(m);var l;k.click(this.confirm_destroy.bind(this));this.content.watch("hidden",this.visibility_changed.bind(this));h.click(this.toggle_visibility.bind(this));this._title_bar=i}return this._title_bar},reposition:function(h,i){this.content.bind("repositioned",i);this.content.reposition(h)},toggle_visibility:function(){this.content.toggle_visibility()},visibility_changed:function(h){var i=200;this.wrapper.removeClass("visible hidden");if(h){this.wrapper.switchClass("visible","hidden",i)}else{this.wrapper.switchClass("hidden","visible",i)}},mouseover:function(){this.outline.addClass("active");if(this.fields_preview){this.fields_preview.addClass("hover")}},mouseout:function(){this.outline.removeClass("active");if(this.fields_preview){this.fields_preview.removeClass("hover")}},confirm_destroy:function(){if(this._dialogue&&!this._dialogue.is_open){this.close_destroy_dialogue()}if(!this._dialogue){this._dialogue=Spontaneous.Popover.open(event,new a(this))}else{this.close_destroy_dialogue()}},destroy:function(){this.close_destroy_dialogue();this.content.bind("destroyed",this.destroyed.bind(this));this.content.destroy()},cancel_destroy:function(){this.close_destroy_dialogue()},close_destroy_dialogue:function(){if(this._dialogue){this._dialogue.close();this._dialogue=null}},destroyed:function(){this.wrapper.disappear(function(){this.wrapper.remove();this.trigger("removed",this)}.bind(this))}});return d}(jQuery,Spontaneous));
55
- Spontaneous.Views.PagePieceView=(function(c,b){var d=b.Dom;var a=new JS.Class(Spontaneous.Views.PieceView,{panel:function(){var l=d.div(["entry-wrap page no-boxes",this.depth_class(),this.visibility_class()]);var j=d.div(".entry-contents");var f=d.div(".entry-inner");var g=d.div(".white-bg").mouseover(this.mouseover.bind(this)).mouseout(this.mouseout.bind(this)).click(this.edit.bind(this));f.append(g);j.append(this.title_bar(j));if(this.content.type().is_alias()){j.append(this.alias_target_panel())}j.append(this.page_title_panel());var i=d.div(".entry");var e=new Spontaneous.FieldPreview(this,"");var h=e.panel();i.append(h);f.append(i);var k=this.create_edit_wrapper(f);j.append(k);l.append(j,this.entry_spacer());this.wrapper=l;this.outline=g;this.fields_preview=h;return l},page_title_panel:function(){var g=d.div(".page-title"),e=this,f=d.a().html(this.content.title()).click(function(){b.Location.load_id(e.id())});this.content.title_field().watch("value",function(h){f.text(h)}.bind(this));g.append(f);return g}});return a}(jQuery,Spontaneous));
56
- Spontaneous.Entry=(function(d,c){var e=c.Dom,b=c.User;var a=new JS.Class(Spontaneous.Content,{initialize:function(g,f){this.container=f;this.callSuper(g)},});return a})(jQuery,Spontaneous);
57
- Spontaneous.PageEntry=(function(c,b){var a=new JS.Class(Spontaneous.Content,{save_complete:function(d){var e=this;e.callSuper(d);e.set("slug",d.slug);e.set("path",d.path)}});return a})(jQuery,Spontaneous);
58
- Spontaneous.Box=(function(c,b){var d=b.Dom;var a=new JS.Class(Spontaneous.Content,{initialize:function(g,e){this.callSuper(g);this.container=e;var f=this;c.each(this.entries(),function(h,i){i.bind("destroyed",function(j){f.entry_removed(j)})})},name:function(){return this.type().title},type:function(){if(!this._type){this._type=this.container.type().box_prototype(this.content.id)}return this._type},id:function(){return this.container.id()+"/"+this.schema_id()},schema_id:function(){return this.type().data.id},depth:function(){return"box"},mouseover:function(){if(this.fields_preview){this.fields_preview.addClass("hover")}},mouseout:function(){if(this.fields_preview){this.fields_preview.removeClass("hover")}},re_sort:function(n){var g=this._entry_container.sortable("toArray"),f=n.attr("id"),k=0;for(var h=0,m=g.length;h<m;h++){if(g[h]===f){k=h;break}}var e=f.split("-")[1],l;for(var h=0,j=this.entries(),m=j.length;h<m;h++){if(j[h].id()==e){l=j[h];break}}l.reposition(k,function(i){this.sorted(i)}.bind(this))},sorted:function(e){},upload_complete:function(e){this.insert_entry(this.wrap_entry(e.entry),e.position)},upload_progress:function(e,f){},entry_id:function(e){return"entry-"+e.id()},entry_class:function(){return"container-"+this.schema_id()},add_entry:function(f,e){Spontaneous.Ajax.post(["/add",this.id(),f.schema_id].join("/"),{position:e},this.entry_added.bind(this))},add_alias:function(f,g,e){b.Ajax.post(["/alias",this.id()].join("/"),{alias_id:g.schema_id,target_id:f,position:e},this.entry_added.bind(this))},entry_added:function(g){var i=this,f=g.position,k=g.entry,h=this.wrap_entry(k);h.bind("destroyed",function(e){i.entry_removed(e)});if(f===-1){this.content.entries.push(k);this.entries().push(h)}else{this.content.entries.splice(f,0,k);this.entries().splice(f,0,h)}var j=b.Editing.get("page");j.trigger("entry_added",h,f);this.trigger("entry_added",h,f)},entry_removed:function(j){var f=this.entries(),e=0;for(var g=0,h=f.length;g<h;g++){if(f[g].id()==j.id()){e=g;break}}f.splice(e,1);this.trigger("entry_removed",j)},save_path:function(){return["/savebox",this.id()].join("/")},entry_wrappers:function(){return this._entry_container.find("> ."+this.entry_class())}});return a})(jQuery,Spontaneous);
59
- Spontaneous.Page=(function(d,c){var e=c.Dom,a=c.User;var b=new JS.Class(Spontaneous.Content,{initialize:function(f){this.callSuper(f);this.set("path",f.path)},save_complete:function(f){this.callSuper(f);this.set("slug",f.slug);this.set("path",f.path)},depth:function(){return 0},entries:function(){var k=[];for(var g=0,f=this.boxes(),h=f.length;g<h;g++){var j=f[g];k=k.concat(j.entries())}return k},children:function(){var j=[];for(var g=0,f=this.entries(),h=f.length;g<h;g++){var k=f[g];if(k.is_page()){j.push(k)}}return j}});return b}(jQuery,Spontaneous));
60
- Spontaneous.FieldTypes={};
61
- Spontaneous.FieldTypes.StringField=(function(d,a){var e=a.Dom;var c=new JS.Class({initialize:function(f,g){this.dialogue=f;this.conflict=g;this.server_version=g.version;this.values=g.values;this.differ=new a.Diff()},panel:function(){var k=e.div(".string-field-conflict.labels.differences"),q=e.div(),n=e.div(".string-field-conflict.changes.differences"),p=e.div(".original.diff"),h=e.div(".final.diff");var m=e.div(".diff").text("Changes made by other person");var f=e.div(".diff").text("Their changes merged with yours");var i=this.diff(this.values.local_original,this.values.server_original);var g=this.diff(this.values.local_original,this.values.local_edited);var o=this.differ.patch_apply(g.patches,this.values.server_original);var l=this.diff(this.values.local_original,o[0]);var r=this.differ.diff_prettyHtml(i.diff);var j=this.differ.diff_prettyHtml(l.diff);p.append(r).click(function(){this.useValue(this.values.server_original);p.add(h).removeClass("selected");p.addClass("selected")}.bind(this));h.append(j).click(function(){this.useValue(o[0]);p.add(h).removeClass("selected");h.addClass("selected")}.bind(this));k.append(m,f);n.append(p,h);q.append(k,n);return q},diff:function(g,i){var h=this.differ.diff_main(g,i,false);this.differ.diff_cleanupSemantic(h);var f=this.differ.patch_make(g,i,h);return{diff:h,patches:f}},useValue:function(f){this.use_value=f;this.dialogue.resolve_value(this.conflict,f)}});var b=new JS.Class({include:Spontaneous.Properties,initialize:function(f,h){this.content=f;this.name=h.name;var g=f.type();this.type=g.field_prototypes[this.name];this.title=this.type.title;this.update(h)},uid:function(){return this.content.uid()+"["+this.name+"]"},set_value:function(f){},unload:function(){},update:function(f){this.data=f;this.set("value",f.processed_value);this.set("unprocessed_value",f.unprocessed_value)},preview:function(){return this.get("value")},activate:function(f){f.find('a[href^="/"]').click(function(){a.Location.load_path(d(this).attr("href"));return false})},value:function(){return this.get("value")},unprocessed_value:function(){return this.data.unprocessed_value},is_image:function(){return false},is_file:function(){return false},id:function(){return this.content.id()},css_id:function(){return"field-"+this.name+"-"+this.id()},form_name:function(){return this.input_name("unprocessed_value")},version_name:function(){return this.input_name("version")},input_name:function(f){return"field["+this.schema_id()+"]["+f+"]"},schema_id:function(){return this.type.schema_id},version:function(){return this.data.version},set_version:function(f){this.data.version=f},label:function(){return this.title},generate_input:function(){return e.input(e.id(this.css_id()),{type:"text",name:this.form_name(),value:this.unprocessed_value()})},input:function(){if(!this._input){this._input=this.generate_input();this._input.data("field",this)}return this._input},edited_value:function(){return this.input().val()},is_modified:function(){return true},original_value:function(){return this.unprocessed_value()},set_edited_value:function(f){this.input().val(f)},cancel_edit:function(){},close_edit:function(){this._input=null;this._version_input=null},edit:function(){return this.input()},toolbar:function(){return false},footer:function(){return false},focus:function(){this.input().focus().select()},accepts_focus:true,on_focus:function(){this.input().parents(".field").first().addClass("focus")},on_blur:function(){this.input().parents(".field").first().removeClass("focus")},conflict_view:function(f,g){return new c(f,g)}});b.ConflictView=c;return b})(jQuery,Spontaneous);
62
- Spontaneous.FieldTypes.LongStringField=(function(c,a){var d=a.Dom;var b=new JS.Class(Spontaneous.FieldTypes.StringField,{generate_input:function(){return d.textarea(d.id(this.css_id()),{name:this.form_name(),rows:10,cols:30}).text(this.unprocessed_value())}});return b})(jQuery,Spontaneous);
63
- Spontaneous.FieldTypes.FileField=(function(c,b){var d=b.Dom;var a=new JS.Class(Spontaneous.FieldTypes.StringField,{selected_files:false,preview:function(){Spontaneous.UploadManager.register(this);return this.callSuper()},unload:function(){this.callSuper();this.input=null;this._progress_bar=null;Spontaneous.UploadManager.unregister(this)},upload_complete:function(e){console.log("FileField#upload_complete",e);this.set("value",e.processed_value);this.set_version(e.version);this.selected_files=null;this.disable_progress()},disable_progress:function(){this.progress_bar().parent().hide();this.drop_target.removeClass("uploading")},upload_progress:function(e,f){if(!this.drop_target.hasClass("uploading")){this.drop_target.addClass("uploading")}this.progress_bar().parent().show();this.progress_bar().css("width",((e/f)*100)+"%")},is_file:function(){return true},get_input:function(){this.input=d.input({type:"file",name:this.form_name(),accept:"image/*"});return this.input},accepts_focus:false,save:function(){if(!this.selected_files){return}var g=this.selected_files;if(g&&g.length>0){this.drop_target.addClass("uploading");this.progress_bar().parent().show();var e=new FormData();var f=g[0];b.UploadManager.replace(this,f)}this.selected_files=false},is_modified:function(){var e=this.selected_files;return(e&&e.length>0)},original_value:function(){this.processed_value()},set_edited_value:function(e){console.log("set_edited_value",e,this.edited_value(),this.original_value());if(e===this.edited_value()){}else{this.selected_files=null;this.set("value",e)}}});return a})(jQuery,Spontaneous);
64
- Spontaneous.FieldTypes.ImageField=(function(d,b){var e=b.Dom;var c=new JS.Class(b.FieldTypes.StringField.ConflictView,{panel:function(){var l=e.div(".image-field-conflict.labels.differences"),h=e.div(),f=e.div(".image-field-conflict.changes.differences"),g=e.div(".original.diff"),k=e.div(".final.diff");var j=e.div(".diff").text("Server version");var i=e.div(".diff").text("Your version");g.append(e.img().attr("src",this.values.server_original)).click(function(){this.useValue(this.values.server_original);k.add(g).removeClass("selected");g.addClass("selected")}.bind(this));k.append(e.img().attr("src",this.values.local_edited)).click(function(){this.useValue(this.values.local_edited);k.add(g).removeClass("selected");k.addClass("selected")}.bind(this));l.append(j,i);f.append(g,k);h.append(l,f);return h}});var a=new JS.Class(Spontaneous.FieldTypes.FileField,{is_image:function(){return true},unload:function(){this.callSuper();this.image=null;this._progress_bar=null},progress_bar:function(){if(!this._progress_bar){var g=e.div(".drop-upload-outer").hide();var f=e.div(".drop-upload-inner").css("width",0);g.append(f);this._progress_bar=f}return this._progress_bar},upload_progress:function(f,g){this.spinner().stop();this.waiting.find(":visible").hide();this.callSuper()},preview:function(){Spontaneous.UploadManager.register(this);var m=this.get("value").original,f=m.src,i=null,j=45;if(f===""){i=e.img(".missing-image",{src:"/@spontaneous/static/px.gif"})}else{i=e.img();i.load(function(){var s=this.width/this.height,u=d(this),q=u.height(),t=0;if(s>=1&&q<=j){var t=(j-q)/2}u.css("top",e.px(t))});i.attr({src:f})}i.error(function(){d(this).addClass("missing")});this.image=i;var o=e.div(".image-outer");var k=e.div(".image-drop");var p=e.div(".waiting").hide();o.append(i);o.append(p);o.append(k);k.append(this.progress_bar().parent());this.waiting=p;var g=function(t){t.stopPropagation();t.preventDefault();k.removeClass("drop-active").addClass("uploading");var s=t.dataTransfer.files;this.waiting.show();this.spinner().indeterminate();if(s.length>0){this.selected_files=s;var r=s[0],q=window.URL.createObjectURL(r);this._edited_value=q;this.image.__start_upload=true;this.image.bind("load",function(){if(this.image.__start_upload){this.image.__start_upload=false;b.Ajax.test_field_versions(this.content,[this],this.upload_values.bind(this),this.upload_conflict.bind(this))}}.bind(this));this.image.attr("src",q);window.URL.revokeObjectURL(q)}return false}.bind(this);var l=function(q){q.stopPropagation();q.preventDefault();d(this).addClass("drop-active");return false}.bind(k);var h=function(q){q.stopPropagation();q.preventDefault();return false}.bind(k);var n=function(q){q.stopPropagation();q.preventDefault();d(this).removeClass("drop-active");return false}.bind(k);k.get(0).addEventListener("drop",g,true);k.bind("dragenter",l).bind("dragover",h).bind("dragleave",n);this.drop_target=k;this.preview_img=i;return o},upload_values:function(){var f=this.selected_files[0];b.UploadManager.replace(this,f)},upload_conflict:function(g){var f=new b.ConflictedFieldDialogue(this,g);f.open()},conflicts_resolved:function(f){console.log("conflicts_resolved",f);var g=f[0];this.set_edited_value(g.value);this.set_version(g.version);if(this.is_modified()){this.upload_values()}else{this.disable_progress()}},disable_progress:function(){this.spinner().stop();this.callSuper()},spinner:function(){if(!this._spinner){this._spinner=Spontaneous.Progress(this.waiting[0],16,{spinner_fg_color:"#fff",period:800});this._spinner.init()}return this._spinner},upload_complete:function(g){this.callSuper(g);if(g){var h=this.value().original;if(this.image){var f=new Image();f.onload=function(){this.image.attr("src",h.src)}.bind(this);f.src=h.src}}},width:function(){if(this.data.values&&this.data.values.original){return this.data.values.original.width}return 0},height:function(){if(this.data.values&&this.data.values.original){return this.data.values.original.height}return 0},edit:function(){var m=e.div({style:"position:relative;"}),t=this.value().original,k=t.src,C=e.img({src:k}),y,f,j,z,x;if(t.width>=t.height){m.addClass("landscape")}else{m.removeClass("landscape")}y=e.div(".info");f=e.div(".sizes");j=e.div(".filename");z=e.div(".filesize");x=e.div(".dimensions");f.append(z,x);y.append(j);y.append(f);var i=function(D,s){if(D&&s){x.text(D+"x"+s)}else{x.text("")}};var r=function(D,E,F,s){j.text(D);if(E){z.text(parseFloat(E,10).to_filesize())}i(F,s)};var h=function(E){if(E.length>0){var D=E[0],s=window.URL.createObjectURL(D);C.attr("src",s).removeClass("empty");this.selected_files=E;C.attr("src",s);this._edited_value=s;this.image.attr("src",s);window.URL.revokeObjectURL(s);r(D.fileName,D.fileSize,null,null)}}.bind(this);var w=function(){var s=this.input[0].files;h(s)}.bind(this);var p=this.get_input().change(w);var B=function(){p.trigger("click");return false};if(k==""){C.addClass("empty")}var g=e.div(".image-drop").click(B);var o=e.div(".actions");o.append(p);m.append(g);var l=function(D){D.stopPropagation();D.preventDefault();g.removeClass("drop-active");var s=D.dataTransfer.files;h(s);return false}.bind(this);var n=function(s){s.stopPropagation();s.preventDefault();d(this).addClass("drop-active");return false}.bind(g);var v=function(s){s.stopPropagation();s.preventDefault();return false}.bind(g);var A=function(s){s.stopPropagation();s.preventDefault();d(this).removeClass("drop-active");return false}.bind(g);g.get(0).addEventListener("drop",l,true);g.bind("dragenter",n).bind("dragover",v).bind("dragleave",A);m.append(C,o,y);if(t){var q=t.src.split("/"),u=q[q.length-1];r(u,t.filesize,t.width,t.height)}this.preview_img=C;return m},edited_value:function(){return this.input().val()},cancel_edit:function(){this.image.attr("src",this.original_value().src)},conflict_view:function(f,g){return new c(f,g)},original_value:function(){return this.value().original},edited_value:function(){return this._edited_value},set_edited_value:function(f){this.preview_img.attr("src",f);this.callSuper(f)}});a.ConflictView=c;return a})(jQuery,Spontaneous);
65
- Spontaneous.FieldTypes.MarkdownField=(function(h,f){var e=f.Dom;var i=new JS.Class({name:"",pre:"",post:"",extend:{get_state:function(q){var w=q[0].selectionStart,p=q[0].selectionEnd,u=q.val(),t=u.substr(0,w),r=u.substr(w,(p-w)),v=u.substr(p),s;s={start:w,end:p,before:t,middle:r,selection:r,after:v};return s}},initialize:function(p){this.input=p.bind("keydown.markdown",function(r){var q=String.fromCharCode(r.keyCode);if((r.ctrlKey||r.metaKey)&&q===this.key_shortcut()){this.execute(r);return false}}.bind(this))},key_shortcut:function(){return""},execute:function(p){this.wrap()},wrap:function(){var r=this.input,u=this.fix_selection(),x=u.start,p=u.end,v=u.before,t=u.selection,w=u.after,q;if(this.matches_selection(t)){q=this.remove(t)}else{q=this.surround(t)}r.val(v+q+w);r[0].selectionStart=x;r[0].selectionEnd=x+q.length},get_state:function(){return i.get_state(this.input)},fix_selection_whitespace:function(s){var r=s.selection,p,q;p=/^( +)/.exec(r);if(p){q=p[1].length;s.start+=q;s.selection=r.substr(q)}p=/( +)$/.exec(r);if(p){q=p[1].length;s.end-=q;s.selection=r.substr(0,r.length-q)}return s},expand_selection:function(q){q=this.fix_selection_whitespace(q);var w=q.selection,u,s=q.start,v=q.end,p=this.pre.replace(/\*/g,"\\*"),z=this.post.replace(/\*/g,"\\*");u=(new RegExp("(?:^| )("+p+"[^("+p+")]*)$","m")).exec(q.before);if(u){s-=u[1].length;w=u[1]+w}u=(new RegExp("^([^("+z+")]*?"+z+")[^("+z+")w ]*?( |$)","")).exec(q.after);if(u){v+=u[1].length;w+=u[1]}if((v-s)>0){if(w.indexOf(this.pre)!==0){var t;for(var x=0,y=this.pre.length;x<y;x++){t=q.before.substr(-(x+1))+w;if(t.indexOf(this.pre)===0){s-=(x+1);w=t;break}}}if(w.substr(-this.post.length)!==this.post){var t;for(var x=0,y=this.post.length;x<y;x++){t=w+q.after.substr(0,(x+1));if(t.substr(-this.post.length)===this.post){v+=(x+1);w=t;break}}}}else{var r="\\s\\b\\.,";u=(new RegExp("(?:["+r+"]|^)([^"+r+"]+)$","")).exec(q.before);if(u){s-=u[1].length;w=u[1]+w}u=(new RegExp("^([^"+r+"]*)(?:["+r+"]|$)","")).exec(q.after);if(u){v+=u[1].length;w+=u[1]}}return{start:s,end:v,selection:w}},fix_selection:function(){var p=this.get_state(),q;if(!this.matches_selection(p.selection)){q=this.expand_selection(p);h.extend(p,q);p=this.update_state(p)}return p},update_state:function(p){this.input[0].setSelectionRange(p.start,p.end);return this.get_state()},surround:function(p){return this.pre+p+this.post},remove:function(p){return p.substr(this.pre.length,p.length-this.pre.length-this.post.length)},value:function(){return this.input.val()},button:function(){if(!this._button){var p=e.a(this.name.toLowerCase()).click(function(q){this.execute(q);return false}.bind(this)).text(this.name);this._button=p}return this._button},respond_to_selection:function(p){this.deactivate();if(this.matches_selection(p.selection)||this.matches_selection(this.expand_selection(p).selection)){this.activate();return true}else{this.deactivate();return false}},activate:function(){this.button().addClass("active")},deactivate:function(){this.button().removeClass("active")},matches_removal:function(p){return this.matches_selection(p)},matches_selection:function(p){return(p.indexOf(this.pre)===0&&p.lastIndexOf(this.post)===(p.length-this.post.length))}});var o=new JS.Class(i,{name:"Bold",pre:"**",post:"**",key_shortcut:function(){return"B"},});var j=new JS.Class(i,{name:"Italic",pre:"_",post:"_",key_shortcut:function(){return"I"},});var b=new JS.Class(i,{name:"UL",pre:"*",post:"",br:/\r?\n/,strip_bullet:/^ *(\d+\.|\*) */,is_list_entry:/(?:\r?\n)( *\*{1} +.+?)$/,surround:function(s){var p=s.split(this.br);for(var q=0,r=p.length;q<r;q++){if(/^\s*$/.test(p[q])){}else{p[q]=this.bullet_for(q)+p[q].replace(this.strip_bullet,"")}}return p.join("\n")},remove:function(s){var p=s.split(this.br);for(var q=0,r=p.length;q<r;q++){p[q]=p[q].replace(this.strip_bullet,"")}return p.join("\n")},expand_selection:function(t){var s=(t.selection||""),p,u=t.start,q=t.end,r=/\r?\n/;p=this.strip_bullet.exec(s);if(!p){p=this.is_list_entry.exec(t.before);if(p){u-=p[1].length;s=p[1]+s;p=/^(.*?)(?:\r?\n)/.exec(t.after);if(p){q+=p[1].length;s+=p[1]}}}return{selection:s,start:u,end:q}},bullet_for:function(p){return"* "},matches_selection:function(p){return/^ *\* +/.test(p)}});var d=new JS.Class(b,{name:"OL",is_list_entry:/(?:\r?\n)( *\d+\..+?)$/,bullet_for:function(p){return(p+1)+". "},matches_selection:function(p){return/^ *\d+\./.test(p)}});var m=new JS.Class(i,{name:"H1",pre:"",post:"=",scale:1,key_shortcut:function(){return"1"},surround:function(u){if(this.matches_removal(u)){u=this.remove(u)}var p="",v=Math.floor(this.input.attr("cols")*0.5),q=/([\r\n]+)$/,t=q.exec(u),s;t=(!t||(t===s)?"":t[1]);for(var r=0;r<v;r++){p+=this.post}return u.replace(q,"")+"\n"+p+t},remove:function(t){var q=new RegExp("[\r\n][=-]+"),p=t.replace(q,"");return p.replace(/ +$/,"")},matches_removal:function(p){return(new RegExp("[\r\n][=\\-]+[\r\n ]*$")).exec(p)},matches_selection:function(p){return(new RegExp("[\r\n]?"+this.post+"+[\r\n ]*$","m")).exec(p)},expand_selection:function(q){var z=(q.selection||""),w,t=q.start,y=q.end,D=/\r?\n/,B=false;w=/[\r\n]([=-]+)$/.exec(q.before);n=/^([=-]+)[\r\n]/.exec(q.after);if(w||n){w=/(?:[\n]|^)(.+[\n]+([=-]+))$/.exec(q.before);if(w){var G=w[1];t-=G.length;z=G+z}if(n){var G=n[1];y+=G.length;z+=G}B=true}if(!B){w=/(.+)$/.exec(q.before);if(w){var G=w[1];t-=G.length;z=w[1]+z}w=/^(.+)/.exec(q.after);if(w){var G=w[1];y+=G.length;z+=w[1]}var F=z.split(D),u=new RegExp("^[=-]+$"),E=false;for(var A=0,C=F.length;A<C;A++){var x=F[A];if(u.test(x)){E=true;break}}if(!E){F=q.after.split(D,2);for(var A=0,C=F.length;A<C;A++){var x=F[A];if(u.test(x)){y+=x.length+A;z+=x;break}}}else{var p=new RegExp("^([=-]+)"),w=p.exec(q.after);if(w){var v=w[1];y+=v.length;z+=w[1]}}}return{selection:z,start:t,end:y}}});var k=new JS.Class(m,{name:"H2",post:"-",scale:1.2,key_shortcut:function(){return"2"},});var l=new JS.Class(Spontaneous.PopoverView,{initialize:function(r,p,q){this.editor=r;this.link_text=p;this.url=q;this.callSuper()},width:function(){return 300},title:function(){return"Insert Link"},close_text:function(){return"Cancel"},view:function(){var s=this,p=e.div(".pop-insert-link"),u,r;var q=function(w,z,y){var v,x=e[(y||"input")]({type:"text"}).keypress(function(A){if(A.charCode===13){s.insert_link_and_close(u,r);return false}}).val(z);v=e.label().append(e.span().text(w)).append(x);return v};u=q("Text",this.link_text);r=q("URL",this.url,"textarea");r.find("textarea").attr("rows",3);cancel=e.a(".button.cancel").text("Clear").click(function(){this.insert_link_and_close(u,r.val(""));return false}.bind(this)),insert=e.a(".button").text("OK").click(function(){this.insert_link_and_close(u,r);return false}.bind(this));p.append(e.p().append(u)).append(e.p().append(r));var t=e.div(".buttons");r=r.find(":input");u=u.find(":input");this.text_input=u;this.url_input=r;this.page_browser=new g(this.url,this);p.append(this.page_browser.view());p.append(t.append(cancel).append(insert));this.wrapper=p;return p},insert_link:function(q,p){this.editor.insert_link(q.val(),p.val())},insert_link_and_close:function(q,p){this.insert_link(q,p);this.close()},cancel:function(){this.close()},after_open:function(){this.wrapper.find("textarea").select()},after_close:function(){this.editor.dialogue_closed()},page_selected:function(p){this.url_input.val(p.path)}});var g=new JS.Class({initialize:function(p,q){this.parent=q;this.location=p;this.browser=new Spontaneous.PageBrowser(this.location);this.browser.set_manager(this)},view:function(){var p=e.div();text=e.span().text("Page Browser"),inner=e.div(".link-page-browser");inner.append(e.label().append(text)).append(this.browser.view());p.append(inner);return p},page_list_loaded:function(p){},page_selected:function(p){this.parent.page_selected(p)},next_level:function(p){this.location=p}});var a=new JS.Class(i,{name:"Link",link_matcher:/^\[([^\]]+)\]\(([^\)]+)\)$/,execute:function(r){var y=this.input,A=this.fix_selection(),t=A.start,v=A.end,x=A.before,B=A.middle,q=A.after,w,u=this.link_matcher.exec(B),z=B,p;if(u){z=u[1];p=u[2]}if(!this._dialogue){this._dialogue=Spontaneous.Popover.open(r,new l(this,z,this.preprocess_url(z,p)))}else{this._dialogue.close();this._dialogue=null}this.input.focus();return false},expand_selection:function(s){s=this.fix_selection_whitespace(s);var r=s.selection,p,t=s.start,q=s.end;p=/(\[[^\)]*?)$/.exec(s.before);if(p){t-=p[1].length;r=p[1]+r}p=/^([^\)\[]*?\))/.exec(s.after);if(p){q+=p[1].length;r+=p[1]}return{selection:r,start:t,end:q}},preprocess_url:function(q,p){if(!p){p=this.postprocess_url(String(q))||""}return p},postprocess_url:function(p){if(p){if(/^(https?|mailto|ftp|javscript):/.test(p)){p=p}else{if(/^[a-z-]+\.([a-z-]+\.)*[a-z]{2,}(\/[^ ]*)*$/i.exec(p)){p="http://"+p}else{if(/^[^ @]+@([a-z-]+\.)+[a-z]{2,}$/i.exec(p)){p="mailto:"+p}else{return false}}}}return p},dialogue_closed:function(){this._dialogue=null;this.input.focus()},insert_link:function(r,p){p=this.postprocess_url(p)||p;var q=function(s){return this.surround_with_link(r,p)}.bind(this);this.surround=q;this.remove=q;this.wrap()},surround_with_link:function(q,p){if(p===""){return q}else{return"["+q+"]("+p+")"}},remove_link:function(q){var p=this.link_matcher.exec(q);return p[1]},matches_selection:function(p){return this.link_matcher.exec(p)}});var c=new JS.Class(Spontaneous.FieldTypes.StringField,{actions:[o,j,m,k,b,d,a],generate_input:function(){return e.textarea(e.id(this.css_id()),{name:this.form_name(),rows:10,cols:90}).val(this.unprocessed_value())},on_focus:function(){if(!this.expanded){var p=this.input(),s=p.innerHeight();p.data("original-height",s);var t=p[0].scrollHeight,q=500,r=Math.min(t,q);if(Math.abs(r-s)>20){p.animate({height:r});this.expanded=true}}this.callSuper()},on_blur:function(){if(this.expanded){var p=this.input();p.animate({height:p.data("original-height")});this.expanded=false}this.callSuper()},toolbar:function(){if(!this._toolbar){this._wrapper=e.div([e.id("editor-"+this.css_id()),".markdown-editor"]);this._toolbar=e.div(".md-toolbar");this.commands=[];var p=this.input();for(var q=0,u=this.actions,r=u.length;q<r;q++){var t=u[q],s=new t(p);this.commands.push(s);this._toolbar.append(s.button())}this._wrapper.append(this._toolbar);p.css("height","")}return this._wrapper},edit:function(){this.expanded=false;var p=this.input();p.unbind("select.markdown").unbind("click.markdown").unbind("keyup.markdown");p.bind("select.markdown",this.on_select.bind(this));p.bind("click.markdown",this.on_select.bind(this));p.bind("keyup.markdown",this.on_select.bind(this));return p},close_edit:function(){this._input=null;this._toolbar=null;this.commands=[];this.expanded=false;this.callSuper()},on_select:function(p){var q=i.get_state(this.input());h.each(this.commands,function(){this.respond_to_selection(q)})}});c.extend({TextCommand:i,Bold:o,Italic:j,UL:b,OL:d,H1:m,H2:k,Link:a});return c})(jQuery,Spontaneous);
66
- Spontaneous.FieldTypes.DateField=(function(c,a){var d=a.Dom;var b=new JS.Class(Spontaneous.FieldTypes.StringField,{});return b})(jQuery,Spontaneous);
67
- Spontaneous.FieldTypes.WebVideoField=(function(c,a){var d=a.Dom;var b=new JS.Class(Spontaneous.FieldTypes.StringField,{});return b})(jQuery,Spontaneous);
68
- Spontaneous.ContentArea=(function(c,b){var d=b.Dom;var a=new JS.Singleton({include:Spontaneous.Properties,wrap:null,preview:null,editing:null,mode:"edit",init:function(){this.wrap=d.div("#content");this.preview=b.Preview.init(this.wrap);this.editing=b.Editing.init(this.wrap);return this.wrap},location_changed:function(e){this.goto_page(e)},display:function(e){this.mode=e;this.current().display(b.Location.location())},current:function(){if(this.mode==="preview"){this.editing.hide();this.preview.show();return this.preview}else{if(this.mode==="edit"){this.preview.hide();this.editing.show();return this.editing}}},goto_page:function(e){this.current().goto_page(e)},scroll_to_bottom:function(f,e){this.wrap.delay(e||0).animate({scrollTop:this.wrap[0].scrollHeight},(f||1000))}});return a})(jQuery,Spontaneous);
69
- Spontaneous.Preview=(function(d,b){var f=b.Dom,a=0;var e=function(){return"?__click="+(++a)};var c=new JS.Singleton({include:Spontaneous.Properties,element:function(){return wrap},title:function(){return this.get("title")||""},init:function(g){this.iframe=f.iframe("#preview_pane",{src:"about:blank"});this.iframe.hide();g.append(this.iframe);return this},display:function(g){var h=b.Location.get("path");this.iframe.show().fadeOut(0);this.iframe.bind("load.preview",function(){var i=this;d(this.contentWindow.document).ready(function(){d(i).fadeIn(100)});b.Preview.set({title:this.contentWindow.document.title,path:this.contentWindow.location.pathname});b.Location.load_path(this.contentWindow.location.pathname)});this.goto_path(h)},goto_path:function(g){if(g){g+=e();this.iframe[0].contentWindow.location.href=g}},goto_page:function(g){var h=this.get("path");if(!h||(g&&(g.path!==h))){this.goto_path(g.path)}},hide:function(){this.iframe.unbind("load.preview").hide()},show:function(){this.iframe.show()}});return c})(jQuery,Spontaneous);
70
- Spontaneous.Editing=(function(c,b){var e=b.Dom,a=b.Page;var d=new JS.Singleton({include:Spontaneous.Properties,init:function(f){this.container=e.div("#data_pane");this.container.hide();f.append(this.container);return this},display:function(f){this.goto_page(f)},goto_page:function(f){if(!f){return}this.container.show().fadeOut(0);b.Ajax.get("/page/{id}".replace("{id}",f.id),this.page_loaded.bind(this));this.set("location",f)},page_loaded:function(g){var f=this.get("page");if(f){f.unload()}f=new a(g);f.watch("path",this.path_updated.bind(this));view=new b.Views.PageView(f);this.container.empty();this.container.append(view.panel());this.set("page",f);this.container.fadeIn(300)},path_updated:function(f){this.set("path",f)},path:function(){var f=this.get("path");if(f){return f}else{return this.get("page").get("path")}},hide:function(){this.container.hide()},show:function(){this.container.show()}});return d})(jQuery,Spontaneous);
71
- Spontaneous.Location=(function(e,c){var d=c.Ajax;var b=new JS.Class({initialize:function(f){this.page_id=false;this.mode=null;if(f){f=f.substr(d.namespace.length+1);this.parse_path(f)}},parse_path:function(g){var f=g.split("/"),i=f[0],h=f[1];this.page_id=i;this.mode=h},restore:function(){if(this.mode){Spontaneous.Location.view_mode_changed(this.mode);Spontaneous.TopBar.set_mode(this.mode)}if(this.page_id){Spontaneous.Location.load_id(this.page_id)}else{Spontaneous.Location.load_path("/")}},to_hash:function(){return"#/"+(this.page_id||"")+(this.mode?("@"+this.mode):"")},to_path:function(){return[d.namespace,(this.page_id||""),this.mode].join("/")},to_obj:function(){return{page_id:this.page_id,mode:this.mode}}});b.extend({popstate:function(f){b.restore(f);return false},restore:function(f){var g=new b(window.location.pathname);g.restore()},page:function(f,h){var g=new b;g.page_id=f.id;g.mode=h;window.history.replaceState(g.to_obj(),""+g.page_id,g.to_path())}});var a=new JS.Singleton({include:Spontaneous.Properties,init:function(g){var f=function(){g();this.location_loaded()}.bind(this);g();b.restore()},page_loaded:function(f){},slot_changed:function(f){},view_mode_changed:function(f){this.set("view_mode",f);if(this.get("location")){this.update_state(this.get("location"),f)}},load_map:function(){},location_loaded:function(g,f,i){if(f!=="success"){if(i.status===406){var h=new Spontaneous.AddHomeDialogue(Spontaneous.Types.get("types"));h.open()}}else{this.set("location",g);this.set("path",g.path);this.update_state(g,this.get("view_mode"))}},update_state:function(f,g){b.page(f,g)},load_id:function(g){var f=this.location();if(!f||g!=f.id){this.find_id(g)}},load_path:function(f){this.find_path(f)},path_changed:function(f){this.set("path",f)},url:function(){var f=this.location();return(f?f.url:"/about")},location:function(){return this.get("location")},update:function(f){this.set("location",f);this.path_from_url(f.url)},current_path:function(){return this.path_from_url(this.url())},find_path:function(f){if(this.location()&&f===this.location().path){return this.location()}d.get("/location"+f,this.location_loaded.bind(this))},find_id:function(f){if(this.location()&&f===this.location().id){return this.location()}d.get("/map/"+f,this.location_loaded.bind(this))},path_from_url:function(g){var f=this.get("map"),j=f.children,p=[],m,o,l=g.split("/").slice(1),n=0;p.push({selected:0,pages:[f],root:true});while(n<l.length){for(m=0,o=j.length;m<o;m++){var h=j[m],k=h.url.split("/").slice(-1)[0];if(k===l[n]){p.push({selected:m,pages:j});j=h.children;break}}n+=1}return p}});return a})(jQuery,Spontaneous);
72
- Spontaneous.State=(function(e,c){var d=c.Ajax;var b=new JS.Class({initialize:function(f){this.content=f;this.state=this.load()},load:function(){var f=(localStorage.getItem(this.storage_key())||"{}");try{return JSON.parse(f)}catch(g){return{}}},save:function(){localStorage.setItem(this.storage_key(),this.toString())},storage_key:function(){return"content-state-"+this.content.id()},activate_box:function(f){this.state.box=f.id()},active_box:function(){return this.state.box},activate_slot:function(f){this.state.slot=f.id()},active_slot:function(){return this.state.slot},toString:function(){return JSON.stringify(this.state)}});var a=new JS.Singleton({get:function(g){var f=new b(g);return f},activate_box:function(h,g){var f=this.get(h);f.activate_box(g);f.save()},active_box:function(g){var f=this.get(g);return f.active_box()},activate_slot:function(g,h){var f=this.get(g);f.activate_slot(h);f.save()},active_slot:function(g){var f=this.get(g);return f.active_slot()}});return a}(jQuery,Spontaneous));
73
- Spontaneous.TopBar=(function(d,c){var b=c.Dom;var j=function(k){this.page=k;this.id=k.id;this.url=k.url;this.title=c.site_domain};j.prototype={element:function(){var k=b.li(".root");var l=b.a({href:this.url}).text(this.title).data("page",this.page);l.click(function(){var m=d(this).data("page");c.Location.load_id(m.id);return false});k.append(l);this.link=l;return k},set_title:function(k){this.link.text(k)}};var a=function(k){this.page=k;this.id=k.id;this.title=k.slug;this.path=k.path};a.prototype={element:function(){var k=b.li().append(d("<a/>").data("page",this.page).click(function(){var l=d(this).data("page");c.Location.load_id(l.id)}).text(this.title));return k}};var e=function(m){this.page=m;this.id=m.id;this.path=m.path;this.title=m.slug;this.pages=m.generation.sort(function(r,q){var p=r.title,o=q.title;if(p==o){return 0}return(p<o?-1:1)});for(var k=0,l=this.pages.length;k<l;k++){var n=this.pages[k];if(n.id===this.id){this.selected=k;break}}};e.prototype={element:function(){var l=b.li();var k=b.select();k.change(function(){var p=d(this.options[this.selectedIndex]).data("page");c.Location.load_id(p.id);return false});for(var m=0,o=this.pages.length;m<o;m++){var q=this.pages[m],n=b.option({value:q.id,selected:(m==this.selected)}).text(q.slug).data("page",q);if(q.id===this.id){this.title_option=n}k.append(n)}l.append(k);return l},set_title:function(k){this.title_option.text(k)}};var i=function(k){this.children=k};i.prototype={element:function(){var l=b.li(".children");var k=b.select(".unselected");this.li=l;this.select=k;k.append(b.option().text(this.status_text()));k.change(function(){var q=d(this.options[this.selectedIndex]).data("page");if(q){c.Location.load_id(q.id())}return false});for(var m=0,n=this.children.length;m<n;m++){var o=this.children[m];k.append(this.option_for_entry(o))}l.append(k);return l}.cache(),status_text:function(){if(this.children.length===0){this.select.hide()}else{this.select.show()}return"("+(this.children.length)+" pages)"},option_for_entry:function(l){var k=b.option({value:l.id()}).text(l.slug()).data("page",l);if(l.watch){l.watch("slug",function(m){k.text(m)}.bind(this))}return k},update_status:function(){var k=this.select.find("option:first-child");k.text(this.status_text());return k},add_page:function(m,k){var l=this.option_for_entry(m);if(k===-1){this.children.push(m);this.select.append(l)}else{this.children.splice(0,0,m);var n=this.update_status();n.after(l)}},remove_page:function(p){var m=0;for(var n=0,o=this.children.length;n<o;n++){if(this.children[n].id()===p.id()){m=n;break}}this.children.splice(m,1);this.update_status();var l=this.select.find("option:gt(0)"),k;l.each(function(){if(d(this).data("page").id()===p.id()){d(this).remove()}})}};var h=new JS.Class({rapid_check:2000,normal_check:10000,initialize:function(){this.status=false;this.set_interval(this.normal_check);var k=this.update_status.bind(this);c.EventSource.addEventListener("publish_progress",function(l){k(d.parseJSON(l.data))})},check_status:function(){c.Ajax.get("/publish/status",this.status_recieved.bind(this))},status_recieved:function(k,l){if(l==="success"&&k!=this.status){this.update_status(k)}window.setTimeout(this.check_status.bind(this),this.timer_interval)},update_status:function(k){if(k===null||k===""){return}var m=k.state,l=k.progress;this.current_action=m;this.current_progress=l;if(m==="complete"||m==="error"){this.in_progress=false;this.progress().stop();this.set_label("Publish");this.button().switchClass("progress","");this.current_action=this.current_progress=null;if(m==="error"){alert("There was a problem publishing: "+l)}}else{this.publishing_state();if(m==="rendering"){this.progress().update(l)}else{this.progress().indeterminate()}}},publishing_started:function(){this.publishing_state();this.progress().indeterminate()},publishing_state:function(){this.set_label("Publishing");var k=this.button();this.current_action=this.current_progress=null;if(!k.hasClass("progress")){k.switchClass("","progress")}this.in_progress=true},set_label:function(k){if(k!==this._label_text){this._label_text=k;this._label.text(k)}},button:function(){if(!this._button){this._progress_container=b.span("#publish-progress");this._label=b.span();this._button=b.a("#open-publish").append(this._progress_container).append(this._label);this.set_label("Publish");this._button.click(function(){if(!this.in_progress){c.Publishing.open_dialogue()}}.bind(this))}return this._button},progress:function(){if(!this._progress){this._progress=Spontaneous.Progress("publish-progress",15,{spinner_fg_color:"#ccc",progress_fg_color:"#fff"});this._progress.init()}return this._progress},set_interval:function(k){this.timer_interval=k}});var g=new JS.Class({initialize:function(k){this.child=k},id:function(){return this.child.id},title:function(){return this.child.title},slug:function(){return this.child.slug}});var f=new JS.Singleton({include:Spontaneous.Properties,location:"/",panel:function(){this.wrap=b.div("#top");this.location=b.ul("#navigation");this.location.append(b.li().append(b.a()));this.mode_switch=b.a("#switch-mode").text(this.opposite_mode(c.ContentArea.mode)).click(function(){c.TopBar.toggle_modes()});this.publish_button=new h();this.wrap.append(this.location);this.wrap.append(this.publish_button.button());this.wrap.append(this.mode_switch);return this.wrap},init:function(){if(!this.get("mode")){this.set("mode",c.ContentArea.mode)}c.Editing.watch("page",this.page_loaded.bind(this));c.Location.watch("location",this.location_loaded.bind(this))},location_loaded:function(k){this.set("page",undefined);var m=[];for(var l=0,p=k.children,n=p.length;l<n;l++){m.push(new g(p[l]))}var o=new i(m);this.location.append(o.element());this.children_node=o},page_loaded:function(n){var k=this.get("page"),m=(k?k.id():undefined);if(n&&(n.id()!==m)){if(this.children_node){this.children_node.element().remove()}this.set("page",n);var l=new i(n.children());this.location.append(l.element());n.bind("entry_added",function(p,o){if(p.is_page()){l.add_page(p,o)}});n.bind("removed_entry",function(o){if(o.is_page()){l.remove_page(o)}});n.watch("slug",function(o){this.navigation_current.set_title(o)}.bind(this));n.title_field().watch("value",function(o){this.set_browser_title(o)}.bind(this));this.children_node=l}},set_mode:function(k){this.set("mode",k);this.mode_switch.text(this.opposite_mode(k))},toggle_modes:function(){this.set_mode(this.opposite_mode(this.get("mode")))},opposite_mode:function(k){if(k==="preview"){return"edit"}else{if(k==="edit"){return"preview"}}},publishing_started:function(){this.publish_button.publishing_started()},set_browser_title:function(k){document.title=c.site_domain+" | Editing: '"+k+"'"},location_changed:function(k){this.set_browser_title(k.title);this.set("location",k);this.update_navigation()},update_navigation:function(){var l=[];var u=this.get("location");var s=this.location;var w=u.ancestors;var t,q=false,m,k,o;if(w.length===0){t=u;q=true}else{t=w.shift()}m=new j(t);l.push(m);for(var p=0,v=w.length;p<v;p++){var r=w[p];var n=new a(r);l.push(n)}if(!q){o=new e(u);l.push(o)}else{o=m}d("li:gt(0)",s).remove();var k;if(u.children.length>0){}for(var p=0,v=l.length;p<v;p++){var n=l[p];s.append(n.element())}this.navigation_current=o;this.page_loaded=function(x){}}});return f})(jQuery,Spontaneous);
74
- Spontaneous.FieldPreview=(function(b,a){var d=a.Dom;var c=new JS.Class({initialize:function(f,e){this.view=f;this.wrap_id=e},depth_class:function(){return"depth-"+this.view.depth()},has_fields:function(){return this.view.has_fields()},panel:function(){var e=d.div([d.id(this.wrap_id),"fields-preview",this.depth_class()]);e.append(this.fields_panel(this.view.text_fields(),"text"));e.append(this.fields_panel(this.view.image_fields(),"image",true));if(this.view.mouseover){e.mouseover(this.view.mouseover.bind(this.view))}if(this.view.mouseout){e.mouseout(this.view.mouseout.bind(this.view))}e.click(function(){this.view.edit(this.field_to_edit)}.bind(this));return e},fields_panel:function(e,g,h){var i=d.ul(".fields-preview-"+g),f=this;if(e.length===0){i.addClass("empty")}b.each(e,function(l,n){var j=d.li();var k=d.div(".name").text(n.title);var m=d.div(".value").html(n.preview());j.click(function(){f.field_to_edit=n});n.activate(m);if(!h){n.watch("value",function(p,o){b(this).html(p.preview())}.bind(m,n))}j.append(k).append(m);i.append(j)});return i}});return c})(jQuery,Spontaneous);
75
- Spontaneous.BoxContainer=(function(c,b){var d=b.Dom;var a=new JS.Class(b.Views.View,{initialize:function(f,e){this.callSuper(f);this.wrap_id=e;this.box_content_container=d.div(".slot-content-wrapper")},panel:function(){var f=d.div([d.id(this.wrap_id),"slots"]);f.append(this.tab_bar());f.append(this.box_content_container);var e=Spontaneous.State.active_box(this.content);this.activate_id(e);return f},tab_bar:function(){if(this.boxes().length===0){return""}if(!this._tab_bar){var l=d.ul(".slot-tabs");for(var g=0,f=this.boxes(),h=f.length;g<h;g++){var k=f[g];var e=d.li();e.text(k.name());e.append(d.span(".down"));var j=function(i){this.activate(i,true)}.bind(this,g);e.click(j);l.append(e)}this._tab_bar=l}return this._tab_bar},activate:function(g,e){var f=this.boxes()[g];if(f===this._active_box){return}c("li",this.tab_bar()).removeClass("active");c("li:nth-child("+(g+1)+")",this.tab_bar()).addClass("active");f.activate();this._active_box=f;if(e){Spontaneous.State.activate_box(this.content,f);this.content.set("box",f)}},activate_id:function(j){if(j){for(var f=0,e=this.boxes(),h=e.length;f<h;f++){var g=e[f];if(e[f].id()===j){this.activate(f);return}}}this.activate(0)},boxes:function(){if(!this._boxes){var h=[],g=this.box_content_container;var e=function(f,j){h.push(new Spontaneous.Views.BoxView(j,g))}.bind(this);c.each(this.content.boxes(),e);this._boxes=h}return this._boxes}});return a})(jQuery,Spontaneous);
76
- Spontaneous.Progress=(function(c,b){var a=function(g,e,d){var h={spinner_fg_color:"#000000",spinner_bg_color:null,progress_fg_color:"#000000",progress_bg_color:false,spinner_alpha:1,progress_alpha:1,period:550,segments:12,segment_length:0.47,segment_width:0.6,trail_length:1.1,rounded:true,shaded:false,};if(typeof d=="undefined"){d={}}var f={};for(k in h){f[k]=h[k]}for(k in d){f[k]=d[k]}return{container:g,size:e,_canvas:false,defaults:h,options:f,_color:{},init:function(){var i=this.canvas()},context:function(){return this.canvas().getContext("2d")},colour:function(j,i,m){var n=j+"_"+i+"_color";if(typeof m=="undefined"){m=this.options[j+"_alpha"]}if(!this._color[n]){this._color[n]=this._parse_color(this.options[n])}return"rgba("+this._color[n][0]+", "+this._color[n][1]+", "+this._color[n][2]+", "+m+")"},canvas:function(){var j;if(this.container&&!this._canvas){j=document.createElement("canvas");j.width=this.size;j.height=this.size;var i=null;if(typeof this.container=="string"){this.container=document.getElementById(this.container)}this.container.appendChild(j);this._canvas=j}return this._canvas},_percent:false,update:function(n){this._indeterminate=false;n=Math.max(0.1,parseFloat(n));this._percent=n;var m=this.context();var j=this.size/2;var i=this.size/2;m.clearRect(0,0,this.size,this.size);var o;if(this.options.progress_bg_color){o=this.colour("progress","bg");m.beginPath();m.moveTo(i,i);m.arc(i,i,j,Math.PI*-0.5,Math.PI*2,false);m.closePath();m.fillStyle=o;m.fill()}o=this.colour("progress","fg");var l=(parseFloat(n)/100);m.beginPath();m.moveTo(i,i);m.arc(i,i,j,Math.PI*-0.5,Math.PI*(-0.5+2*l),false);m.lineTo(i,i);m.closePath();m.fillStyle=o;m.fill()},_redraw:function(){if(this._percent){this.update(this._percent)}},_indeterminate:false,_indeterminate_interval:false,indeterminate:function(){if(this._indeterminate){return}this._indeterminate=true;var j=this;var i=function(){j._update_indeterminate()};this._draw_indeterminate();this._indeterminate_interval=setInterval(i,parseFloat(this.options.period)/this.options.segments)},spin:function(){this.indeterminate()},start:function(){this.indeterminate()},_spin_angle:0,_spin_increment:function(){return 2/this.options.segments},_update_indeterminate:function(){if(!this._indeterminate){this.pause();return}this._spin_angle+=this._spin_increment();this._draw_indeterminate()},_draw_indeterminate:function(){var u=this.context();var s=this._radius();var j=this._center();var o=this._spin_increment();u.clearRect(0,0,this.size,this.size);var n=s-(s*this.options.segment_length);var l=((2*Math.PI*n)/this.options.segments)*this.options.segment_width;var m=s;if(this.options.rounded){m-=l/2}for(var r=0;r<this.options.segments;r++){var q=(o*r);var t=Math.PI*(1-this._spin_angle+q);u.beginPath();if(this.options.rounded){this._draw_rounded(u,j,n,m,t,l)}else{this._draw_square(u,j,n,m,t,l)}u.closePath();u.fillStyle=this._fill(u,r);u.fill()}},_draw_rounded:function(t,o,n,m,r,l){var q=Math.sin(r);var s=Math.cos(r);var j=Math.PI-r;var i=2*Math.PI-r;t.arc(o+n*q,o+n*s,l/2,j,i,false);t.arc(o+m*q,o+m*s,l/2,i,j,false)},_draw_square:function(u,C,x,w,D,t){var i=Math.sin(D);var m=Math.cos(D);var s=(t/2)*m;var r=(t/2)*i;var B=C+x*i;var q=C+x*m;var A=C+x*i+s;var o=C+x*m-r;var z=C+w*i+s;var n=C+w*m-r;var y=C+w*i-s;var l=C+w*m+r;var v=C+x*i-s;var j=C+x*m+r;u.moveTo(A,o);u.lineTo(z,n);u.lineTo(y,l);u.lineTo(v,j)},_fill:function(j,l){if(this.options.shaded){return this._shaded_fill(j,l)}else{return this._solid_fill(j,l)}},_solid_fill:function(j,l){return this.colour("spinner","fg",this._alpha_for_segment(l))},_shaded_fill:function(j,l){var n=this._center();var m=j.createRadialGradient(n,n,0,n,n,this._radius());m.addColorStop(0.3,this.colour("spinner","fg",0));m.addColorStop(1,this.colour("spinner","fg",this._alpha_for_segment(l)));return m},_alpha_for_segment:function(l){var i=(l/this.options.segments);var j=Math.max(0,this.options.spinner_alpha*((1/(5*((i/this.options.trail_length)+(1/5.8))))-0.168));return j},_radius:function(){return this.size/2},_center:function(){return this._radius()},_parse_color:function(m){if(m.charAt(0)=="#"){m=m.substr(1,6)}m=m.replace(/ /g,"");m=m.toLowerCase();var n=[];if(m.length==3){for(var l=0;l<3;l++){n[n.length]=m.charAt(l)+m.charAt(l)}}else{for(var l=0;l<3;l++){n[n.length]=m.substr(l*2,2)}}var j=[];for(var l=0;l<n.length;l++){j[l]=parseInt(n[l],16)}return j},pause:function(){this._indeterminate=false;clearInterval(this._indeterminate_interval)},stop:function(){this.pause();this.clear()},clear:function(){this.context().clearRect(0,0,this.size,this.size)},_disappear_interval:null,disappear:function(m){if(typeof m==="undefined"){m=1000}var n=this;var l=this.options.spinner_alpha;var j=(new Date()).valueOf()+m;var i=function(){if(n.options.spinner_alpha<=0){clearInterval(n._disappear_interval);n.stop();n.options.spinner_alpha=l}else{var o=(new Date()).valueOf(),p=(j-o)/m;n.options.spinner_alpha=l*p}};this._disappear_interval=setInterval(i,50)},set_options:function(i){this.options=i;this._color={};this._spin_angle=0;if(this._indeterminate){this.stop();this.indeterminate()}else{this._redraw()}}}};return a})(jQuery,Spontaneous);
77
- Spontaneous.StatusBar=(function(c,b){var d=b.Dom;var a={showing:false,init:function(){this.container=d.div("#status-bar").hide();b.UploadManager.init(this);return this.container},hide:function(){if(!this.showing){return}this.showing=false;var e=200;window.setTimeout(function(){this.container.animate({height:0},e,function(){}.bind(this))}.bind(this),500)},show:function(){if(this.showing){return}this.showing=true;var f=200,e=32;this.container.css("height",0+"px");this.container.show();this.container.animate({height:e},f)},progress_container:function(){if(!this._progress_container){var e=d.div("#progress-container");this.container.append(e);this._progress_container=e}return this._progress_container}};return a})(jQuery,Spontaneous);
78
- Spontaneous.Upload=(function(c,b){var d=(new Date()).valueOf();var a=new JS.Class({initialize:function(g,h,f,e){this.manager=g;this.field_name=h.schema_id();this.uid=h.uid();this.target=h;this.target_id=h.id();if(h.version){this.target_version=h.version()}this._position=0;this.failure_count=0;this.file=f;this.insert_position=e;console.log("upload insert at",e);this.name=this.file.fileName;this._total=this.file.size;this.upload_id=d++},position:function(){return Math.min(this._total,this._position)},total:function(){return this._total},start:function(){var e=new FormData();e.append("file",this.file);e.append("field",this.field_name);if(this.target_version){e.append("version",this.target_version)}this.post("/file/replace/"+this.target_id,e)},post:function(e,f){this.xhr=new XMLHttpRequest();this.upload=this.xhr.upload;this.xhr.open("POST",this.namespaced_path(e),true);this.upload.onprogress=this.onprogress.bind(this);this.upload.onload=this.onload.bind(this);this.upload.onloadend=this.onloadend.bind(this);this.upload.onerror=this.onerror.bind(this);this.xhr.onreadystatechange=this.onreadystatechange.bind(this);this.started=(new Date()).valueOf();this.xhr.send(f)},namespaced_path:function(e){return b.Ajax.request_url(e,true)},onprogress:function(f){var e=f.position;this._position=e;this.time=(new Date()).valueOf()-this.started;this.manager.upload_progress(this)},onload:function(e){},onloadend:function(e){},onreadystatechange:function(f){var g=f.currentTarget;if(g.readyState==4){if(g.status===200){if(!this.complete){console.log(g);var e=JSON.parse(g.responseText);this.manager.upload_complete(this,e);this.complete=true}}else{if(g.status===409){this.manager.upload_conflict(this,f)}}}},onerror:function(e){this.failure_count++;this.manager.upload_failed(this)}});return a}(jQuery,Spontaneous));
79
- Spontaneous.ShardedUpload=(function(d,b){var f=b.Dom;var e=(new Date()).valueOf();var a=new JS.Class({initialize:function(i,h,g){this.uploader=i;this.index=h;this.blob=g;this.progress=0;this.size=this.blob.size},start:function(){var g=new FileReader();g.onload=function(h){this.compute_hash(g.result)}.bind(this);g.onerror=function(h){console.error("error",h)};g.readAsArrayBuffer(this.blob)},compute_hash:function(i){var g=new Uint8Array(i);var h=Crypto.SHA1(g);this.hash=h;this.begin_upload();this.failure_count=0},remote_path:function(){return b.Ajax.request_url(["shard",this.hash].join("/"),true)},begin_upload:function(){b.Ajax.get(["/shard",this.hash].join("/"),this.status_complete.bind(this))},status_complete:function(h,g,i){if(g==="success"){this.complete()}else{this.upload()}},retry:function(){if(this.hash){this.upload()}else{this.start()}},upload:function(){var h=new FormData(),i=b.Ajax.request_url(["/shard",this.hash].join("/"),true);h.append("file",this.blob);var j=new XMLHttpRequest(),g=j.upload;j.open("POST",i,true);g.onprogress=this.onprogress.bind(this);g.onload=this.onload.bind(this);g.onloadend=this.onloadend.bind(this);g.onerror=this.onerror.bind(this);j.onreadystatechange=this.onreadystatechange.bind(this);this.started=(new Date()).valueOf();j.send(h)},complete:function(){this.blob=null;this.uploader.shard_complete(this)},failed:function(){this.failure_count+=1;this.uploader.shard_failed(this)},onprogress:function(h){var g=h.position;this.progress=g;this.time=(new Date()).valueOf()-this.started;this.uploader.upload_progress(this)},onload:function(g){},onloadend:function(g){console.error("Shard#onloadend: shard upload failed",g)},onreadystatechange:function(g){var h=g.currentTarget;if(h.readyState==4){if(h.status===200){this.complete()}else{this.failed()}}},onerror:function(g){console.error("Shard#onerror: shard upload error",g)}});var c=new JS.Class(Spontaneous.Upload,{slice_size:524288,initialize:function(h,i,g){this.callSuper();this.completed=[];this.failed=[];this.current=null},start:function(){this.started=(new Date()).valueOf();this.start_with_index(0)},start_with_index:function(g){if(g<this.shard_count()){var h=new a(this,g,this.slice(g));this.current=h;h.start()}else{if(this.failed.length===0){this.finalize()}else{var h=this.failed.pop();console.warn("retrying failed shard",h);this.current=h;h.retry()}}},finalize:function(){var g=new FormData();g.append("field",this.field_name);g.append("version",this.target_version);g.append("shards",this.hashes().join(","));g.append("mime_type",this.mime_type());g.append("filename",this.file.fileName);this.post(this.path(),g)},path:function(){return["/shard/replace",this.target_id].join("/")},hashes:function(){var g=[];for(var h=0,j=this.completed.length;h<j;h++){g.push(this.completed[h].hash)}return g},upload_progress:function(g){this.time=(new Date()).valueOf()-this.started;this.manager.upload_progress(this)},position:function(){var g=0;for(var h=0,k=this.completed,j=k.length;h<j;h++){if(k[h]){g+=k[h].size}}g+=this.current.progress;g=Math.min(g,this.total());return g},mime_type:function(){return this.file.type},total:function(){return this.file.size},shard_complete:function(g){this.manager.upload_progress(this);this.completed[g.index]=g;this.start_with_index(g.index+1)},shard_failed:function(g){console.error("shard failed",g,g.index);this.failed.push(g);this.start_with_index(g.index+1)},shard_count:function(){return Math.ceil(this.file.size/this.slice_size)},slice:function(g){return this.file.slice(g*this.slice_size,(g+1)*this.slice_size)}});c.extend({supported:function(){return((typeof window.File.prototype.slice==="function")&&(typeof window.FileReader!=="undefined")&&(typeof window.Uint8Array!=="undefined"))}});return c}(jQuery,Spontaneous));
80
- Spontaneous.UploadManager=(function(g,c){var h=c.Dom;var b=c.Upload;var a=new JS.Class(b,{start:function(){var i=new FormData();i.append("file",this.file);this.post(["/file/wrap",this.target_id].join("/"),i)}});var e=new JS.Class(c.ShardedUpload,{path:function(){return["/shard/wrap",this.target_id].join("/")},});var d=new JS.Class(b,{initialize:function(j,k,l,i){this.callSuper(j,k,l);this.form_data=this.file;this._total=i;this.name="Saving..."},start:function(){this.post(this.target.save_path(),this.form_data)}});var f={init:function(i){this.status_bar=i;this.pending=[];this.completed=[];this.failed=[];this.current=null;this.updater=null;this.total_time=0;this.total_data=0;this.targets={}},add:function(j,i){this.pending.push(i);this.register(j)},register:function(i){this.targets[i.uid()]=i},unregister:function(i){delete this.targets[i.uid()]},replace:function(k,i){var j=b;if(c.ShardedUpload.supported()){console.log("Using sharded uploader");j=c.ShardedUpload}this.add(k,new j(this,k,i));if(!this.current){this.next()}},wrap:function(q,p,j){for(var n=0,o=p.length;n<o;n++){var m=p[n],k,l=a;if(c.ShardedUpload.supported()){console.log("Using sharded uploader");l=e}k=new l(this,q,m,j);this.add(q,k)}if(!this.current){this.next()}},form:function(k,l,i){var j=new d(this,k,l,i);this.add(k,j);if(!this.current){this.next()}},next:function(){if(this.current){return}if(this.pending.length===0){if(this.failed.length===0){this.finished()}else{var j=this.failed.pop(),i=Math.pow(2,j.failure_count);console.log("UploadManager.next","scheduling re-try of failed upload after",i,"seconds");this.pending.push(j);window.setTimeout(function(){console.log("UploadManager.next","re-trying failed upload");this.next()}.bind(this),i*1000)}return}this.init_progress_bar();this.current=this.pending.shift();this.bars.name.text(this.current.name);this.current.start()},finished:function(){this.completed=[];this.status_bar.hide()},init_progress_bar:function(){this.status_bar.show();if(this.progress_showing){return}var n=this.status_bar.progress_container();var l=h.div("#progress-bars");var m=h.div("#progress-total.bar");var i=h.div("#progress-individual.bar");var j=h.div("#progress-name");var k=h.div("#progress-stats");l.append(i);l.append(m);n.append(l);n.append(j).append(k);this.bars={total:m,individual:i,name:j,stats:k};this.progress_showing=true},data_total:function(){var l=0;for(var j=0,k=this.completed.length;j<k;j++){l+=this.completed[j].total()}for(var j=0,k=this.pending.length;j<k;j++){l+=this.pending[j].total()}if(this.current){l+=this.current.total()}return l},data_completed:function(){var l=0;for(var j=0,k=this.completed.length;j<k;j++){l+=this.completed[j].total()}if(this.current){l+=this.current.position()}return l},update_progress_bars:function(){var j=this.data_total(),i=this.data_completed();i=Math.min(j,i);this.set_bar_length("total",i,j);if(this.current){this.set_bar_length("individual",this.current.position,this.current.total);this.bars.stats.text([this.rate(),"Kb/s",this.time_estimate()].join(" "))}else{this.set_bar_length("individual",0,0)}},rate:function(){var i=this.total_time,j=this.total_data;if(this.current){i+=this.current.time;j+=this.current.position()}return Math.round(((j/1024)/(i/1000)*10)/10)},time_estimate:function(){var i=this.data_total()-this.data_completed();var j=(i/1024)/this.rate();return(Math.round(j))+"s"},set_bar_length:function(m,i,l){var k=this.bars[m],j=(i/l)*100;k.css("width",j+"%")},upload_progress:function(i){if(i!==this.current){console.warn("UploadManager#upload_progress","completed upload does not match current")}var j=this.targets[i.uid];if(j){j.upload_progress(i.position(),i.total())}this.update_progress_bars()},upload_complete:function(j,i){if(j!==this.current){console.warn("UploadManager#upload_complete","completed upload does not match current")}this.completed.push(this.current);this.total_time+=this.current.time;this.total_data+=this.current.position();var k=this.targets[j.uid];if(k){k.upload_complete(i)}this.current=null;this.next()},upload_failed:function(i,j){if(i!==this.current){console.warn("UploadManager#upload_complete","completed upload does not match current")}this.failed.push(this.current);var k=this.targets[i.uid];if(k){k.upload_failed(j)}this.current=null;console.error("UploadManager#upload_failed",i,this.failed);this.next()},upload_conflict:function(i,j){if(i!==this.current){console.warn("UploadManager#upload_complete","completed upload does not match current")}var k=this.targets[i.uid];if(k){k.upload_conflict(g.parseJSON(j.currentTarget.response))}this.current=null;console.error("UploadManager#upload_conflict",i,j);this.next()},FormUpload:d,WrapUpload:a};return f}(jQuery,Spontaneous));
81
- Spontaneous.Dialogue=(function(e,d){var f=d.Dom;var c=new JS.Class({initialize:function(g,h,i){this.label=g;this.action=h;this.is_default=i;this.disabled=false},html:function(){var h=f.a(this.css_class()).html(this.label);if(typeof this.action==="function"){var g=this;h.click(function(){if(!g.disabled){g.action()}return false})}this.button=h;return h},css_class:function(){return["button",(this.is_default?"default":""),this.label.toLowerCase().split(" ")[0]].join(" ")},disable:function(){this.set_disabled(true)},enable:function(){this.set_disabled(false)},set_disabled:function(g){this.disabled=g;this.button.removeClass("disabled");if(this.disabled){this.button.addClass("disabled")}}});var a=new JS.Class(c,{initialize:function(g,h){this.callSuper(g+' <span class="key-combo">(Esc)</span>',function(){Spontaneous.Dialogue.cancel()},h)},css_class:function(){return this.callSuper().replace(" cancel","")+" cancel"}});var b=new JS.Class({open:function(){Spontaneous.Dialogue.open(this)},close:function(){Spontaneous.Dialogue.close(this)},width:function(){return"50%"},title:function(){return"Dialogue"},class_name:function(){return""},buttons:function(){},cleanup:function(){},cancel_button:function(){return new a(this.cancel_label())},cancel_label:function(){return"Cancel"},disable_button:function(g){Spontaneous.Dialogue.disable_button(g)}});b.extend({_overlay:false,_open:false,_z_index:1000,_instance:false,open:function(h){if(this._open||!h){return}this._instance=h;e("body").css("overflow","hidden");this.overlay().fadeIn(200);var l=this.container(),i=this._actions,g;var j=h.buttons(),k={};i.empty().append(f.div(".spacer"));g=h.cancel_button();if(g){k.cancel=g;k[h.cancel_label().toLowerCase()]=g;i.append(g.html());e(document).bind("keydown.dialogue",function(m){if(m.keyCode===27){this.cancel()}}.bind(this))}if(j){e.each(j,function(m,p){var n,o=false;if(typeof p==="function"){n=p}else{if(e.isArray(p)){n=p[0];o=p[1]}else{n=p.action;o=p.is_default}}g=new c(m,n,o);i.append(g.html());k[m.toLowerCase()]=g})}this.button_map=k;this._body.empty().append(h.body());l.fadeIn(200);this._open=true},disable_button:function(g){var h=this.button_map[g.toLowerCase()];h.disable()},close:function(){if(!this._instance||!this._open){return}this._instance.cleanup();this.container().remove();this.overlay().fadeOut(200,function(){e("body").css("overflow","auto")});this._instance=this._container=this._open=false;e(document).unbind("keydown.dialogue")},cancel:function(){return this.close()},container:function(){if(!this._container){var h=this._instance;var k=f.div("#dialogue-wrap").css("z-index",this.z_index()).hide();var j=f.div("#dialogue-outer").css("width",h.width()).addClass(h.class_name());var n=f.div("#dialogue-control-wrap");var i=f.div("#dialogue-controls");var m=f.div(".dialogue-actions");var g=f.div("#dialogue-body");var l=f.div("#dialogue-title").append(h.title());i.append(m);n.append(i);j.append(l);j.append(g);j.append(n);k.append(j);e("#content").append(k);this._actions=m;this._title=l;this._container=k;this._body=g}return this._container},overlay:function(){if(!this._overlay){var g=f.div("#dialogue-overlay").css("z-index",this.z_index()).hide();e("#content").append(g);this._overlay=g}return this._overlay},z_index:function(){return ++this._z_index}});return b})(jQuery,Spontaneous);
82
- Spontaneous.EditPanel=(function(d,b){var e=b.Dom,a=Spontaneous.Dialogue;var c=new JS.Class(a,{initialize:function(f){this.parent_view=f},buttons:function(){var f="Save ("+((window.navigator.platform.indexOf("Mac")===0)?"Cmd":"Ctrl")+"+s)",g={};g[f]=this.save.bind(this);return g},id:function(){return this.parent_view.id()},schema_id:function(){},uid:function(){return this.parent_view.uid()+"!editing"},save:function(){var f=this.parent_view.field_list();b.Ajax.test_field_versions(this.parent_view,f,this.upload_values.bind(this),this.upload_conflict.bind(this));return false},upload_values:function(){var f=this.form.serializeArray();var h=new FormData();var g=0;d.each(f,function(k,j){h.append(j.name,j.value);g+=(j.name.length+j.value.length)});d("> *",this.form).animate({opacity:0.3},400);if(f.length>0){Spontaneous.UploadManager.form(this,h,g)}else{this.close()}d.each(this.parent_view.file_fields(),function(){this.save()})},save_path:function(){return this.parent_view.save_path()},upload_progress:function(f,g){},upload_complete:function(f){this.parent_view.save_complete(f);this.close()},upload_failed:function(f){},upload_conflict:function(g){console.log("conflicted_fields",g);var f=new b.ConflictedFieldDialogue(this,g);f.open()},conflicts_resolved:function(h){console.log("conflicts resolved",h);var g=this.parent_view.field_list(),f={};for(var j=0,k=h.length;j<k;j++){var l=h[j];f[l.field.schema_id()]=l}for(var j=0,k=g.length;j<k;j++){var m=g[j],l=f[m.schema_id()];if(l){console.log(">>> conflicts_resolved",m,l.version);m.set_edited_value(l.value);m.set_version(l.version)}}},cancel:function(){var f=this.parent_view.field_list();for(var g=0,h=f.length;g<h;g++){f[g].cancel_edit()}this.close();return false},close:function(){b.Popover.close();var f=this.parent_view.field_list();for(var g=0,h=f.length;g<h;g++){f[g].close_edit()}d(":input",this.form).add(document).unbind("keydown.savedialog");if(typeof this.parent_view.edit_closed==="function"){this.parent_view.edit_closed()}},view:function(){var g=this.save.bind(this);var j=this.cancel.bind(this);var l=function(y){var x=e.a(".button.save").html(e.cmd_key_label("Save","s")).click(g);var w=e.a(".button.cancel").html(e.key_label("Cancel","Esc")).click(j);var z=e.div(".indent");var v=e.div(".buttons").append(w).append(x);var i=e.div(".editing-toolbar").append(z).append(v);if(y){i.addClass(y)}return i};var h=e.form([".editing-panel",this.parent_view.depth_class()],{enctype:"multipart/form-data","accept-charset":"UTF-8",method:"post"});var q=l();var u=e.div(".editing-fields");var o=e.div(".field-group.text");var m=e.div(".field-group.image");var f=this.parent_view.text_fields();var n=e.input({type:"submit"});var t=this;h.append(q);for(var k=0,s=f.length;k<s;k++){var p=f[k];o.append(this.field_edit(p))}if(f.length>0){u.append(o)}var r=this.parent_view.image_fields();for(var k=0,s=r.length;k<s;k++){var p=r[k];m.append(this.field_edit(p).click(function(){t.field_focus(this)}))}if(r.length>0){u.append(m)}u.append(n);h.append(u);h.append(e.div(".clear"));h.append(l("bottom"));d("input, textarea",h).focus(function(){t.field_focus(this)}).blur(function(){t.field_blur(this)});h.submit(this.save.bind(this));this.form=h;d(":input",this.form).keydown(function(i){if(i.keyCode===9){t.tab_to_next(this,i.shiftKey);return false}}).add(document).bind("keydown.savedialog",function(w){var v=83,i=27;if((w.ctrlKey||w.metaKey)&&w.keyCode===v){this.save();return false}else{if(w.keyCode===i){j()}}}.bind(this));return this.form},tab_to_next:function(n,f){var k=d(n).data("field"),h=this.parent_view.text_fields(),l=0,p,g,m=f?-1:1;for(var j=0,o=h.length;j<o;j++){if(h[j]===k){l=j;break}}p=(l+m)%h.length;if(p===-1){p=h.length-1}g=h[p];g.input().focus()},on_show:function(f){if(!f||!(f.focus)||!f.accepts_focus){f=null}var f=f||this.parent_view.text_fields()[0];if(f){f.focus()}},field_focus:function(f){var g=d(f).data("field");if(g===this.active_field){return}if(g){this.active_field=g;this.active_field.on_focus()}},field_blur:function(f){var g=d(f).data("field");if(g){g.on_blur()}if(g===this.active_field){this.active_field=null}},field_from_input:function(l){var j=this.parent_view.text_fields(),h=false;for(var f=0,g=j.length;f<g;f++){var k=j[f];if(k.input()[0]===l){return k}}},field_edit:function(i){var j=e.div(".field");var f=e.label(".name",{"for":i.css_id()}).html(i.label());if(i.type.comment){var l=e.span(".comment").text("("+i.type.comment+")");f.append(l)}j.append(f);var h=i.toolbar();if(h){j.append(e.div(".toolbar").html(h))}var g=i.edit();j.append(e.div(".value").append(g));var k=i.footer();if(k){j.append(e.div(".footer").html(k))}return j}});return c})(jQuery,Spontaneous);
83
- Spontaneous.AddHomeDialogue=(function(d,c){var e=c.Dom,b=Spontaneous.Dialogue;var a=new JS.Class(b,{initialize:function(f){this.types=f},title:function(){return"Create site home page"},width:function(){return"50%"},buttons:function(){var f={};f.Create=this.create_home.bind(this);return f},uid:function(){return this.content.uid()+"!editing"},create_home:function(){if(this.type){c.Ajax.post("/root",{type:this.type.schema_id},this.home_created.bind(this))}},home_created:function(f){window.location.href=c.Ajax.namespace},select_type:function(f){this.type=f},body:function(){var g=e.div("#create-home-dialogue"),j=e.div(),f=e.p(".instructions"),i=this.types,h=this;f.html('You don\'t have a home page. Please choose a type below and hit <span class="button">Create</span> to add one');d.each(i,function(k,l){if(l.is_page()){var m=e.div(".type").text(l.title).click(function(){d(".type",j).removeClass("selected");h.select_type(l);d(this).addClass("selected")});j.append(m)}});g.append(f,j);return g},cancel_button:function(){return false},});return a})(jQuery,Spontaneous);
84
- Spontaneous.PageBrowser=(function(c,a){var d=a.Dom;var b=new JS.Class(Spontaneous.PopoverView,{initialize:function(e){e=String(e||"");if(/^\//.test(e)){this.origin=e||"/";this.selected=this.origin}else{this.selected=false;this.origin="/"}this.page_list=this.origin_list();this.ancestor_list=this.origin_ancestors()},origin_list:function(){return function(e){return e.generation}},children_list:function(){return function(e){return e.children}},origin_ancestors:function(){return function(e){return e.ancestors}},children_ancestors:function(){return function(e){return e.ancestors.concat(e)}},get_page_list:function(){var e;if(typeof this.origin==="string"){e="/location"+this.origin}else{e="/map/"+this.origin.id}a.Ajax.get(e,this.page_list_loaded.bind(this))},view:function(){var f=d.div(".page-browser"),e=d.div(".page-list");ancestors=d.div(".page-ancestors");f.append(ancestors).append(e);this.wrapper=f;this.table=e;this.ancestors=ancestors;this.get_page_list();return f},page_list_loaded:function(e,f){if(f==="success"){this.table.empty();this.location=e;this.manager.page_list_loaded(this);var k=this.page_list(this.location),r=this.table;for(var j=0,p=k.length;j<p;j++){var m=k[j];r.append(this.get_entry(m))}this.ancestors.empty();var h=this,l=d.ul(),s=this.ancestor_list(this.location);this.depth=s.length;var q=function(g){return function(i){h.ancestor_selected(g);return false}};for(var j=0,p=s.length;j<p;j++){var n=s[j],o=d.li().append(d.a().text(n.title)).append(d.span().text("/")).click(q(n));l.append(o)}if(s.length===0){l.append(d.li().append(d.a().text("Choose a page...")))}this.ancestors.append(l)}},get_entry:function(i){var e=this,g=function(l){return function(){e.page_selected(l);c(this).addClass("active")}};var h=function(){e.next_level(i);return false};var k=d.div(".page").click(g(i)),j=d.a().text(i.title);if(i.children>0){var f=d.span();f.click(h);k.append(f)}k.append(j);if(this.selected&&(i.path===this.selected)){k.addClass("active")}return k},ancestor_selected:function(e){this.page_list=this.origin_list();this.ancestor_list=this.origin_ancestors();this.origin=e;this.get_page_list()},next_level:function(e){this.page_list=this.children_list();this.ancestor_list=this.children_ancestors();this.origin=e;this.get_page_list()},page_selected:function(f){var e=this.table;c(".page",e).removeClass("active");this.selected=f.path;this.manager.page_selected(f)},title:function(){return"Choose Page"},width:function(){return 400},});return b})(jQuery,Spontaneous);
85
- Spontaneous.AddAliasDialogue=(function(d,b){var e=b.Dom,a=Spontaneous.Dialogue;var c=new JS.Class(a,{initialize:function(h,g,f){this.box_view=h;this.box_view.bind("entry_added",this.alias_added.bind(this));this.type=g;this.insert_position=f},title:function(){return"Add alias to &ldquo;"+this.box_view.name()+"&rdquo;"},buttons:function(){var f={};f.Add=this.add_alias.bind(this);return f},uid:function(){return this.content.uid()+"!add-alias"},add_alias:function(){if(this.target){this.box_view.add_alias(this.target.id,this.type,this.insert_position)}},alias_added:function(){this.close()},select_target:function(f){this.target=f},box_owner:function(){return this.box_view.box.container},box:function(){return this.box_view.box},body:function(){var g=e.div("#add-alias-dialogue"),i=e.div(),f=e.p(".instructions"),h=this;f.html("Choose a target:");g.append(f,i);Spontaneous.Ajax.get(["/targets",this.type.schema_id,this.box().id()].join("/"),this.targets_loaded.bind(this));this._outer=i;return g},targets_loaded:function(f){var h=this._outer,g=this;this.targets=f;d.each(f,function(j,k){var l=e.div(".type").html(k.title).click(function(){d(".type",h).removeClass("selected");g.select_target(k);d(this).addClass("selected")});h.append(l)})}});return c})(jQuery,Spontaneous);
86
- Spontaneous.ConflictedFieldDialogue=(function(c,b){var e=b.Dom,a=Spontaneous.Dialogue;var d=new JS.Class(a,{initialize:function(f,g){this.parent_view=f;this.conflicted_fields=g;this.active_conflict=0;this.wrap=e.div("#conflicted-fields-dialogue")},title:function(){return"Conflicted Fields"},width:function(){return"90%"},buttons:function(){var f={};f.Use=this.conflict_resolved.bind(this);return f},resolve_value:function(g,f){g.value=f},conflict_resolved:function(){var f=this.current_conflict();if(f&&f.value){this.show_next_conflict()}},uid:function(){return this.content.uid()+"!editing"},create_home:function(){if(this.type){b.Ajax.post("/root",{type:this.type.schema_id},this.home_created.bind(this))}},home_created:function(f){window.location.href=b.Ajax.namespace},select_type:function(f){this.type=f},current_conflict:function(){return this.conflicted_fields[this.active_conflict]},next_conflict:function(){this.active_conflict+=1;return this.current_conflict()},conflict_panel:function(h){h.empty();var i=this.current_conflict(),j=i.field,f=e.p(".instructions");f.html("The field '"+j.label()+"' has been modified by another person. Please select which version you want to use.");var g=j.conflict_view(this,i);h.append(f);h.append(g.panel());this.conflict_view=g;return h},body:function(){panel=this.conflict_panel(this.wrap);return this.wrap},show_next_conflict:function(){var f=this.next_conflict();if(f){this.conflict_panel(this.wrap)}else{console.log("closing conflict view",this.conflicted_fields);this.parent_view.conflicts_resolved(this.conflicted_fields);this.close()}},cancel_button:function(){return false},});return d})(jQuery,Spontaneous);
87
- Spontaneous.Publishing=(function(f,d){var g=d.Dom,a=Spontaneous.Dialogue;var c=new JS.Class(a,{initialize:function(h){this.change_sets=[]},width:function(){return"90%"},title:function(){return"Publish Changes"},class_name:function(){return"publishing"},body:function(){var h=g.div("#publishing-dialogue").text("publishing");this.wrapper=h;Spontaneous.Ajax.get(["/publish","changes"].join("/"),this.change_list_loaded.bind(this));return h},buttons:function(){btns={};btns.Publish=this.publish.bind(this);return btns},publish:function(){var l=[],k=this.changes_to_publish();for(var h=0,j=k.length;h<j;h++){l.push(k[h].id)}if(l.length>0){Spontaneous.Ajax.post(["/publish","publish"].join("/"),{change_set_ids:l},this.publish_requested.bind(this))}else{}},publish_requested:function(){Spontaneous.TopBar.publishing_started();this.close()},change_list_loaded:function(k){var r=this.wrapper,v=this;r.empty();var q=g.div("#changes.change-list"),u=g.div("#to-publish.change-list");r.append(q,u);if(k.length===0){var o=g.p(".publish-up-to-date").text("The site is up to date");r.append(o);this.disable_button("Publish")}else{var x=g.a(".button").text("Publish All").click(function(){this.set_publish_all(true)}.bind(this));var h=g.a(".button").text("Clear All").click(function(){this.set_publish_all(false)}.bind(this));var j=g.div(".actions").append(g.div().text("Modified pages")).append(x);var p=g.div(".actions").append(g.div().text("Publish pages")).append(h);var t=g.div(".change-sets"),m=g.div(".change-sets");q.append(j,t);u.append(p,m);for(var l=0,s=k.length;l<s;l++){var n=new e(l,this,k[l]);this.change_sets.push(n);t.append(n.panel())}m.append(g.div(".instructions").text("Add pages to publish from the list on the left"));this.changed_entries=t;this.publish_entries=m}},set_publish_all:function(h){this.publish_all=h;f.each(this.change_sets,function(){this.select(h)})},change_set_state:function(k,j){var l="cs-"+k.id,h,i=this;if(j){this.publish_entries.find(".instructions").hide();h=k.selected_panel(l).hide();this.publish_entries.prepend(h);k.panel().disappear();h.appear()}else{h=this.publish_entries.find("#"+l);h.disappear(function(){h.remove();var m=i.publish_entries;if(m.find(".change-set").length==0){m.find(".instructions").fadeIn()}});k.panel().appear()}},selected:function(){var l=[],k;for(var h=0,j=this.change_sets.length;h<j;h++){k=this.change_sets[h];if(k.selected){l.push(k)}}return l},changes_to_publish:function(){var m=[],l=this.selected(),k;for(var h=0,j=l.length;h<j;h++){k=l[h];m=m.concat(k.change.changes)}return m}});var e=new JS.Class({initialize:function(j,h,i){this.id=j;this.dialogue=h;this.change=i;this.selected=false},panel:function(){if(!this._panel){var j=g.div(".change-set"),k=g.div(".inner"),n=g.div(".pages"),o=g.div(".add").append(g.span().text("+")),h=this.pages();for(var l=0,m=h.length;l<m;l++){n.append(g.div(".title").text(h[l].title).append(g.div(".url").text(h[l].path)))}o.click(function(){this.select_toggle()}.bind(this));k.append(n,o);j.append(k);this.wrapper=j;this._panel=j}return this._panel},selected_panel:function(i){var h=this.panel().clone().attr("id",i);h.find(".add").click(this.select_toggle.bind(this)).find("span").text("-");return h},select:function(h){if(h===this.selected){return}this.selected=h;this.dialogue.change_set_state(this,this.selected)},select_toggle:function(){this.select(!this.selected)},update_view:function(){if(this.selected){this.wrapper.addClass("selected")}else{this.wrapper.removeClass("selected")}},pages:function(){if(!this._pages){this._pages=this.change.pages.sort(function(k,j){var i=k.depth,h=j.depth;if(i==h){return 0}return(i<h?-1:1)})}return this._pages}});var b=new JS.Singleton({open_dialogue:function(){a.open(new c())}});return b})(jQuery,Spontaneous);
88
- Spontaneous.Init=(function(b,a){return function(){var d=a.Location,f=a.TopBar,e=a.ContentArea,c=a.Dom.body();d.watch("location",f.location_changed.bind(f));d.watch("location",e.location_changed.bind(e));f.watch("mode",e.display.bind(e));f.watch("mode",d.view_mode_changed.bind(d));a.Editing.watch("page",d.page_loaded.bind(d));a.Editing.watch("path",d.path_changed.bind(d));c.append(f.panel());c.append(e.init());c.append(a.StatusBar.init());a.User.load();a.Types.init(function(){d.init(function(){f.init()})})}}(jQuery,Spontaneous));
89
- jQuery(Spontaneous.Init);
90
- // YUI compression via shine.magnetised.info