Refactored pyams_content.zmi package and resources
authorThierry Florac <thierry.florac@onf.fr>
Thu, 08 Nov 2018 10:50:52 +0100
changeset 1070 ea0c7ac589c4
parent 1069 abd11be23718
child 1071 e202798d3732
Refactored pyams_content.zmi package and resources
src/pyams_content/component/gallery/zmi/templates/gallery-medias.pt
src/pyams_content/component/illustration/zmi/__init__.py
src/pyams_content/component/paragraph/zmi/container.py
src/pyams_content/component/theme/zmi/manager.py
src/pyams_content/features/alert/zmi/container.py
src/pyams_content/features/footer/zmi/__init__.py
src/pyams_content/features/header/zmi/__init__.py
src/pyams_content/features/redirect/zmi/container.py
src/pyams_content/features/review/zmi/templates/review-comments.pt
src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.mo
src/pyams_content/reference/pictograms/zmi/templates/manager-selection.pt
src/pyams_content/root/zmi/__init__.py
src/pyams_content/root/zmi/search.py
src/pyams_content/root/zmi/sites.py
src/pyams_content/shared/blog/zmi/manager.py
src/pyams_content/shared/common/zmi/dashboard.py
src/pyams_content/shared/common/zmi/rename.py
src/pyams_content/shared/common/zmi/search.py
src/pyams_content/shared/common/zmi/templates/header.pt
src/pyams_content/shared/common/zmi/types.py
src/pyams_content/shared/form/zmi/field.py
src/pyams_content/shared/imagemap/zmi/templates/widget-input.pt
src/pyams_content/shared/site/zmi/container.py
src/pyams_content/shared/site/zmi/link.py
src/pyams_content/shared/site/zmi/manager.py
src/pyams_content/shared/site/zmi/widget/templates/folders-input.pt
src/pyams_content/skin/__init__.py
src/pyams_content/skin/resources/css/pyams_content.css
src/pyams_content/skin/resources/css/pyams_content.min.css
src/pyams_content/skin/resources/img/internal-link.png
src/pyams_content/skin/resources/js/jquery-canvasAreaDraw.js
src/pyams_content/skin/resources/js/jquery-canvasAreaDraw.min.js
src/pyams_content/skin/resources/js/jquery-imagemapster-1.2.10.js
src/pyams_content/skin/resources/js/jquery-imagemapster-1.2.10.min.js
src/pyams_content/skin/resources/js/pyams_content.js
src/pyams_content/skin/resources/js/pyams_content.min.js
src/pyams_content/skin/resources/js/tinymce/onflinks/langs/fr.js
src/pyams_content/skin/resources/js/tinymce/onflinks/langs/fr.min.js
src/pyams_content/skin/resources/js/tinymce/onflinks/plugin.js
src/pyams_content/skin/resources/js/tinymce/onflinks/plugin.min.js
src/pyams_content/skin/resources/less/pyams_content.less
src/pyams_content/skin/zmi/__init__.py
src/pyams_content/skin/zmi/interfaces/__init__.py
src/pyams_content/skin/zmi/tinymce.py
src/pyams_content/skin/zmi/viewlet/__init__.py
src/pyams_content/skin/zmi/viewlet/toplinks/__init__.py
src/pyams_content/skin/zmi/viewlet/toplinks/templates/user-addings.pt
src/pyams_content/zmi/__init__.py
src/pyams_content/zmi/interfaces.py
src/pyams_content/zmi/resources/css/pyams_content.css
src/pyams_content/zmi/resources/css/pyams_content.min.css
src/pyams_content/zmi/resources/img/internal-link.png
src/pyams_content/zmi/resources/js/jquery-canvasAreaDraw.js
src/pyams_content/zmi/resources/js/jquery-canvasAreaDraw.min.js
src/pyams_content/zmi/resources/js/jquery-imagemapster-1.2.10.js
src/pyams_content/zmi/resources/js/jquery-imagemapster-1.2.10.min.js
src/pyams_content/zmi/resources/js/pyams_content.js
src/pyams_content/zmi/resources/js/pyams_content.min.js
src/pyams_content/zmi/resources/js/tinymce/onflinks/langs/fr.js
src/pyams_content/zmi/resources/js/tinymce/onflinks/langs/fr.min.js
src/pyams_content/zmi/resources/js/tinymce/onflinks/plugin.js
src/pyams_content/zmi/resources/js/tinymce/onflinks/plugin.min.js
src/pyams_content/zmi/resources/less/pyams_content.less
src/pyams_content/zmi/tinymce.py
src/pyams_content/zmi/viewlet/__init__.py
src/pyams_content/zmi/viewlet/toplinks/__init__.py
src/pyams_content/zmi/viewlet/toplinks/templates/user-addings.pt
--- a/src/pyams_content/component/gallery/zmi/templates/gallery-medias.pt	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/component/gallery/zmi/templates/gallery-medias.pt	Thu Nov 08 10:50:52 2018 +0100
@@ -1,8 +1,8 @@
 <div class="form-group" i18n:domain="pyams_content"
 	 data-ams-plugins="pyams_content"
 	 tal:define="gallery_images context.values()"
-	 tal:attributes="data-ams-plugin-pyams_content-src tales:resource_path('pyams_content.skin:pyams_content');
-					 data-ams-plugin-pyams_content-css tales:resource_path('pyams_content.skin:pyams_content_css');
+	 tal:attributes="data-ams-plugin-pyams_content-src tales:resource_path('pyams_content.zmi:pyams_content');
+					 data-ams-plugin-pyams_content-css tales:resource_path('pyams_content.zmi:pyams_content_css');
 					 id string:gallery_medias_${context.__name__};"
 	 data-ams-plugin-pyams_content-async="false">
 	<fieldset class="margin-top-10 padding-top-5 padding-bottom-0">
--- a/src/pyams_content/component/illustration/zmi/__init__.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/component/illustration/zmi/__init__.py	Thu Nov 08 10:50:52 2018 +0100
@@ -22,7 +22,7 @@
 from pyams_content.component.paragraph import IBaseParagraph
 from pyams_content.component.paragraph.zmi import get_json_paragraph_markers_refresh_event
 from pyams_content.features.renderer.zmi.widget import RendererFieldWidget
-from pyams_content.skin import pyams_content
+from pyams_content.zmi import pyams_content
 from pyams_form.interfaces.form import IInnerSubForm, IWidgetsPrefixViewletsManager
 from pyams_form.security import ProtectedFormObjectMixin
 from pyams_skin.event import get_json_form_refresh_event, get_json_widget_refresh_event
--- a/src/pyams_content/component/paragraph/zmi/container.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/component/paragraph/zmi/container.py	Thu Nov 08 10:50:52 2018 +0100
@@ -32,7 +32,7 @@
     IParagraphInnerEditor, IParagraphTitleToolbar, IParagraphTitleValue
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
 from pyams_content.shared.common.zmi import WfModifiedContentColumnMixin
-from pyams_content.skin import pyams_content
+from pyams_content.zmi import pyams_content
 from pyams_form.interfaces.form import IFormSecurityContext, IInnerSubForm
 from pyams_form.security import ProtectedFormObjectMixin
 from pyams_i18n.interfaces import II18n
--- a/src/pyams_content/component/theme/zmi/manager.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/component/theme/zmi/manager.py	Thu Nov 08 10:50:52 2018 +0100
@@ -27,7 +27,7 @@
 from pyams_zmi.layer import IAdminLayer
 
 # import packages
-from pyams_content.skin import pyams_content
+from pyams_content.zmi import pyams_content
 from pyams_form.form import ajax_config
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.viewlet.menu import MenuItem, MenuDivider
--- a/src/pyams_content/features/alert/zmi/container.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/features/alert/zmi/container.py	Thu Nov 08 10:50:52 2018 +0100
@@ -26,7 +26,7 @@
 from z3c.table.interfaces import IValues, IColumn
 
 # import packages
-from pyams_content.skin import pyams_content
+from pyams_content.zmi import pyams_content
 from pyams_i18n.column import I18nAttrColumn
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.page import DefaultPageHeaderAdapter
--- a/src/pyams_content/features/footer/zmi/__init__.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/features/footer/zmi/__init__.py	Thu Nov 08 10:50:52 2018 +0100
@@ -30,7 +30,7 @@
 from z3c.form.interfaces import INPUT_MODE
 
 # import packages
-from pyams_content.skin import pyams_content
+from pyams_content.zmi import pyams_content
 from pyams_form.form import AJAXEditForm
 from pyams_form.group import NamedWidgetsGroup
 from pyams_form.help import FormHelp
--- a/src/pyams_content/features/header/zmi/__init__.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/features/header/zmi/__init__.py	Thu Nov 08 10:50:52 2018 +0100
@@ -30,7 +30,7 @@
 from z3c.form.interfaces import INPUT_MODE
 
 # import packages
-from pyams_content.skin import pyams_content
+from pyams_content.zmi import pyams_content
 from pyams_form.form import AJAXEditForm
 from pyams_form.group import NamedWidgetsGroup
 from pyams_form.help import FormHelp
--- a/src/pyams_content/features/redirect/zmi/container.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/features/redirect/zmi/container.py	Thu Nov 08 10:50:52 2018 +0100
@@ -30,7 +30,7 @@
 from z3c.table.interfaces import IValues, IColumn
 
 # import packages
-from pyams_content.skin import pyams_content
+from pyams_content.zmi import pyams_content
 from pyams_form.form import AJAXAddForm
 from pyams_form.schema import CloseButton
 from pyams_pagelet.pagelet import pagelet_config
--- a/src/pyams_content/features/review/zmi/templates/review-comments.pt	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/features/review/zmi/templates/review-comments.pt	Thu Nov 08 10:50:52 2018 +0100
@@ -1,7 +1,7 @@
 <div class="ams-widget comments" i18n:domain="pyams_content"
 	 data-ams-plugins="pyams_content"
-	 tal:attributes="data-ams-plugin-pyams_content-src tales:resource_path('pyams_content.skin:pyams_content');
-					 data-ams-plugin-pyams_content-css tales:resource_path('pyams_content.skin:pyams_content_css');"
+	 tal:attributes="data-ams-plugin-pyams_content-src tales:resource_path('pyams_content.zmi:pyams_content');
+					 data-ams-plugin-pyams_content-css tales:resource_path('pyams_content.zmi:pyams_content_css');"
 	 data-ams-plugin-pyams_content-async="false"
 	 data-ams-callback="PyAMS_content.review.initComments">
 	<header>
Binary file src/pyams_content/locales/fr/LC_MESSAGES/pyams_content.mo has changed
--- a/src/pyams_content/reference/pictograms/zmi/templates/manager-selection.pt	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/reference/pictograms/zmi/templates/manager-selection.pt	Thu Nov 08 10:50:52 2018 +0100
@@ -1,8 +1,8 @@
 <div class="pictograms-manager" i18n:domain="pyams_content"
 	 data-ams-plugins="pyams_content"
 	 data-ams-plugin-pyams_content-async="false"
-	 data-ams-plugin-pyams_content-src="${tales:resource_path('pyams_content.skin:pyams_content')}"
-	 data-ams-plugin-pyams_content-css="${tales:resource_path('pyams_content.skin:pyams_content_css')}">
+	 data-ams-plugin-pyams_content-src="${tales:resource_path('pyams_content.zmi:pyams_content')}"
+	 data-ams-plugin-pyams_content-css="${tales:resource_path('pyams_content.zmi:pyams_content_css')}">
 	<fieldset class="bordered margin-x-20 col-md-5">
 		<legend class="inner" i18n:translate="">Available pictograms</legend>
 		<div class="droppable sortable height-min-100 pictograms available-pictograms viewport-y viewport-500"
--- a/src/pyams_content/root/zmi/__init__.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/root/zmi/__init__.py	Thu Nov 08 10:50:52 2018 +0100
@@ -22,7 +22,7 @@
 from pyams_content.root.interfaces import ISiteRoot
 from pyams_content.shared.common.interfaces import IBaseSharedTool, IManagerRestrictions
 from pyams_content.shared.common.interfaces.zmi import ISiteRootDashboardTable
-from pyams_content.skin.zmi.interfaces import IDashboardMenu, IMyDashboardMenu, IAllContentsMenu
+from pyams_content.zmi.interfaces import IDashboardMenu, IMyDashboardMenu, IAllContentsMenu
 from pyams_i18n.interfaces import II18n
 from pyams_skin.interfaces import IInnerPage, IPageHeader
 from pyams_skin.interfaces.configuration import IBackOfficeConfiguration, IConfiguration
--- a/src/pyams_content/root/zmi/search.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/root/zmi/search.py	Thu Nov 08 10:50:52 2018 +0100
@@ -22,7 +22,7 @@
 from pyams_content.root import ISiteRoot
 from pyams_content.shared.common.interfaces import CONTENT_TYPES_VOCABULARY
 from pyams_content.shared.common.interfaces.zmi import ISiteRootDashboardTable
-from pyams_content.skin.zmi.interfaces import IAllContentsMenu
+from pyams_content.zmi.interfaces import IAllContentsMenu
 from pyams_form.search import ISearchFields, SearchForm, SearchView, SearchResultsView
 from pyams_i18n.interfaces import INegotiator
 from pyams_sequence.interfaces import ISequentialIntIds
--- a/src/pyams_content/root/zmi/sites.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/root/zmi/sites.py	Thu Nov 08 10:50:52 2018 +0100
@@ -23,8 +23,8 @@
 from pyams_content.root.interfaces import ISiteRoot
 from pyams_content.shared.common.interfaces import IBaseSharedTool, ISharedSite
 from pyams_content.shared.common.interfaces.zmi import IDashboardTable
-from pyams_content.skin import pyams_content
-from pyams_content.skin.zmi.interfaces import ISiteTreeMenu, ISiteTreeTable
+from pyams_content.zmi import pyams_content
+from pyams_content.zmi.interfaces import ISiteTreeMenu, ISiteTreeTable
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_sequence.interfaces import ISequentialIdInfo
 from pyams_skin.container import ContainerView, delete_container_element
--- a/src/pyams_content/shared/blog/zmi/manager.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/blog/zmi/manager.py	Thu Nov 08 10:50:52 2018 +0100
@@ -26,7 +26,7 @@
 from pyams_content.shared.blog.manager import BlogManager
 from pyams_content.shared.common import IBaseSharedTool
 from pyams_content.shared.common.zmi.manager import SharedToolPropertiesEditForm
-from pyams_content.skin.zmi.interfaces import ISiteTreeTable, IUserAddingsMenuLabel
+from pyams_content.zmi.interfaces import ISiteTreeTable, IUserAddingsMenuLabel
 from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_i18n.interfaces import II18n, INegotiator
 from pyams_pagelet.pagelet import pagelet_config
--- a/src/pyams_content/shared/common/zmi/dashboard.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/dashboard.py	Thu Nov 08 10:50:52 2018 +0100
@@ -28,8 +28,8 @@
 from pyams_content.shared.common.interfaces import IBaseSharedTool, IWfSharedContent, IManagerRestrictions
 from pyams_content.shared.common.interfaces.zmi import IDashboardTable, ISharedToolDashboardTable, \
     IDashboardSearchHeader
-from pyams_content.skin import pyams_content
-from pyams_content.skin.zmi.interfaces import IDashboardMenu, IMyDashboardMenu, IAllContentsMenu
+from pyams_content.zmi import pyams_content
+from pyams_content.zmi.interfaces import IDashboardMenu, IMyDashboardMenu, IAllContentsMenu
 from pyams_i18n.interfaces import II18n
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_security.interfaces import ISecurityManager
--- a/src/pyams_content/shared/common/zmi/rename.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/rename.py	Thu Nov 08 10:50:52 2018 +0100
@@ -21,8 +21,8 @@
 
 from pyams_content.interfaces import MANAGE_SITE_PERMISSION
 from pyams_content.shared.common.interfaces import ISharedSite
-from pyams_content.shared.site.interfaces import ISiteFolder, IBaseSiteItem
-from pyams_content.skin.zmi.interfaces import ISiteTreeTable
+from pyams_content.shared.site.interfaces import IBaseSiteItem
+from pyams_content.zmi.interfaces import ISiteTreeTable
 from pyams_form.form import ajax_config
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.interfaces.viewlet import IContextActions, ITableItemColumnActionsMenu
--- a/src/pyams_content/shared/common/zmi/search.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/search.py	Thu Nov 08 10:50:52 2018 +0100
@@ -22,7 +22,7 @@
 from pyams_content.profile.interfaces import IAdminProfile
 from pyams_content.shared.common.interfaces import IBaseSharedTool
 from pyams_content.shared.common.interfaces.zmi import ISharedToolDashboardTable
-from pyams_content.skin.zmi.interfaces import IAllContentsMenu
+from pyams_content.zmi.interfaces import IAllContentsMenu
 from pyams_i18n.interfaces import INegotiator
 from pyams_pagelet.interfaces import PageletCreatedEvent
 from pyams_sequence.interfaces import ISequentialIntIds
--- a/src/pyams_content/shared/common/zmi/templates/header.pt	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/templates/header.pt	Thu Nov 08 10:50:52 2018 +0100
@@ -22,7 +22,7 @@
 		   data-ams-click-handler="PyAMS_content.profile.switchFavorite"
 		   data-ams-hint-gravity="w" title="Add/remove from favorites" i18n:attributes="title"
 		   tal:attributes="class 'fa fa-star{0} txt-color-blue hint opaque align-middle padding-left-10 padding-bottom-5'.format('' if view.favorite_content else '-o');
-						   data-ams-plugin-pyams_content-src tales:resource_path('pyams_content.skin:pyams_content');
+						   data-ams-plugin-pyams_content-src tales:resource_path('pyams_content.zmi:pyams_content');
 						   data-sequence-oid view.hex_oid;"></i><br />
 		<span class="content-version" tal:content="string:V${view.version_id}">Version</span> =
 		<span class="content-state" tal:content="structure view.state">state</span> |
--- a/src/pyams_content/shared/common/zmi/types.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/types.py	Thu Nov 08 10:50:52 2018 +0100
@@ -32,7 +32,7 @@
 from pyams_content.shared.common.types import DataType, SubType
 from pyams_content.shared.common.zmi import SharedContentAddForm
 from pyams_content.shared.common.zmi.properties import SharedContentPropertiesEditForm
-from pyams_content.skin import pyams_content
+from pyams_content.zmi import pyams_content
 from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_form.interfaces.form import IWidgetForm
 from pyams_form.security import ProtectedFormObjectMixin
--- a/src/pyams_content/shared/form/zmi/field.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/form/zmi/field.py	Thu Nov 08 10:50:52 2018 +0100
@@ -21,7 +21,7 @@
 from pyams_content.shared.common.interfaces import IWfSharedContent
 from pyams_content.shared.form.interfaces import IFormFieldContainerTarget, IFormFieldContainer, IFormField, \
     IFormFieldFactory
-from pyams_content.skin import pyams_content
+from pyams_content.zmi import pyams_content
 from pyams_form.interfaces.form import IFormSecurityContext
 from pyams_i18n.interfaces import II18n
 from pyams_skin.interfaces.viewlet import IWidgetTitleViewletManager
--- a/src/pyams_content/shared/imagemap/zmi/templates/widget-input.pt	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/imagemap/zmi/templates/widget-input.pt	Thu Nov 08 10:50:52 2018 +0100
@@ -1,5 +1,5 @@
 <label data-ams-plugins="pyams_content"
-	   tal:attributes="data-ams-plugin-pyams_content-src tales:resource_path('pyams_content.skin:pyams_content')">
+	   tal:attributes="data-ams-plugin-pyams_content-src tales:resource_path('pyams_content.zmi:pyams_content')">
 	<input type="hidden"
 		   tal:attributes="id view/id;
 						   name view/name;
--- a/src/pyams_content/shared/site/zmi/container.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/site/zmi/container.py	Thu Nov 08 10:50:52 2018 +0100
@@ -33,8 +33,8 @@
     SharedToolDashboardVersionColumn
 from pyams_content.shared.site import WfSiteTopic
 from pyams_content.shared.site.interfaces import IBaseSiteItem, IContentLink, ISiteContainer, ISiteManager
-from pyams_content.skin import pyams_content
-from pyams_content.skin.zmi.interfaces import ISiteTreeMenu, ISiteTreeTable, IUserAddingsMenuLabel
+from pyams_content.zmi import pyams_content
+from pyams_content.zmi.interfaces import ISiteTreeMenu, ISiteTreeTable, IUserAddingsMenuLabel
 from pyams_form.form import ajax_config
 from pyams_i18n.interfaces import II18n
 from pyams_pagelet.pagelet import pagelet_config
--- a/src/pyams_content/shared/site/zmi/link.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/site/zmi/link.py	Thu Nov 08 10:50:52 2018 +0100
@@ -19,7 +19,7 @@
 # import interfaces
 from pyams_content.interfaces import CREATE_CONTENT_PERMISSION, MANAGE_CONTENT_PERMISSION
 from pyams_content.shared.site.interfaces import ISiteContainer, IContentLink
-from pyams_content.skin.zmi.interfaces import ISiteTreeTable
+from pyams_content.zmi.interfaces import ISiteTreeTable
 from pyams_i18n.interfaces import II18n
 from pyams_skin.interfaces.container import ITableElementName
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu
--- a/src/pyams_content/shared/site/zmi/manager.py	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/site/zmi/manager.py	Thu Nov 08 10:50:52 2018 +0100
@@ -26,7 +26,7 @@
 from pyams_content.shared.site import WfSiteTopic
 from pyams_content.shared.site.interfaces import ISiteManager, ISiteManagerFactory
 from pyams_content.shared.site.manager import SiteManager
-from pyams_content.skin.zmi.interfaces import ISiteTreeTable, IUserAddingsMenuLabel
+from pyams_content.zmi.interfaces import ISiteTreeTable, IUserAddingsMenuLabel
 from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_i18n.interfaces import II18n, INegotiator
 from pyams_pagelet.pagelet import pagelet_config
--- a/src/pyams_content/shared/site/zmi/widget/templates/folders-input.pt	Thu Nov 08 08:46:58 2018 +0100
+++ b/src/pyams_content/shared/site/zmi/widget/templates/folders-input.pt	Thu Nov 08 10:50:52 2018 +0100
@@ -1,6 +1,6 @@
 <div i18n:domain="pyams_content"
 	 data-ams-plugins="pyams_content"
-	 tal:attributes="data-ams-plugin-pyams_content-src tales:resource_path('pyams_content.skin:pyams_content')">
+	 tal:attributes="data-ams-plugin-pyams_content-src tales:resource_path('pyams_content.zmi:pyams_content')">
 	<input type="hidden"
 			tal:attributes="id view/id;
 							name view/name;
--- a/src/pyams_content/skin/__init__.py	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
-
-# import interfaces
-
-# import packages
-from fanstatic import Library, Resource
-
-
-library = Library('pyams_content', 'resources')
-
-
-pyams_content_css = Resource(library, 'css/pyams_content.css',
-                             minified='css/pyams_content.min.css')
-
-pyams_content = Resource(library, 'js/pyams_content.js',
-                         minified='js/pyams_content.min.js',
-                         depends=(pyams_content_css, ),
-                         bottom=True)
--- a/src/pyams_content/skin/resources/css/pyams_content.css	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-.ams-widget.comments .widget-body {
-  position: fixed;
-  height: calc(100% - 337px);
-}
-.ams-widget.comments .widget-body .chat-body {
-  position: relative;
-  height: 100%;
-}
-.ams-widget.comments .widget-body .chat-footer {
-  position: fixed;
-  bottom: 10px;
-}
-.ams-widget.comments .widget-body,
-.ams-widget.comments .widget-body .chat-footer {
-  width: calc(100% - 240px);
-}
-@media (max-width: 767px) {
-  .ams-widget.comments .widget-body,
-  .ams-widget.comments .widget-body .chat-footer {
-    width: calc(100% - 10px);
-  }
-}
-@media (min-width: 768px) and (max-width: 979px) {
-  .ams-widget.comments .widget-body,
-  .ams-widget.comments .widget-body .chat-footer {
-    width: calc(100% - 20px);
-  }
-}
-.minified .ams-widget.comments .widget-body,
-.minified .ams-widget.comments .widget-body .chat-footer {
-  width: calc(100% - 65px);
-}
-@media (max-width: 767px) {
-  .minified .ams-widget.comments .widget-body,
-  .minified .ams-widget.comments .widget-body .chat-footer {
-    width: calc(100% - 55px);
-  }
-}
-.hidden-menu .ams-widget.comments .widget-body,
-.hidden-menu .ams-widget.comments .widget-body .chat-footer {
-  width: calc(100% - 30px);
-}
-.pictograms-manager .pictogram {
-  border-bottom: 1px solid silver;
-}
-.pictograms-manager .pictogram:last-child {
-  border-bottom: none;
-}
-.sortable.gallery {
-  max-height: 550px;
-}
--- a/src/pyams_content/skin/resources/css/pyams_content.min.css	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-.ams-widget.comments .widget-body{position:fixed;height:calc(100% - 337px)}.ams-widget.comments .widget-body .chat-body{position:relative;height:100%}.ams-widget.comments .widget-body .chat-footer{position:fixed;bottom:10px}.ams-widget.comments .widget-body,.ams-widget.comments .widget-body .chat-footer{width:calc(100% - 240px)}@media (max-width:767px){.ams-widget.comments .widget-body,.ams-widget.comments .widget-body .chat-footer{width:calc(100% - 10px)}}@media (min-width:768px) and (max-width:979px){.ams-widget.comments .widget-body,.ams-widget.comments .widget-body .chat-footer{width:calc(100% - 20px)}}.minified .ams-widget.comments .widget-body,.minified .ams-widget.comments .widget-body .chat-footer{width:calc(100% - 65px)}@media (max-width:767px){.minified .ams-widget.comments .widget-body,.minified .ams-widget.comments .widget-body .chat-footer{width:calc(100% - 55px)}}.hidden-menu .ams-widget.comments .widget-body,.hidden-menu .ams-widget.comments .widget-body .chat-footer{width:calc(100% - 30px)}.pictograms-manager .pictogram{border-bottom:1px solid silver}.pictograms-manager .pictogram:last-child{border-bottom:none}.sortable.gallery{max-height:550px}
Binary file src/pyams_content/skin/resources/img/internal-link.png has changed
--- a/src/pyams_content/skin/resources/js/jquery-canvasAreaDraw.js	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,273 +0,0 @@
-(function ($) {
-
-	$.fn.canvasAreaDraw = function (options) {
-
-		this.each(function (index, element) {
-			init.apply(element, [index, element, options]);
-		});
-
-	}
-
-	var init = function (index, input, options) {
-
-		var points, activePoint, settings;
-		var $reset, $canvas, ctx, image;
-		var draw, mousedown, stopdrag, move, moveall, resize, reset, rightclick, record;
-		var dragpoint;
-		var startpoint = false;
-
-		settings = $.extend({
-								imageUrl: $(this).attr('data-image-url')
-							}, options);
-
-		var v = $(input).val().replace(/[^0-9\,]/ig, '');
-		if (v.length) {
-			points = v.split(',').map(function (point) {
-				return parseInt(point, 10);
-			});
-		} else {
-			points = [];
-		}
-
-		// $reset = $('<button type="button" class="btn"><i class="icon-trash"></i>Очистить</button>');
-		$reset = $('<i class="fa fa-fw fa-trash"></i>');
-		$canvas = $('<canvas>');
-		ctx = $canvas[0].getContext('2d');
-
-		image = new Image();
-		resize = function () {
-			$canvas.attr('height', image.height).attr('width', image.width);
-			draw();
-		};
-		$(image).load(resize);
-		image.src = settings.imageUrl;
-		if (image.loaded) {
-			resize();
-		}
-		$canvas.css({background: 'url(' + image.src + ')'});
-
-		if (input.type !== 'hidden') {
-			$(input).after('<br />');
-		}
-		$(input).after($canvas, '<br />', $reset);
-
-		reset = function () {
-			points = [];
-			draw();
-		};
-
-		move = function (e) {
-			if (!e.offsetX) {
-				e.offsetX = (e.pageX - $(e.target).offset().left);
-				e.offsetY = (e.pageY - $(e.target).offset().top);
-			}
-			points[activePoint] = Math.round(e.offsetX);
-			points[activePoint + 1] = Math.round(e.offsetY);
-			draw();
-		};
-
-		moveall = function (e) {
-			if (!e.offsetX) {
-				e.offsetX = (e.pageX - $(e.target).offset().left);
-				e.offsetY = (e.pageY - $(e.target).offset().top);
-			}
-			if (!startpoint) {
-				startpoint = {x: Math.round(e.offsetX), y: Math.round(e.offsetY)};
-			}
-			var sdvpoint = {x: Math.round(e.offsetX), y: Math.round(e.offsetY)};
-			for (var i = 0; i < points.length; i++) {
-				points[i] = (sdvpoint.x - startpoint.x) + points[i];
-				points[++i] = (sdvpoint.y - startpoint.y) + points[i];
-			}
-			startpoint = sdvpoint;
-			draw();
-		};
-
-		stopdrag = function () {
-			$(this).off('mousemove');
-			record();
-			activePoint = null;
-		};
-
-		rightclick = function (e) {
-			e.preventDefault();
-			if (!e.offsetX) {
-				e.offsetX = (e.pageX - $(e.target).offset().left);
-				e.offsetY = (e.pageY - $(e.target).offset().top);
-			}
-			var x = e.offsetX, y = e.offsetY;
-			for (var i = 0; i < points.length; i += 2) {
-				dis = Math.sqrt(Math.pow(x - points[i], 2) + Math.pow(y - points[i + 1], 2));
-				if (dis < 6) {
-					points.splice(i, 2);
-					draw();
-					record();
-					return false;
-				}
-			}
-			return false;
-		};
-
-		mousedown = function (e) {
-			var x, y, dis, lineDis, insertAt = points.length;
-
-			if (e.which === 3) {
-				return false;
-			}
-
-			e.preventDefault();
-			if (!e.offsetX) {
-				e.offsetX = (e.pageX - $(e.target).offset().left);
-				e.offsetY = (e.pageY - $(e.target).offset().top);
-			}
-			x = e.offsetX;
-			y = e.offsetY;
-
-			if (points.length >= 6) {
-				var c = getCenter();
-				ctx.fillRect(c.x - 4, c.y - 4, 8, 8);
-				dis = Math.sqrt(Math.pow(x - c.x, 2) + Math.pow(y - c.y, 2));
-				if (dis < 6) {
-					startpoint = false;
-					$(this).on('mousemove', moveall);
-					return false;
-				}
-			}
-
-			for (var i = 0; i < points.length; i += 2) {
-				dis = Math.sqrt(Math.pow(x - points[i], 2) + Math.pow(y - points[i + 1], 2));
-				if (dis < 6) {
-					activePoint = i;
-					$(this).on('mousemove', move);
-					return false;
-				}
-			}
-
-			for (var i = 0; i < points.length; i += 2) {
-				if (i > 1) {
-					lineDis = dotLineLength(
-						x, y,
-						points[i], points[i + 1],
-						points[i - 2], points[i - 1],
-						true
-					);
-					if (lineDis < 6) {
-						insertAt = i;
-					}
-				}
-			}
-
-			points.splice(insertAt, 0, Math.round(x), Math.round(y));
-			activePoint = insertAt;
-			$(this).on('mousemove', move);
-
-			draw();
-			record();
-
-			return false;
-		};
-
-		draw = function () {
-			ctx.canvas.width = ctx.canvas.width;
-
-			record();
-			if (points.length < 2) {
-				return;
-			}
-			ctx.globalCompositeOperation = 'destination-over';
-			ctx.fillStyle = 'rgb(255,255,255)';
-			ctx.strokeStyle = 'rgb(255,20,20)';
-			ctx.lineWidth = 1;
-			if (points.length >= 6) {
-				var c = getCenter();
-				ctx.fillRect(c.x - 4, c.y - 4, 8, 8);
-			}
-			ctx.beginPath();
-			ctx.moveTo(points[0], points[1]);
-			for (var i = 0; i < points.length; i += 2) {
-				ctx.fillRect(points[i] - 2, points[i + 1] - 2, 4, 4);
-				ctx.strokeRect(points[i] - 2, points[i + 1] - 2, 4, 4);
-				if (points.length > 2 && i > 1) {
-					ctx.lineTo(points[i], points[i + 1]);
-				}
-			}
-			ctx.closePath();
-			ctx.fillStyle = 'rgba(255,0,0,0.3)';
-			ctx.fill();
-			ctx.stroke();
-
-		};
-
-		record = function () {
-			$(input).val(points.join(','));
-		};
-
-		getCenter = function () {
-			var ptc = [];
-			for (i = 0; i < points.length; i++) {
-				ptc.push({x: points[i], y: points[++i]});
-			}
-			var first = ptc[0], last = ptc[ptc.length - 1];
-			if (first.x != last.x || first.y != last.y) ptc.push(first);
-			var twicearea = 0,
-				x = 0, y = 0,
-				nptc = ptc.length,
-				p1, p2, f;
-			for (var i = 0, j = nptc - 1; i < nptc; j = i++) {
-				p1 = ptc[i];
-				p2 = ptc[j];
-				f = p1.x * p2.y - p2.x * p1.y;
-				twicearea += f;
-				x += ( p1.x + p2.x ) * f;
-				y += ( p1.y + p2.y ) * f;
-			}
-			f = twicearea * 3;
-			return {x: x / f, y: y / f};
-		};
-
-		$(input).on('change', function () {
-			var v = $(input).val().replace(/[^0-9\,]/ig, '');
-			if (v.length) {
-				points = v.split(',').map(function (point) {
-					return parseInt(point, 10);
-				});
-			} else {
-				points = [];
-			}
-			draw();
-		});
-
-		$(document).find($reset).click(reset);
-		$(document).find($canvas).on('mousedown', mousedown);
-		$(document).find($canvas).on('contextmenu', rightclick);
-		$(document).find($canvas).on('mouseup', stopdrag);
-
-	};
-
-	$(document).ready(function () {
-		$('.canvas-area[data-image-url]').canvasAreaDraw();
-	});
-
-	var dotLineLength = function (x, y, x0, y0, x1, y1, o) {
-		function lineLength(x, y, x0, y0) {
-			return Math.sqrt((x -= x0) * x + (y -= y0) * y);
-		}
-
-		if (o && !(o = function (x, y, x0, y0, x1, y1) {
-				if (!(x1 - x0)) return {x: x0, y: y};
-				else if (!(y1 - y0)) return {x: x, y: y0};
-				var left, tg = -1 / ((y1 - y0) / (x1 - x0));
-				return {
-					x: left = (x1 * (x * tg - y + y0) + x0 * (x * -tg + y - y1)) / (tg * (x1 - x0) + y0 - y1),
-					y: tg * left - tg * x + y
-				};
-			}(x, y, x0, y0, x1, y1), o.x >= Math.min(x0, x1) && o.x <= Math.max(x0, x1) && o.y >= Math.min(y0, y1) && o.y <= Math.max(y0, y1))) {
-			var l1 = lineLength(x, y, x0, y0), l2 = lineLength(x, y, x1, y1);
-			return l1 > l2 ? l2 : l1;
-		}
-		else {
-			var a = y0 - y1, b = x1 - x0, c = x0 * y1 - y0 * x1;
-			return Math.abs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
-		}
-	};
-})(jQuery);
--- a/src/pyams_content/skin/resources/js/jquery-canvasAreaDraw.min.js	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-(function(b){b.fn.canvasAreaDraw=function(d){this.each(function(e,f){c.apply(f,[e,f,d])})};var c=function(i,o,h){var u,g,x;var p,j,s,q;var l,t,m,r,d,z,y,w,f;var e;var k=false;x=b.extend({imageUrl:b(this).attr("data-image-url")},h);var n=b(o).val().replace(/[^0-9\,]/ig,"");if(n.length){u=n.split(",").map(function(v){return parseInt(v,10)})}else{u=[]}p=b('<i class="fa fa-fw fa-trash"></i>');j=b("<canvas>");s=j[0].getContext("2d");q=new Image();z=function(){j.attr("height",q.height).attr("width",q.width);l()};b(q).load(z);q.src=x.imageUrl;if(q.loaded){z()}j.css({background:"url("+q.src+")"});if(o.type!=="hidden"){b(o).after("<br />")}b(o).after(j,"<br />",p);y=function(){u=[];l()};r=function(v){if(!v.offsetX){v.offsetX=(v.pageX-b(v.target).offset().left);v.offsetY=(v.pageY-b(v.target).offset().top)}u[g]=Math.round(v.offsetX);u[g+1]=Math.round(v.offsetY);l()};d=function(B){if(!B.offsetX){B.offsetX=(B.pageX-b(B.target).offset().left);B.offsetY=(B.pageY-b(B.target).offset().top)}if(!k){k={x:Math.round(B.offsetX),y:Math.round(B.offsetY)}}var v={x:Math.round(B.offsetX),y:Math.round(B.offsetY)};for(var A=0;A<u.length;A++){u[A]=(v.x-k.x)+u[A];u[++A]=(v.y-k.y)+u[A]}k=v;l()};m=function(){b(this).off("mousemove");f();g=null};w=function(B){B.preventDefault();if(!B.offsetX){B.offsetX=(B.pageX-b(B.target).offset().left);B.offsetY=(B.pageY-b(B.target).offset().top)}var v=B.offsetX,C=B.offsetY;for(var A=0;A<u.length;A+=2){dis=Math.sqrt(Math.pow(v-u[A],2)+Math.pow(C-u[A+1],2));if(dis<6){u.splice(A,2);l();f();return false}}return false};t=function(E){var v,G,A,D,C=u.length;if(E.which===3){return false}E.preventDefault();if(!E.offsetX){E.offsetX=(E.pageX-b(E.target).offset().left);E.offsetY=(E.pageY-b(E.target).offset().top)}v=E.offsetX;G=E.offsetY;if(u.length>=6){var F=getCenter();s.fillRect(F.x-4,F.y-4,8,8);A=Math.sqrt(Math.pow(v-F.x,2)+Math.pow(G-F.y,2));if(A<6){k=false;b(this).on("mousemove",d);return false}}for(var B=0;B<u.length;B+=2){A=Math.sqrt(Math.pow(v-u[B],2)+Math.pow(G-u[B+1],2));if(A<6){g=B;b(this).on("mousemove",r);return false}}for(var B=0;B<u.length;B+=2){if(B>1){D=a(v,G,u[B],u[B+1],u[B-2],u[B-1],true);if(D<6){C=B}}}u.splice(C,0,Math.round(v),Math.round(G));g=C;b(this).on("mousemove",r);l();f();return false};l=function(){s.canvas.width=s.canvas.width;f();if(u.length<2){return}s.globalCompositeOperation="destination-over";s.fillStyle="rgb(255,255,255)";s.strokeStyle="rgb(255,20,20)";s.lineWidth=1;if(u.length>=6){var A=getCenter();s.fillRect(A.x-4,A.y-4,8,8)}s.beginPath();s.moveTo(u[0],u[1]);for(var v=0;v<u.length;v+=2){s.fillRect(u[v]-2,u[v+1]-2,4,4);s.strokeRect(u[v]-2,u[v+1]-2,4,4);if(u.length>2&&v>1){s.lineTo(u[v],u[v+1])}}s.closePath();s.fillStyle="rgba(255,0,0,0.3)";s.fill();s.stroke()};f=function(){b(o).val(u.join(","))};getCenter=function(){var E=[];for(A=0;A<u.length;A++){E.push({x:u[A],y:u[++A]})}var C=E[0],I=E[E.length-1];if(C.x!=I.x||C.y!=I.y){E.push(C)}var B=0,G=0,F=0,K=E.length,J,H,D;for(var A=0,v=K-1;A<K;v=A++){J=E[A];H=E[v];D=J.x*H.y-H.x*J.y;B+=D;G+=(J.x+H.x)*D;F+=(J.y+H.y)*D}D=B*3;return{x:G/D,y:F/D}};b(o).on("change",function(){var A=b(o).val().replace(/[^0-9\,]/ig,"");if(A.length){u=A.split(",").map(function(v){return parseInt(v,10)})}else{u=[]}l()});b(document).find(p).click(y);b(document).find(j).on("mousedown",t);b(document).find(j).on("contextmenu",w);b(document).find(j).on("mouseup",m)};b(document).ready(function(){b(".canvas-area[data-image-url]").canvasAreaDraw()});var a=function(p,l,g,q,e,n,f){function d(o,t,r,s){return Math.sqrt((o-=r)*o+(t-=s)*t)}if(f&&!(f=function(o,z,s,u,r,t){if(!(r-s)){return{x:s,y:z}}else{if(!(t-u)){return{x:o,y:u}}}var w,v=-1/((t-u)/(r-s));return{x:w=(r*(o*v-z+u)+s*(o*-v+z-t))/(v*(r-s)+u-t),y:v*w-v*o+z}}(p,l,g,q,e,n),f.x>=Math.min(g,e)&&f.x<=Math.max(g,e)&&f.y>=Math.min(q,n)&&f.y<=Math.max(q,n))){var i=d(p,l,g,q),h=d(p,l,e,n);return i>h?h:i}else{var m=q-n,k=e-g,j=g*n-q*e;return Math.abs(m*p+k*l+j)/Math.sqrt(m*m+k*k)}}})(jQuery);
\ No newline at end of file
--- a/src/pyams_content/skin/resources/js/jquery-imagemapster-1.2.10.js	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4668 +0,0 @@
-/* ImageMapster
-   Version: 1.2.10 (2/25/2013)
-
-Copyright 2011-2012 James Treworgy
-
-http://www.outsharked.com/imagemapster
-https://github.com/jamietre/ImageMapster
-
-A jQuery plugin to enhance image maps.
-
-*/
-
-;
-
-/// LICENSE (MIT License)
-///
-/// Permission is hereby granted, free of charge, to any person obtaining
-/// a copy of this software and associated documentation files (the
-/// "Software"), to deal in the Software without restriction, including
-/// without limitation the rights to use, copy, modify, merge, publish,
-/// distribute, sublicense, and/or sell copies of the Software, and to
-/// permit persons to whom the Software is furnished to do so, subject to
-/// the following conditions:
-///
-/// The above copyright notice and this permission notice shall be
-/// included in all copies or substantial portions of the Software.
-///
-/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-/// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-/// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-/// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-/// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-/// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-/// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-///
-/// January 19, 2011
-
-/** @license MIT License (c) copyright B Cavalier & J Hann */
-
-/**
-* when
-* A lightweight CommonJS Promises/A and when() implementation
-*
-* when is part of the cujo.js family of libraries (http://cujojs.com/)
-*
-* Licensed under the MIT License at:
-* http://www.opensource.org/licenses/mit-license.php
-*
-* @version 1.2.0
-*/
-
-/*lint-ignore-start*/
-
-(function (define) {
-    define(function () {
-        var freeze, reduceArray, slice, undef;
-
-        //
-        // Public API
-        //
-
-        when.defer = defer;
-        when.reject = reject;
-        when.isPromise = isPromise;
-
-        when.all = all;
-        when.some = some;
-        when.any = any;
-
-        when.map = map;
-        when.reduce = reduce;
-
-        when.chain = chain;
-
-        /** Object.freeze */
-        freeze = Object.freeze || function (o) { return o; };
-
-        /**
-        * Trusted Promise constructor.  A Promise created from this constructor is
-        * a trusted when.js promise.  Any other duck-typed promise is considered
-        * untrusted.
-        *
-        * @constructor
-        */
-        function Promise() { }
-
-        Promise.prototype = freeze({
-            always: function (alwaysback, progback) {
-                return this.then(alwaysback, alwaysback, progback);
-            },
-
-            otherwise: function (errback) {
-                return this.then(undef, errback);
-            }
-        });
-
-        /**
-        * Create an already-resolved promise for the supplied value
-        * @private
-        *
-        * @param value anything
-        * @return {Promise}
-        */
-        function resolved(value) {
-
-            var p = new Promise();
-
-            p.then = function (callback) {
-                var nextValue;
-                try {
-                    if (callback) nextValue = callback(value);
-                    return promise(nextValue === undef ? value : nextValue);
-                } catch (e) {
-                    return rejected(e);
-                }
-            };
-
-            return freeze(p);
-        }
-
-        /**
-        * Create an already-rejected {@link Promise} with the supplied
-        * rejection reason.
-        * @private
-        *
-        * @param reason rejection reason
-        * @return {Promise}
-        */
-        function rejected(reason) {
-
-            var p = new Promise();
-
-            p.then = function (callback, errback) {
-                var nextValue;
-                try {
-                    if (errback) {
-                        nextValue = errback(reason);
-                        return promise(nextValue === undef ? reason : nextValue)
-                    }
-
-                    return rejected(reason);
-
-                } catch (e) {
-                    return rejected(e);
-                }
-            };
-
-            return freeze(p);
-        }
-
-        /**
-        * Returns a rejected promise for the supplied promiseOrValue. If
-        * promiseOrValue is a value, it will be the rejection value of the
-        * returned promise.  If promiseOrValue is a promise, its
-        * completion value will be the rejected value of the returned promise
-        *
-        * @param promiseOrValue {*} the rejected value of the returned {@link Promise}
-        *
-        * @return {Promise} rejected {@link Promise}
-        */
-        function reject(promiseOrValue) {
-            return when(promiseOrValue, function (value) {
-                return rejected(value);
-            });
-        }
-
-        /**
-        * Creates a new, CommonJS compliant, Deferred with fully isolated
-        * resolver and promise parts, either or both of which may be given out
-        * safely to consumers.
-        * The Deferred itself has the full API: resolve, reject, progress, and
-        * then. The resolver has resolve, reject, and progress.  The promise
-        * only has then.
-        *
-        * @memberOf when
-        * @function
-        *
-        * @returns {Deferred}
-        */
-        function defer() {
-            var deferred, promise, listeners, progressHandlers, _then, _progress, complete;
-
-            listeners = [];
-            progressHandlers = [];
-
-            /**
-            * Pre-resolution then() that adds the supplied callback, errback, and progback
-            * functions to the registered listeners
-            *
-            * @private
-            *
-            * @param [callback] {Function} resolution handler
-            * @param [errback] {Function} rejection handler
-            * @param [progback] {Function} progress handler
-            *
-            * @throws {Error} if any argument is not null, undefined, or a Function
-            */
-            _then = function unresolvedThen(callback, errback, progback) {
-                var deferred = defer();
-
-                listeners.push(function (promise) {
-                    promise.then(callback, errback)
-					.then(deferred.resolve, deferred.reject, deferred.progress);
-                });
-
-                progback && progressHandlers.push(progback);
-
-                return deferred.promise;
-            };
-
-            /**
-            * Registers a handler for this {@link Deferred}'s {@link Promise}.  Even though all arguments
-            * are optional, each argument that *is* supplied must be null, undefined, or a Function.
-            * Any other value will cause an Error to be thrown.
-            *
-            * @memberOf Promise
-            *
-            * @param [callback] {Function} resolution handler
-            * @param [errback] {Function} rejection handler
-            * @param [progback] {Function} progress handler
-            *
-            * @throws {Error} if any argument is not null, undefined, or a Function
-            */
-            function then(callback, errback, progback) {
-                return _then(callback, errback, progback);
-            }
-
-            /**
-            * Resolves this {@link Deferred}'s {@link Promise} with val as the
-            * resolution value.
-            *
-            * @memberOf Resolver
-            *
-            * @param val anything
-            */
-            function resolve(val) {
-                complete(resolved(val));
-            }
-
-            /**
-            * Rejects this {@link Deferred}'s {@link Promise} with err as the
-            * reason.
-            *
-            * @memberOf Resolver
-            *
-            * @param err anything
-            */
-            function reject(err) {
-                complete(rejected(err));
-            }
-
-            /**
-            * @private
-            * @param update
-            */
-            _progress = function (update) {
-                var progress, i = 0;
-                while (progress = progressHandlers[i++]) progress(update);
-            };
-
-            /**
-            * Emits a progress update to all progress observers registered with
-            * this {@link Deferred}'s {@link Promise}
-            *
-            * @memberOf Resolver
-            *
-            * @param update anything
-            */
-            function progress(update) {
-                _progress(update);
-            }
-
-            /**
-            * Transition from pre-resolution state to post-resolution state, notifying
-            * all listeners of the resolution or rejection
-            *
-            * @private
-            *
-            * @param completed {Promise} the completed value of this deferred
-            */
-            complete = function (completed) {
-                var listener, i = 0;
-
-                // Replace _then with one that directly notifies with the result.
-                _then = completed.then;
-
-                // Replace complete so that this Deferred can only be completed
-                // once. Also Replace _progress, so that subsequent attempts to issue
-                // progress throw.
-                complete = _progress = function alreadyCompleted() {
-                    // TODO: Consider silently returning here so that parties who
-                    // have a reference to the resolver cannot tell that the promise
-                    // has been resolved using try/catch
-                    throw new Error("already completed");
-                };
-
-                // Free progressHandlers array since we'll never issue progress events
-                // for this promise again now that it's completed
-                progressHandlers = undef;
-
-                // Notify listeners
-                // Traverse all listeners registered directly with this Deferred
-
-                while (listener = listeners[i++]) {
-                    listener(completed);
-                }
-
-                listeners = [];
-            };
-
-            /**
-            * The full Deferred object, with both {@link Promise} and {@link Resolver}
-            * parts
-            * @class Deferred
-            * @name Deferred
-            */
-            deferred = {};
-
-            // Promise and Resolver parts
-            // Freeze Promise and Resolver APIs
-
-            promise = new Promise();
-            promise.then = deferred.then = then;
-
-            /**
-            * The {@link Promise} for this {@link Deferred}
-            * @memberOf Deferred
-            * @name promise
-            * @type {Promise}
-            */
-            deferred.promise = freeze(promise);
-
-            /**
-            * The {@link Resolver} for this {@link Deferred}
-            * @memberOf Deferred
-            * @name resolver
-            * @class Resolver
-            */
-            deferred.resolver = freeze({
-                resolve: (deferred.resolve = resolve),
-                reject: (deferred.reject = reject),
-                progress: (deferred.progress = progress)
-            });
-
-            return deferred;
-        }
-
-        /**
-        * Determines if promiseOrValue is a promise or not.  Uses the feature
-        * test from http://wiki.commonjs.org/wiki/Promises/A to determine if
-        * promiseOrValue is a promise.
-        *
-        * @param promiseOrValue anything
-        *
-        * @returns {Boolean} true if promiseOrValue is a {@link Promise}
-        */
-        function isPromise(promiseOrValue) {
-            return promiseOrValue && typeof promiseOrValue.then === 'function';
-        }
-
-        /**
-        * Register an observer for a promise or immediate value.
-        *
-        * @function
-        * @name when
-        * @namespace
-        *
-        * @param promiseOrValue anything
-        * @param {Function} [callback] callback to be called when promiseOrValue is
-        *   successfully resolved.  If promiseOrValue is an immediate value, callback
-        *   will be invoked immediately.
-        * @param {Function} [errback] callback to be called when promiseOrValue is
-        *   rejected.
-        * @param {Function} [progressHandler] callback to be called when progress updates
-        *   are issued for promiseOrValue.
-        *
-        * @returns {Promise} a new {@link Promise} that will complete with the return
-        *   value of callback or errback or the completion value of promiseOrValue if
-        *   callback and/or errback is not supplied.
-        */
-        function when(promiseOrValue, callback, errback, progressHandler) {
-            // Get a promise for the input promiseOrValue
-            // See promise()
-            var trustedPromise = promise(promiseOrValue);
-
-            // Register promise handlers
-            return trustedPromise.then(callback, errback, progressHandler);
-        }
-
-        /**
-        * Returns promiseOrValue if promiseOrValue is a {@link Promise}, a new Promise if
-        * promiseOrValue is a foreign promise, or a new, already-resolved {@link Promise}
-        * whose resolution value is promiseOrValue if promiseOrValue is an immediate value.
-        *
-        * Note that this function is not safe to export since it will return its
-        * input when promiseOrValue is a {@link Promise}
-        *
-        * @private
-        *
-        * @param promiseOrValue anything
-        *
-        * @returns Guaranteed to return a trusted Promise.  If promiseOrValue is a when.js {@link Promise}
-        *   returns promiseOrValue, otherwise, returns a new, already-resolved, when.js {@link Promise}
-        *   whose resolution value is:
-        *   * the resolution value of promiseOrValue if it's a foreign promise, or
-        *   * promiseOrValue if it's a value
-        */
-        function promise(promiseOrValue) {
-            var promise, deferred;
-
-            if (promiseOrValue instanceof Promise) {
-                // It's a when.js promise, so we trust it
-                promise = promiseOrValue;
-
-            } else {
-                // It's not a when.js promise.  Check to see if it's a foreign promise
-                // or a value.
-
-                deferred = defer();
-                if (isPromise(promiseOrValue)) {
-                    // It's a compliant promise, but we don't know where it came from,
-                    // so we don't trust its implementation entirely.  Introduce a trusted
-                    // middleman when.js promise
-
-                    // IMPORTANT: This is the only place when.js should ever call .then() on
-                    // an untrusted promise.
-                    promiseOrValue.then(deferred.resolve, deferred.reject, deferred.progress);
-                    promise = deferred.promise;
-
-                } else {
-                    // It's a value, not a promise.  Create an already-resolved promise
-                    // for it.
-                    deferred.resolve(promiseOrValue);
-                    promise = deferred.promise;
-                }
-            }
-
-            return promise;
-        }
-
-        /**
-        * Return a promise that will resolve when howMany of the supplied promisesOrValues
-        * have resolved. The resolution value of the returned promise will be an array of
-        * length howMany containing the resolutions values of the triggering promisesOrValues.
-        *
-        * @memberOf when
-        *
-        * @param promisesOrValues {Array} array of anything, may contain a mix
-        *      of {@link Promise}s and values
-        * @param howMany
-        * @param [callback]
-        * @param [errback]
-        * @param [progressHandler]
-        *
-        * @returns {Promise}
-        */
-        function some(promisesOrValues, howMany, callback, errback, progressHandler) {
-
-            checkCallbacks(2, arguments);
-
-            return when(promisesOrValues, function (promisesOrValues) {
-
-                var toResolve, results, ret, deferred, resolver, rejecter, handleProgress, len, i;
-
-                len = promisesOrValues.length >>> 0;
-
-                toResolve = Math.max(0, Math.min(howMany, len));
-                results = [];
-                deferred = defer();
-                ret = when(deferred, callback, errback, progressHandler);
-
-                // Wrapper so that resolver can be replaced
-                function resolve(val) {
-                    resolver(val);
-                }
-
-                // Wrapper so that rejecter can be replaced
-                function reject(err) {
-                    rejecter(err);
-                }
-
-                // Wrapper so that progress can be replaced
-                function progress(update) {
-                    handleProgress(update);
-                }
-
-                function complete() {
-                    resolver = rejecter = handleProgress = noop;
-                }
-
-                // No items in the input, resolve immediately
-                if (!toResolve) {
-                    deferred.resolve(results);
-
-                } else {
-                    // Resolver for promises.  Captures the value and resolves
-                    // the returned promise when toResolve reaches zero.
-                    // Overwrites resolver var with a noop once promise has
-                    // be resolved to cover case where n < promises.length
-                    resolver = function (val) {
-                        // This orders the values based on promise resolution order
-                        // Another strategy would be to use the original position of
-                        // the corresponding promise.
-                        results.push(val);
-
-                        if (! --toResolve) {
-                            complete();
-                            deferred.resolve(results);
-                        }
-                    };
-
-                    // Rejecter for promises.  Rejects returned promise
-                    // immediately, and overwrites rejecter var with a noop
-                    // once promise to cover case where n < promises.length.
-                    // TODO: Consider rejecting only when N (or promises.length - N?)
-                    // promises have been rejected instead of only one?
-                    rejecter = function (err) {
-                        complete();
-                        deferred.reject(err);
-                    };
-
-                    handleProgress = deferred.progress;
-
-                    // TODO: Replace while with forEach
-                    for (i = 0; i < len; ++i) {
-                        if (i in promisesOrValues) {
-                            when(promisesOrValues[i], resolve, reject, progress);
-                        }
-                    }
-                }
-
-                return ret;
-            });
-        }
-
-        /**
-        * Return a promise that will resolve only once all the supplied promisesOrValues
-        * have resolved. The resolution value of the returned promise will be an array
-        * containing the resolution values of each of the promisesOrValues.
-        *
-        * @memberOf when
-        *
-        * @param promisesOrValues {Array|Promise} array of anything, may contain a mix
-        *      of {@link Promise}s and values
-        * @param [callback] {Function}
-        * @param [errback] {Function}
-        * @param [progressHandler] {Function}
-        *
-        * @returns {Promise}
-        */
-        function all(promisesOrValues, callback, errback, progressHandler) {
-
-            checkCallbacks(1, arguments);
-
-            return when(promisesOrValues, function (promisesOrValues) {
-                return _reduce(promisesOrValues, reduceIntoArray, []);
-            }).then(callback, errback, progressHandler);
-        }
-
-        function reduceIntoArray(current, val, i) {
-            current[i] = val;
-            return current;
-        }
-
-        /**
-        * Return a promise that will resolve when any one of the supplied promisesOrValues
-        * has resolved. The resolution value of the returned promise will be the resolution
-        * value of the triggering promiseOrValue.
-        *
-        * @memberOf when
-        *
-        * @param promisesOrValues {Array|Promise} array of anything, may contain a mix
-        *      of {@link Promise}s and values
-        * @param [callback] {Function}
-        * @param [errback] {Function}
-        * @param [progressHandler] {Function}
-        *
-        * @returns {Promise}
-        */
-        function any(promisesOrValues, callback, errback, progressHandler) {
-
-            function unwrapSingleResult(val) {
-                return callback ? callback(val[0]) : val[0];
-            }
-
-            return some(promisesOrValues, 1, unwrapSingleResult, errback, progressHandler);
-        }
-
-        /**
-        * Traditional map function, similar to `Array.prototype.map()`, but allows
-        * input to contain {@link Promise}s and/or values, and mapFunc may return
-        * either a value or a {@link Promise}
-        *
-        * @memberOf when
-        *
-        * @param promise {Array|Promise} array of anything, may contain a mix
-        *      of {@link Promise}s and values
-        * @param mapFunc {Function} mapping function mapFunc(value) which may return
-        *      either a {@link Promise} or value
-        *
-        * @returns {Promise} a {@link Promise} that will resolve to an array containing
-        *      the mapped output values.
-        */
-        function map(promise, mapFunc) {
-            return when(promise, function (array) {
-                return _map(array, mapFunc);
-            });
-        }
-
-        /**
-        * Private map helper to map an array of promises
-        * @private
-        *
-        * @param promisesOrValues {Array}
-        * @param mapFunc {Function}
-        * @return {Promise}
-        */
-        function _map(promisesOrValues, mapFunc) {
-
-            var results, len, i;
-
-            // Since we know the resulting length, we can preallocate the results
-            // array to avoid array expansions.
-            len = promisesOrValues.length >>> 0;
-            results = new Array(len);
-
-            // Since mapFunc may be async, get all invocations of it into flight
-            // asap, and then use reduce() to collect all the results
-            for (i = 0; i < len; i++) {
-                if (i in promisesOrValues)
-                    results[i] = when(promisesOrValues[i], mapFunc);
-            }
-
-            // Could use all() here, but that would result in another array
-            // being allocated, i.e. map() would end up allocating 2 arrays
-            // of size len instead of just 1.  Since all() uses reduce()
-            // anyway, avoid the additional allocation by calling reduce
-            // directly.
-            return _reduce(results, reduceIntoArray, results);
-        }
-
-        /**
-        * Traditional reduce function, similar to `Array.prototype.reduce()`, but
-        * input may contain {@link Promise}s and/or values, and reduceFunc
-        * may return either a value or a {@link Promise}, *and* initialValue may
-        * be a {@link Promise} for the starting value.
-        *
-        * @memberOf when
-        *
-        * @param promise {Array|Promise} array of anything, may contain a mix
-        *      of {@link Promise}s and values.  May also be a {@link Promise} for
-        *      an array.
-        * @param reduceFunc {Function} reduce function reduce(currentValue, nextValue, index, total),
-        *      where total is the total number of items being reduced, and will be the same
-        *      in each call to reduceFunc.
-        * @param initialValue starting value, or a {@link Promise} for the starting value
-        *
-        * @returns {Promise} that will resolve to the final reduced value
-        */
-        function reduce(promise, reduceFunc, initialValue) {
-            var args = slice.call(arguments, 1);
-            return when(promise, function (array) {
-                return _reduce.apply(undef, [array].concat(args));
-            });
-        }
-
-        /**
-        * Private reduce to reduce an array of promises
-        * @private
-        *
-        * @param promisesOrValues {Array}
-        * @param reduceFunc {Function}
-        * @param initialValue {*}
-        * @return {Promise}
-        */
-        function _reduce(promisesOrValues, reduceFunc, initialValue) {
-
-            var total, args;
-
-            total = promisesOrValues.length;
-
-            // Skip promisesOrValues, since it will be used as 'this' in the call
-            // to the actual reduce engine below.
-
-            // Wrap the supplied reduceFunc with one that handles promises and then
-            // delegates to the supplied.
-
-            args = [
-			function (current, val, i) {
-			    return when(current, function (c) {
-			        return when(val, function (value) {
-			            return reduceFunc(c, value, i, total);
-			        });
-			    });
-			}
-		];
-
-            if (arguments.length > 2) args.push(initialValue);
-
-            return reduceArray.apply(promisesOrValues, args);
-        }
-
-        /**
-        * Ensure that resolution of promiseOrValue will complete resolver with the completion
-        * value of promiseOrValue, or instead with resolveValue if it is provided.
-        *
-        * @memberOf when
-        *
-        * @param promiseOrValue
-        * @param resolver {Resolver}
-        * @param [resolveValue] anything
-        *
-        * @returns {Promise}
-        */
-        function chain(promiseOrValue, resolver, resolveValue) {
-            var useResolveValue = arguments.length > 2;
-
-            return when(promiseOrValue,
-			function (val) {
-			    if (useResolveValue) val = resolveValue;
-			    resolver.resolve(val);
-			    return val;
-			},
-			function (e) {
-			    resolver.reject(e);
-			    return rejected(e);
-			},
-			resolver.progress
-		);
-        }
-
-        //
-        // Utility functions
-        //
-
-        /**
-        * Helper that checks arrayOfCallbacks to ensure that each element is either
-        * a function, or null or undefined.
-        *
-        * @private
-        *
-        * @param arrayOfCallbacks {Array} array to check
-        * @throws {Error} if any element of arrayOfCallbacks is something other than
-        * a Functions, null, or undefined.
-        */
-        function checkCallbacks(start, arrayOfCallbacks) {
-            var arg, i = arrayOfCallbacks.length;
-            while (i > start) {
-                arg = arrayOfCallbacks[--i];
-                if (arg != null && typeof arg != 'function') throw new Error('callback is not a function');
-            }
-        }
-
-        /**
-        * No-Op function used in method replacement
-        * @private
-        */
-        function noop() { }
-
-        slice = [].slice;
-
-        // ES5 reduce implementation if native not available
-        // See: http://es5.github.com/#x15.4.4.21 as there are many
-        // specifics and edge cases.
-        reduceArray = [].reduce ||
-		function (reduceFunc /*, initialValue */) {
-		    // ES5 dictates that reduce.length === 1
-
-		    // This implementation deviates from ES5 spec in the following ways:
-		    // 1. It does not check if reduceFunc is a Callable
-
-		    var arr, args, reduced, len, i;
-
-		    i = 0;
-		    arr = Object(this);
-		    len = arr.length >>> 0;
-		    args = arguments;
-
-		    // If no initialValue, use first item of array (we know length !== 0 here)
-		    // and adjust i to start at second item
-		    if (args.length <= 1) {
-		        // Skip to the first real element in the array
-		        for (; ; ) {
-		            if (i in arr) {
-		                reduced = arr[i++];
-		                break;
-		            }
-
-		            // If we reached the end of the array without finding any real
-		            // elements, it's a TypeError
-		            if (++i >= len) {
-		                throw new TypeError();
-		            }
-		        }
-		    } else {
-		        // If initialValue provided, use it
-		        reduced = args[1];
-		    }
-
-		    // Do the actual reduce
-		    for (; i < len; ++i) {
-		        // Skip holes
-		        if (i in arr)
-		            reduced = reduceFunc(reduced, arr[i], i, arr);
-		    }
-
-		    return reduced;
-		};
-
-        return when;
-    });
-})(typeof define == 'function'
-	? define
-	: function (factory) {
-	    typeof module != 'undefined'
-		? (module.exports = factory())
-		: (jQuery.mapster_when = factory());
-	}
-// Boilerplate for AMD, Node, and browser global
-);
-/*lint-ignore-end*/
-/* ImageMapster core */
-
-/*jslint laxbreak: true, evil: true, unparam: true */
-
-/*global jQuery: true, Zepto: true */
-
-
-(function ($) {
-    // all public functions in $.mapster.impl are methods
-    $.fn.mapster = function (method) {
-        var m = $.mapster.impl;
-        if ($.isFunction(m[method])) {
-            return m[method].apply(this, Array.prototype.slice.call(arguments, 1));
-        } else if (typeof method === 'object' || !method) {
-            return m.bind.apply(this, arguments);
-        } else {
-            $.error('Method ' + method + ' does not exist on jQuery.mapster');
-        }
-    };
-
-    $.mapster = {
-        version: "1.2.10",
-        render_defaults: {
-            isSelectable: true,
-            isDeselectable: true,
-            fade: false,
-            fadeDuration: 150,
-            fill: true,
-            fillColor: '000000',
-            fillColorMask: 'FFFFFF',
-            fillOpacity: 0.7,
-            highlight: true,
-            stroke: false,
-            strokeColor: 'ff0000',
-            strokeOpacity: 1,
-            strokeWidth: 1,
-            includeKeys: '',
-            altImage: null,
-            altImageId: null, // used internally            
-            altImages: {} 
-        },
-        defaults: {
-            clickNavigate: false,
-            wrapClass: null,
-            wrapCss: null,
-            onGetList: null,
-            sortList: false,
-            listenToList: false,
-            mapKey: '',
-            mapValue: '',
-            singleSelect: false,
-            listKey: 'value',
-            listSelectedAttribute: 'selected',
-            listSelectedClass: null,
-            onClick: null,
-            onMouseover: null,
-            onMouseout: null,
-            mouseoutDelay: 0,
-            onStateChange: null,
-            boundList: null,
-            onConfigured: null,
-            configTimeout: 30000,
-            noHrefIsMask: true,
-            scaleMap: true,
-            safeLoad: false,
-            areas: []
-        },
-        shared_defaults: {
-            render_highlight: { fade: true },
-            render_select: { fade: false },
-            staticState: null,
-            selected: null
-        },
-        area_defaults:
-        {
-            includeKeys: '',
-            isMask: false
-        },
-        canvas_style: {
-            position: 'absolute',
-            left: 0,
-            top: 0,
-            padding: 0,
-            border: 0
-        },
-        hasCanvas: null,
-        isTouch: null,
-        map_cache: [],
-        hooks: {},
-        addHook: function(name,callback) {
-            this.hooks[name]=(this.hooks[name]||[]).push(callback);
-        },
-        callHooks: function(name,context) {
-            $.each(this.hooks[name]||[],function(i,e) {
-                e.apply(context);
-            });
-        },
-        utils: {
-            when: $.mapster_when,
-            defer: $.mapster_when.defer,
-
-            // extends the constructor, returns a new object prototype. Does not refer to the
-            // original constructor so is protected if the original object is altered. This way you
-            // can "extend" an object by replacing it with its subclass.
-            subclass: function(BaseClass, constr) {
-                var Subclass=function() {
-                    var me=this, 
-                        args=Array.prototype.slice.call(arguments,0);
-                    me.base = BaseClass.prototype;
-                    me.base.init = function() {
-                        BaseClass.prototype.constructor.apply(me,args);
-                    };
-                    constr.apply(me,args);
-                };
-                Subclass.prototype = new BaseClass();
-                Subclass.prototype.constructor=Subclass;
-                return Subclass;
-            },
-            asArray: function (obj) {
-                return obj.constructor === Array ?
-                    obj : this.split(obj);
-            },
-            // clean split: no padding or empty elements
-            split: function (text,cb) {
-                var i,el, arr = text.split(',');
-                for (i = 0; i < arr.length; i++) {
-                    el = $.trim(arr[i]);
-                    if (el==='') {
-                        arr.splice(i,1);
-                    } else {
-                        arr[i] = cb ? cb(el):el;
-                    }
-                }
-                return arr;
-            },
-            // similar to $.extend but does not add properties (only updates), unless the
-            // first argument is an empty object, then all properties will be copied
-            updateProps: function (_target, _template) {
-                var onlyProps,
-                    target = _target || {},
-                    template = $.isEmptyObject(target) ? _template : _target;
-
-                //if (template) {
-                onlyProps = [];
-                $.each(template, function (prop) {
-                    onlyProps.push(prop);
-                });
-                //}
-
-                $.each(Array.prototype.slice.call(arguments, 1), function (i, src) {
-                    $.each(src || {}, function (prop) {
-                        if (!onlyProps || $.inArray(prop, onlyProps) >= 0) {
-                            var p = src[prop];
-
-                            if ($.isPlainObject(p)) {
-                                // not recursive - only copies 1 level of subobjects, and always merges
-                                target[prop] = $.extend(target[prop] || {}, p);
-                            } else if (p && p.constructor === Array) {
-                                target[prop] = p.slice(0);
-                            } else if (typeof p !== 'undefined') {
-                                target[prop] = src[prop];
-                            }
-
-                        }
-                    });
-                });
-                return target;
-            },
-            isElement: function (o) {
-                return (typeof HTMLElement === "object" ? o instanceof HTMLElement :
-                        o && typeof o === "object" && o.nodeType === 1 && typeof o.nodeName === "string");
-            },
-            // finds element of array or object with a property "prop" having value "val"
-            // if prop is not defined, then just looks for property with value "val"
-            indexOfProp: function (obj, prop, val) {
-                var result = obj.constructor === Array ? -1 : null;
-                $.each(obj, function (i, e) {
-                    if (e && (prop ? e[prop] : e) === val) {
-                        result = i;
-                        return false;
-                    }
-                });
-                return result;
-            },
-            // returns "obj" if true or false, or "def" if not true/false
-            boolOrDefault: function (obj, def) {
-                return this.isBool(obj) ?
-                        obj : def || false;
-            },
-            isBool: function (obj) {
-                return typeof obj === "boolean";
-            },
-            isUndef: function(obj) {
-                return typeof obj === "undefined";
-            },
-            // evaluates "obj", if function, calls it with args
-            // (todo - update this to handle variable lenght/more than one arg)
-            ifFunction: function (obj, that, args) {
-                if ($.isFunction(obj)) {
-                    obj.call(that, args);
-                }
-            },
-            size: function(image, raw) {
-                var u=$.mapster.utils;
-                return { 
-                    width: raw ? (image.width || image.naturalWidth) : u.imgWidth(image,true) ,
-                    height: raw ? (image.height || image.naturalHeight) : u.imgHeight(image,true),
-                    complete: function() { return !!this.height && !!this.width;}
-                };
-            },
-
-                
-            /**
-             * Set the opacity of the element. This is an IE<8 specific function for handling VML.
-             * When using VML we must override the "setOpacity" utility function (monkey patch ourselves).
-             * jQuery does not deal with opacity correctly for VML elements. This deals with that.
-             * 
-             * @param {Element} el The DOM element
-             * @param {double} opacity A value between 0 and 1 inclusive.
-             */
-
-            setOpacity: function (el, opacity) {
-                if ($.mapster.hasCanvas()) {
-                    el.style.opacity = opacity;
-                } else {
-                    $(el).each(function(i,e) {
-                        if (typeof e.opacity !=='undefined') {
-                           e.opacity=opacity;
-                        } else {
-                            $(e).css("opacity",opacity);
-                        }
-                    });
-                }
-            },
-
-
-            // fade "el" from opacity "op" to "endOp" over a period of time "duration"
-            
-            fader: (function () {
-                var elements = {},
-                        lastKey = 0,
-                        fade_func = function (el, op, endOp, duration) {
-                            var index, 
-                                cbIntervals = duration/15,
-                                obj, u = $.mapster.utils;
-
-                            if (typeof el === 'number') {
-                                obj = elements[el];
-                                if (!obj) {
-                                    return;
-                                }
-                            } else {
-                                index = u.indexOfProp(elements, null, el);
-                                if (index) {
-                                    delete elements[index];
-                                }
-                                elements[++lastKey] = obj = el;
-                                el = lastKey;
-                            }
-
-                            endOp = endOp || 1;
-
-                            op = (op + (endOp / cbIntervals) > endOp - 0.01) ? endOp : op + (endOp / cbIntervals);
-
-                            u.setOpacity(obj, op);
-                            if (op < endOp) {
-                                setTimeout(function () {
-                                    fade_func(el, op, endOp, duration);
-                                }, 15);
-                            }
-                        };
-                return fade_func;
-            } ())
-        },
-        getBoundList: function (opts, key_list) {
-            if (!opts.boundList) {
-                return null;
-            }
-            var index, key, result = $(), list = $.mapster.utils.split(key_list);
-            opts.boundList.each(function (i,e) {
-                for (index = 0; index < list.length; index++) {
-                    key = list[index];
-                    if ($(e).is('[' + opts.listKey + '="' + key + '"]')) {
-                        result = result.add(e);
-                    }
-                }
-            });
-            return result;
-        },
-        // Causes changes to the bound list based on the user action (select or deselect)
-        // area: the jQuery area object
-        // returns the matching elements from the bound list for the first area passed (normally only one should be passed, but
-        // a list can be passed
-        setBoundListProperties: function (opts, target, selected) {
-            target.each(function (i,e) {
-                if (opts.listSelectedClass) {
-                    if (selected) {
-                        $(e).addClass(opts.listSelectedClass);
-                    } else {
-                        $(e).removeClass(opts.listSelectedClass);
-                    }
-                }
-                if (opts.listSelectedAttribute) {
-                    $(e).attr(opts.listSelectedAttribute, selected);
-                }
-            });
-        },
-        getMapDataIndex: function (obj) {
-            var img, id;
-            switch (obj.tagName && obj.tagName.toLowerCase()) {
-                case 'area':
-                    id = $(obj).parent().attr('name');
-                    img = $("img[usemap='#" + id + "']")[0];
-                    break;
-                case 'img':
-                    img = obj;
-                    break;
-            }
-            return img ?
-                this.utils.indexOfProp(this.map_cache, 'image', img) : -1;
-        },
-        getMapData: function (obj) {
-            var index = this.getMapDataIndex(obj.length ? obj[0]:obj);
-            if (index >= 0) {
-                return index >= 0 ? this.map_cache[index] : null;
-            }
-        },
-        /**
-         * Queue a command to be run after the active async operation has finished
-         * @param  {MapData}  map_data    The target MapData object
-         * @param  {jQuery}   that        jQuery object on which the command was invoked
-         * @param  {string}   command     the ImageMapster method name
-         * @param  {object[]} args        arguments passed to the method
-         * @return {bool}                 true if the command was queued, false if not (e.g. there was no need to)
-         */
-        queueCommand: function (map_data, that, command, args) {
-            if (!map_data) {
-                return false;
-            }
-            if (!map_data.complete || map_data.currentAction) {
-                map_data.commands.push(
-                {
-                    that: that,
-                    command: command,
-                    args: args
-                });
-                return true;
-            }
-            return false;
-        },
-        unload: function () {
-            this.impl.unload();
-            this.utils = null;
-            this.impl = null;
-            $.fn.mapster = null;
-            $.mapster = null;
-            $('*').unbind();
-        }
-    };
-
-    // Config for object prototypes
-    // first: use only first object (for things that should not apply to lists)
-    /// calls back one of two fuinctions, depending on whether an area was obtained.
-    // opts: {
-    //    name: 'method name',
-    //    key: 'key,
-    //    args: 'args'
-    //
-    //}
-    // name: name of method (required)
-    // args: arguments to re-call with
-    // Iterates through all the objects passed, and determines whether it's an area or an image, and calls the appropriate
-    // callback for each. If anything is returned from that callback, the process is stopped and that data return. Otherwise,
-    // the object itself is returned.
-    
-    var m = $.mapster, 
-        u = m.utils,
-        ap = Array.prototype;
-
-
-    // jQuery's width() and height() are broken on IE9 in some situations. This tries everything. 
-    $.each(["width","height"],function(i,e) {
-        var capProp = e.substr(0,1).toUpperCase() + e.substr(1);
-        // when jqwidth parm is passed, it also checks the jQuery width()/height() property
-        // the issue is that jQUery width() can report a valid size before the image is loaded in some browsers
-        // without it, we can read zero even when image is loaded in other browsers if its not visible
-        // we must still check because stuff like adblock can temporarily block it
-        // what a goddamn headache
-        u["img"+capProp]=function(img,jqwidth) {
-                return (jqwidth ? $(img)[e]() : 0) || 
-                    img[e] || img["natural"+capProp] || img["client"+capProp] || img["offset"+capProp];
-        };
-     
-    });    
-
-    /**
-     * The Method object encapsulates the process of testing an ImageMapster method to see if it's being
-     * invoked on an image, or an area; then queues the command if the MapData is in an active state.
-     * 
-     * @param {[jQuery]}    that        The target of the invocation
-     * @param {[function]}  func_map    The callback if the target is an imagemap
-     * @param {[function]}  func_area   The callback if the target is an area
-     * @param {[object]}    opt         Options: { key: a map key if passed explicitly
-     *                                             name: the command name, if it can be queued,
-     *                                             args: arguments to the method
-     *                                            }
-     */
-    
-    m.Method = function (that, func_map, func_area, opts) {
-        var me = this;
-        me.name = opts.name;
-        me.output = that;
-        me.input = that;
-        me.first = opts.first || false;
-        me.args = opts.args ? ap.slice.call(opts.args, 0) : [];
-        me.key = opts.key;
-        me.func_map = func_map;
-        me.func_area = func_area;
-        //$.extend(me, opts);
-        me.name = opts.name;
-        me.allowAsync = opts.allowAsync || false;
-    };
-    m.Method.prototype = {
-        constructor: m.Method,
-        go: function () {
-            var i,  data, ar, len, result, src = this.input,
-                    area_list = [],
-                    me = this;
-
-            len = src.length;
-            for (i = 0; i < len; i++) {
-                data = $.mapster.getMapData(src[i]);
-                if (data) {
-                    if (!me.allowAsync && m.queueCommand(data, me.input, me.name, me.args)) {
-                        if (this.first) {
-                            result = '';
-                        }
-                        continue;
-                    }
-                    
-                    ar = data.getData(src[i].nodeName === 'AREA' ? src[i] : this.key);
-                    if (ar) {
-                        if ($.inArray(ar, area_list) < 0) {
-                            area_list.push(ar);
-                        }
-                    } else {
-                        result = this.func_map.apply(data, me.args);
-                    }
-                    if (this.first || typeof result !== 'undefined') {
-                        break;
-                    }
-                }
-            }
-            // if there were areas, call the area function for each unique group
-            $(area_list).each(function (i,e) {
-                result = me.func_area.apply(e, me.args);
-            });
-
-            if (typeof result !== 'undefined') {
-                return result;
-            } else {
-                return this.output;
-            }
-        }
-    };
-
-    $.mapster.impl = (function () {
-        var me = {},
-        addMap= function (map_data) {
-            return m.map_cache.push(map_data) - 1;
-        },
-        removeMap = function (map_data) {
-            m.map_cache.splice(map_data.index, 1);
-            for (var i = m.map_cache.length - 1; i >= this.index; i--) {
-                m.map_cache[i].index--;
-            }
-        };
-
-        
-        /**
-         * Test whether the browser supports VML. Credit: google.
-         * http://stackoverflow.com/questions/654112/how-do-you-detect-support-for-vml-or-svg-in-a-browser
-         * 
-         * @return {bool} true if vml is supported, false if not
-         */
-        
-        function hasVml() {
-            var a = $('<div />').appendTo('body');
-            a.html('<v:shape id="vml_flag1" adj="1" />');
-            
-            var b = a[0].firstChild;
-            b.style.behavior = "url(#default#VML)";
-            var has = b ? typeof b.adj === "object" : true;
-            a.remove();
-            return has;
-        }
-
-        /**
-         * Return a reference to the IE namespaces object, if available, or an empty object otherwise
-         * @return {obkect} The document.namespaces object.
-         */
-        function namespaces() {
-            return typeof(document.namespaces)==='object' ?
-                document.namespaces :
-                null;
-        }
-
-        /**
-         * Test for the presence of HTML5 Canvas support. This also checks to see if excanvas.js has been 
-         * loaded and is faking it; if so, we assume that canvas is not supported.
-         *
-         * @return {bool} true if HTML5 canvas support, false if not
-         */
-        
-        function hasCanvas() {
-            var d = namespaces();
-            // when g_vml_ is present, then we can be sure excanvas is active, meaning there's not a real canvas.
-            
-             return d && d.g_vml_ ? 
-                false :
-                $('<canvas />')[0].getContext ? 
-                    true : 
-                    false;
-        }
-
-        /**
-         * Merge new area data into existing area options on a MapData object. Used for rebinding.
-         * 
-         * @param  {[MapData]} map_data     The MapData object
-         * @param  {[object[]]} areas       areas array to merge
-         */
-        
-        function merge_areas(map_data, areas) {
-            var ar, index,
-                map_areas = map_data.options.areas;
-
-            if (areas) {
-                $.each(areas, function (i, e) {
-                    
-                    // Issue #68 - ignore invalid data in areas array
-                    
-                    if (!e || !e.key) { 
-                        return;
-                    }
-
-                    index = u.indexOfProp(map_areas, "key", e.key);
-
-                    if (index >= 0) {
-                        $.extend(map_areas[index], e);
-                    }
-                    else {
-                        map_areas.push(e);
-                    }
-                    ar = map_data.getDataForKey(e.key);
-                    if (ar) {
-                        $.extend(ar.options, e);
-                    }
-                });
-            }
-        }
-        function merge_options(map_data, options) {
-            var temp_opts = u.updateProps({}, options);
-            delete temp_opts.areas;
-
-            u.updateProps(map_data.options, temp_opts);
-
-            merge_areas(map_data, options.areas);
-            // refresh the area_option template
-            u.updateProps(map_data.area_options, map_data.options);
-        }
-
-        // Most methods use the "Method" object which handles figuring out whether it's an image or area called and
-        // parsing key parameters. The constructor wants:
-        // this, the jQuery object
-        // a function that is called when an image was passed (with a this context of the MapData)
-        // a function that is called when an area was passed (with a this context of the AreaData)
-        // options: first = true means only the first member of a jQuery object is handled
-        //          key = the key parameters passed
-        //          defaultReturn: a value to return other than the jQuery object (if its not chainable)
-        //          args: the arguments
-        // Returns a comma-separated list of user-selected areas. "staticState" areas are not considered selected for the purposes of this method.
-        
-        me.get = function (key) {
-            var md = m.getMapData(this);
-            if (!(md && md.complete)) {
-                throw("Can't access data until binding complete.");
-            }
-
-            return (new m.Method(this,
-                function () {
-                    // map_data return
-                    return this.getSelected();
-                },
-                function () {
-                    return this.isSelected();
-                },
-                { name: 'get',
-                    args: arguments,
-                    key: key,
-                    first: true,
-                    allowAsync: true,
-                    defaultReturn: ''
-                }
-            )).go();
-        };
-        me.data = function (key) {
-            return (new m.Method(this,
-                null,
-                function () {
-                    return this;
-                },
-                { name: 'data',
-                    args: arguments,
-                    key: key
-                }
-            )).go();
-        };
-
-
-        // Set or return highlight state.
-        //  $(img).mapster('highlight') -- return highlighted area key, or null if none
-        //  $(area).mapster('highlight') -- highlight an area
-        //  $(img).mapster('highlight','area_key') -- highlight an area
-        //  $(img).mapster('highlight',false) -- remove highlight
-        me.highlight = function (key) {
-            return (new m.Method(this,
-                function () {
-                    if (key === false) {
-                        this.ensureNoHighlight();
-                    } else {
-                        var id = this.highlightId;
-                        return id >= 0 ? this.data[id].key : null;
-                    }
-                },
-                function () {
-                    this.highlight();
-                },
-                { name: 'highlight',
-                    args: arguments,
-                    key: key,
-                    first: true
-                }
-            )).go();
-        };
-        // Return the primary keys for an area or group key.
-        // $(area).mapster('key')
-        // includes all keys (not just primary keys)
-        // $(area).mapster('key',true)
-        // $(img).mapster('key','group-key')
-
-        // $(img).mapster('key','group-key', true)
-        me.keys = function(key,all) {
-            var keyList=[], 
-                md = m.getMapData(this);
-
-            if (!(md && md.complete)) {
-                throw("Can't access data until binding complete.");
-            }
-
-
-            function addUniqueKeys(ad) {
-                var areas,keys=[];
-                if (!all) {
-                    keys.push(ad.key);
-                } else {
-                    areas=ad.areas();
-                    $.each(areas,function(i,e) {
-                        keys=keys.concat(e.keys);
-                    });
-                }
-                $.each(keys,function(i,e) {
-                    if ($.inArray(e,keyList)<0) {
-                        keyList.push(e);                         
-                    }
-                });
-            }
-
-            if (!(md  && md.complete)) {
-                return '';
-            }
-            if (typeof key === 'string') {
-                if (all) {
-                    addUniqueKeys(md.getDataForKey(key));
-                } else {
-                    keyList=[md.getKeysForGroup(key)];
-                }
-            } else {
-                all = key;
-                this.each(function(i,e) {
-                    if (e.nodeName==='AREA') {
-                        addUniqueKeys(md.getDataForArea(e));
-                    }
-                });
-            }
-            return keyList.join(',');
-        
-
-        };
-        me.select = function () {
-            me.set.call(this, true);
-        };
-        me.deselect = function () {
-            me.set.call(this, false);
-        };
-        
-        /**
-         * Select or unselect areas. Areas can be identified by a single string key, a comma-separated list of keys, 
-         * or an array of strings.
-         * 
-         * 
-         * @param {boolean} selected Determines whether areas are selected or deselected
-         * @param {string|string[]} key A string, comma-separated string, or array of strings indicating 
-         *                              the areas to select or deselect
-         * @param {object} options Rendering options to apply when selecting an area
-         */ 
-
-        me.set = function (selected, key, options) {
-            var lastMap, map_data, opts=options,
-                key_list, area_list; // array of unique areas passed
-
-            function setSelection(ar) {
-                if (ar) {
-                    switch (selected) {
-                        case true:
-                            ar.select(opts); break;
-                        case false:
-                            ar.deselect(true); break;
-                        default:
-                            ar.toggle(opts); break;
-                    }
-                }
-            }
-            function addArea(ar) {
-               if (ar && $.inArray(ar, area_list) < 0) {
-                    area_list.push(ar);
-                    key_list+=(key_list===''?'':',')+ar.key;
-                }
-            }
-            // Clean up after a group that applied to the same map
-            function finishSetForMap(map_data) {
-                $.each(area_list, function (i, el) {
-                    setSelection(el);
-                });
-                if (!selected) {
-                    map_data.removeSelectionFinish();
-                }
-                if (map_data.options.boundList) {
-                    m.setBoundListProperties(map_data.options, m.getBoundList(map_data.options, key_list), selected);
-                }            
-            }
-
-            this.filter('img,area').each(function (i,e) {
-                var keys;
-                map_data = m.getMapData(e);
-
-                if (map_data !== lastMap) {
-                    if (lastMap) {
-                       finishSetForMap(lastMap);
-                    }
-
-                    area_list = [];
-                    key_list='';
-                }
-                
-               if (map_data) {
-                    
-                    keys = '';
-                    if (e.nodeName.toUpperCase()==='IMG') {
-                        if (!m.queueCommand(map_data, $(e), 'set', [selected, key, opts])) {
-                            if (key instanceof Array) {
-                                if (key.length) {
-                                    keys = key.join(",");
-                                }
-                            }
-                            else {
-                                keys = key;
-                            }
-
-                            if (keys) {
-                                $.each(u.split(keys), function (i,key) {
-                                    addArea(map_data.getDataForKey(key.toString()));
-                                    lastMap = map_data;
-                                });
-                            }
-                        }
-                    } else {
-                        opts=key;
-                        if (!m.queueCommand(map_data, $(e), 'set', [selected, opts])) {
-                            addArea(map_data.getDataForArea(e));
-                            lastMap = map_data;
-                        }
-                    
-                    }
-                }
-            });
-            
-            if (map_data) {
-               finishSetForMap(map_data);
-            }
-
-           
-            return this;
-        };
-        me.unbind = function (preserveState) {
-            return (new m.Method(this,
-                function () {
-                    this.clearEvents();
-                    this.clearMapData(preserveState);
-                    removeMap(this);
-                },
-                null,
-                { name: 'unbind',
-                    args: arguments
-                }
-            )).go();
-        };
-
-
-        // refresh options and update selection information.
-        me.rebind = function (options) {
-            return (new m.Method(this,
-                function () {
-                    var me=this;
-
-                    me.complete=false;
-                    me.configureOptions(options);
-                    me.bindImages().then(function() {
-                        me.buildDataset(true);
-                        me.complete=true;
-                    });
-                    //this.redrawSelections();
-                },
-                null,
-                {
-                    name: 'rebind',
-                    args: arguments
-                }
-            )).go();
-        };
-        // get options. nothing or false to get, or "true" to get effective options (versus passed options)
-        me.get_options = function (key, effective) {
-            var eff = u.isBool(key) ? key : effective; // allow 2nd parm as "effective" when no key
-            return (new m.Method(this,
-                function () {
-                    var opts = $.extend({}, this.options);
-                    if (eff) {
-                        opts.render_select = u.updateProps(
-                            {},
-                            m.render_defaults,
-                            opts,
-                            opts.render_select);
-
-                        opts.render_highlight = u.updateProps(
-                            {},
-                            m.render_defaults,
-                            opts,
-                            opts.render_highlight);
-                    }
-                    return opts;
-                },
-                function () {
-                    return eff ? this.effectiveOptions() : this.options;
-                },
-                {
-                    name: 'get_options',
-                    args: arguments,
-                    first: true,
-                    allowAsync: true,
-                    key: key
-                }
-            )).go();
-        };
-
-        // set options - pass an object with options to set,
-        me.set_options = function (options) {
-            return (new m.Method(this,
-                function () {
-                    merge_options(this, options);
-                },
-                null,
-                {
-                    name: 'set_options',
-                    args: arguments
-                }
-            )).go();
-        };
-        me.unload = function () {
-            var i;
-            for (i = m.map_cache.length - 1; i >= 0; i--) {
-                if (m.map_cache[i]) {
-                    me.unbind.call($(m.map_cache[i].image));
-                }
-            }
-            me.graphics = null;
-        };
-
-        me.snapshot = function () {
-            return (new m.Method(this,
-                function () {
-                    $.each(this.data, function (i, e) {
-                        e.selected = false;
-                    });
-
-                    this.base_canvas = this.graphics.createVisibleCanvas(this);
-                    $(this.image).before(this.base_canvas);
-                },
-                null,
-                { name: 'snapshot' }
-            )).go();
-        };
-        
-        // do not queue this function
-        
-        me.state = function () {
-            var md, result = null;
-            $(this).each(function (i,e) {
-                if (e.nodeName === 'IMG') {
-                    md = m.getMapData(e);
-                    if (md) {
-                        result = md.state();
-                    }
-                    return false;
-                }
-            });
-            return result;
-        };
-
-        me.bind = function (options) {
-
-            return this.each(function (i,e) {
-                var img, map, usemap, md;
-
-                // save ref to this image even if we can't access it yet. commands will be queued
-                img = $(e);
-
-                md = m.getMapData(e);
-
-                // if already bound completely, do a total rebind
-                
-                if (md) {
-                    me.unbind.apply(img);
-                    if (!md.complete) {
-                        // will be queued
-                        img.bind();
-                        return true;
-                    }
-                    md = null;
-                }
-
-                // ensure it's a valid image
-                // jQuery bug with Opera, results in full-url#usemap being returned from jQuery's attr.
-                // So use raw getAttribute instead.
-                
-                usemap = this.getAttribute('usemap');
-                map = usemap && $('map[name="' + usemap.substr(1) + '"]');
-                if (!(img.is('img') && usemap && map.size() > 0)) {
-                    return true;
-                }
-
-                // sorry - your image must have border:0, things are too unpredictable otherwise.
-                img.css('border', 0);
-
-                if (!md) {
-                    md = new m.MapData(this, options);
-
-                    md.index = addMap(md);
-                    md.map = map;
-                    md.bindImages().then(function() {
-                        md.initialize();
-                    });
-                }
-            });
-        };
-
-        me.init = function (useCanvas) {
-            var style, shapes;
-
-            // for testing/debugging, use of canvas can be forced by initializing 
-            // manually with "true" or "false". But generally we test for it.
-            
-            m.hasCanvas = function() {
-                if (!u.isBool(m.hasCanvas.value)) {
-                    m.hasCanvas.value = u.isBool(useCanvas) ?
-                        useCanvas : 
-                        hasCanvas();
-                }
-                return m.hasCanvas.value;
-            };
-            m.hasVml = function() {
-                if (!u.isBool(m.hasVml.value)) {
-                    // initialize VML the first time we detect its presence.
-                    var d = namespaces();
-
-                    if (d && !d.v) {
-                        d.add("v", "urn:schemas-microsoft-com:vml");
-                        style = document.createStyleSheet();
-                        shapes = ['shape', 'rect', 'oval', 'circ', 'fill', 'stroke', 'imagedata', 'group', 'textbox'];
-                        $.each(shapes,
-                        function (i, el) {
-                            style.addRule('v\\:' + el, "behavior: url(#default#VML); antialias:true");
-                        });
-                    }
-                    m.hasVml.value = hasVml();
-                }
-
-                return m.hasVml.value;
-            };
-
-            m.isTouch = !!document.documentElement.ontouchstart;
-
-            $.extend(m.defaults, m.render_defaults,m.shared_defaults);
-            $.extend(m.area_defaults, m.render_defaults,m.shared_defaults);
-            
-        };
-        me.test = function (obj) {
-            return eval(obj);
-        };
-        return me;
-    } ());
-    
-    $.mapster.impl.init();
-    
-    
-} (jQuery));
-/* graphics.js
-   Graphics object handles all rendering.
-*/
-(function ($) {
-    var p, m=$.mapster,
-        u=m.utils,
-        canvasMethods,
-        vmlMethods;
-    
-    /**
-     * Implemenation to add each area in an AreaData object to the canvas
-     * @param {Graphics} graphics The target graphics object
-     * @param {AreaData} areaData The AreaData object (a collection of area elements and metadata)
-     * @param {object} options Rendering options to apply when rendering this group of areas
-     */
-    function addShapeGroupImpl(graphics, areaData, options) {
-        var me = graphics,
-            md = me.map_data,
-            isMask = options.isMask;
-
-        // first get area options. Then override fade for selecting, and finally merge in the 
-        // "select" effect options.
-
-        $.each(areaData.areas(), function (i,e) {
-            options.isMask = isMask || (e.nohref && md.options.noHrefIsMask);
-            me.addShape(e, options);
-        });
-
-        // it's faster just to manipulate the passed options isMask property and restore it, than to 
-        // copy the object each time
-        
-        options.isMask=isMask;
-
-    }
-
-     /**
-     * Convert a hex value to decimal
-     * @param  {string} hex A hexadecimal toString
-     * @return {int} Integer represenation of the hex string
-     */
-
-    function hex_to_decimal(hex) {
-        return Math.max(0, Math.min(parseInt(hex, 16), 255));
-    }
-    function css3color(color, opacity) {
-        return 'rgba(' + hex_to_decimal(color.substr(0, 2)) + ','
-                + hex_to_decimal(color.substr(2, 2)) + ','
-                + hex_to_decimal(color.substr(4, 2)) + ',' + opacity + ')';
-    }
-    /**
-     * An object associated with a particular map_data instance to manage renderin.
-     * @param {MapData} map_data The MapData object bound to this instance
-     */
-    
-    m.Graphics = function (map_data) {
-        //$(window).unload($.mapster.unload);
-        // create graphics functions for canvas and vml browsers. usage:
-        // 1) init with map_data, 2) call begin with canvas to be used (these are separate b/c may not require canvas to be specified
-        // 3) call add_shape_to for each shape or mask, 4) call render() to finish
-
-        var me = this;
-        me.active = false;
-        me.canvas = null;
-        me.width = 0;
-        me.height = 0;
-        me.shapes = [];
-        me.masks = [];
-        me.map_data = map_data;
-    };
-    
-    p = m.Graphics.prototype= {
-        constructor: m.Graphics,
-
-        /**
-         * Initiate a graphics request for a canvas
-         * @param  {Element} canvas The canvas element that is the target of this operation
-         * @param  {string} [elementName] The name to assign to the element (VML only)
-         */
-        
-        begin: function(canvas, elementName) {
-            var c = $(canvas);
-
-            this.elementName = elementName;
-            this.canvas = canvas;
-
-            this.width = c.width();
-            this.height = c.height();
-            this.shapes = [];
-            this.masks = [];
-            this.active = true;
-
-        },
-        
-        /**
-         * Add an area to be rendered to this canvas. 
-         * @param {MapArea} mapArea The MapArea object to render
-         * @param {object} options An object containing any rendering options that should override the
-         *                         defaults for the area
-         */
-        
-        addShape: function(mapArea, options) {
-            var addto = options.isMask ? this.masks : this.shapes;
-            addto.push({ mapArea: mapArea, options: options });
-        },
-
-        /**
-         * Create a canvas that is sized and styled for the MapData object
-         * @param  {MapData} mapData The MapData object that will receive this new canvas
-         * @return {Element} A canvas element
-         */
-        
-        createVisibleCanvas: function (mapData) {
-            return $(this.createCanvasFor(mapData))
-                .addClass('mapster_el')
-                .css(m.canvas_style)[0];
-        },
-
-        /**
-         * Add a group of shapes from an AreaData object to the canvas
-         * 
-         * @param {AreaData} areaData An AreaData object (a set of area elements)
-         * @param {string} mode     The rendering mode, "select" or "highlight". This determines the target 
-         *                          canvas and which default options to use.
-         * @param {striong} options  Rendering options
-         */
-        
-        addShapeGroup: function (areaData, mode,options) {
-            // render includeKeys first - because they could be masks
-            var me = this,
-                list, name, canvas,
-                map_data = this.map_data,
-                opts = areaData.effectiveRenderOptions(mode);
-
-            if (options) {
-                 $.extend(opts,options);
-            }
-
-            if (mode === 'select') {
-                name = "static_" + areaData.areaId.toString();
-                canvas = map_data.base_canvas;
-            } else {
-                canvas = map_data.overlay_canvas;
-            }
-
-            me.begin(canvas, name);
-
-            if (opts.includeKeys) {
-                list = u.split(opts.includeKeys);
-                $.each(list, function (i,e) {
-                    var areaData = map_data.getDataForKey(e.toString());
-                    addShapeGroupImpl(me,areaData, areaData.effectiveRenderOptions(mode));
-                });
-            }
-
-            addShapeGroupImpl(me,areaData, opts);
-            me.render();
-            if (opts.fade) {
-                
-                // fading requires special handling for IE. We must access the fill elements directly. The fader also has to deal with 
-                // the "opacity" attribute (not css)
-
-                u.fader(m.hasCanvas() ? 
-                    canvas : 
-                    $(canvas).find('._fill').not('.mapster_mask'),
-                0,
-                m.hasCanvas() ? 
-                    1 : 
-                    opts.fillOpacity,
-                opts.fadeDuration); 
-               
-            }
-
-        }
-
-        // These prototype methods are implementation dependent
-    };
-
-    function noop() {}
-
-  
-    // configure remaining prototype methods for ie or canvas-supporting browser
-
-    canvasMethods = {
-        renderShape: function (context, mapArea, offset) {
-            var i,
-                c = mapArea.coords(null,offset);
-
-            switch (mapArea.shape) {
-                case 'rect':
-                    context.rect(c[0], c[1], c[2] - c[0], c[3] - c[1]);
-                    break;
-                case 'poly':
-                    context.moveTo(c[0], c[1]);
-
-                    for (i = 2; i < mapArea.length; i += 2) {
-                        context.lineTo(c[i], c[i + 1]);
-                    }
-                    context.lineTo(c[0], c[1]);
-                    break;
-                case 'circ':
-                case 'circle':
-                    context.arc(c[0], c[1], c[2], 0, Math.PI * 2, false);
-                    break;
-            }
-        },
-        addAltImage: function (context, image, mapArea, options) {
-            context.beginPath();
-
-            this.renderShape(context, mapArea);
-            context.closePath();
-            context.clip();
-
-            context.globalAlpha = options.altImageOpacity || options.fillOpacity;
-
-            context.drawImage(image, 0, 0, mapArea.owner.scaleInfo.width, mapArea.owner.scaleInfo.height);
-        },
-        render: function () {
-            // firefox 6.0 context.save() seems to be broken. to work around,  we have to draw the contents on one temp canvas,
-            // the mask on another, and merge everything. ugh. fixed in 1.2.2. unfortunately this is a lot more code for masks,
-            // but no other way around it that i can see.
-
-            var maskCanvas, maskContext,
-                        me = this,
-                        md = me.map_data,
-                        hasMasks = me.masks.length,
-                        shapeCanvas = me.createCanvasFor(md),
-                        shapeContext = shapeCanvas.getContext('2d'),
-                        context = me.canvas.getContext('2d');
-
-            if (hasMasks) {
-                maskCanvas = me.createCanvasFor(md);
-                maskContext = maskCanvas.getContext('2d');
-                maskContext.clearRect(0, 0, maskCanvas.width, maskCanvas.height);
-
-                $.each(me.masks, function (i,e) {
-                    maskContext.save();
-                    maskContext.beginPath();
-                    me.renderShape(maskContext, e.mapArea);
-                    maskContext.closePath();
-                    maskContext.clip();
-                    maskContext.lineWidth = 0;
-                    maskContext.fillStyle = '#000';
-                    maskContext.fill();
-                    maskContext.restore();
-                });
-
-            }
-
-            $.each(me.shapes, function (i,s) {
-                shapeContext.save();
-                if (s.options.fill) {
-                    if (s.options.altImageId) {
-                        me.addAltImage(shapeContext, md.images[s.options.altImageId], s.mapArea, s.options);
-                    } else {
-                        shapeContext.beginPath();
-                        me.renderShape(shapeContext, s.mapArea);
-                        shapeContext.closePath();
-                        //shapeContext.clip();
-                        shapeContext.fillStyle = css3color(s.options.fillColor, s.options.fillOpacity);
-                        shapeContext.fill();
-                    }
-                }
-                shapeContext.restore();
-            });
-
-
-            // render strokes at end since masks get stroked too
-
-            $.each(me.shapes.concat(me.masks), function (i,s) {
-                var offset = s.options.strokeWidth === 1 ? 0.5 : 0;
-                // offset applies only when stroke width is 1 and stroke would render between pixels.
-
-                if (s.options.stroke) {
-                    shapeContext.save();
-                    shapeContext.strokeStyle = css3color(s.options.strokeColor, s.options.strokeOpacity);
-                    shapeContext.lineWidth = s.options.strokeWidth;
-
-                    shapeContext.beginPath();
-
-                    me.renderShape(shapeContext, s.mapArea, offset);
-                    shapeContext.closePath();
-                    shapeContext.stroke();
-                    shapeContext.restore();
-                }
-            });
-
-            if (hasMasks) {
-                // render the new shapes against the mask
-
-                maskContext.globalCompositeOperation = "source-out";
-                maskContext.drawImage(shapeCanvas, 0, 0);
-
-                // flatten into the main canvas
-                context.drawImage(maskCanvas, 0, 0);
-            } else {
-                context.drawImage(shapeCanvas, 0, 0);
-            }
-
-            me.active = false;
-            return me.canvas;
-        },
-
-        // create a canvas mimicing dimensions of an existing element
-        createCanvasFor: function (md) {
-            return $('<canvas width="' + md.scaleInfo.width + '" height="' +md.scaleInfo.height + '"></canvas>')[0];
-        },
-        clearHighlight: function () {
-            var c = this.map_data.overlay_canvas;
-            c.getContext('2d').clearRect(0, 0, c.width, c.height);
-        },
-        // Draw all items from selected_list to a new canvas, then swap with the old one. This is used to delete items when using canvases.
-        refreshSelections: function () {
-            var canvas_temp, map_data = this.map_data;
-            // draw new base canvas, then swap with the old one to avoid flickering
-            canvas_temp = map_data.base_canvas;
-
-            map_data.base_canvas = this.createVisibleCanvas(map_data);
-            $(map_data.base_canvas).hide();
-            $(canvas_temp).before(map_data.base_canvas);
-
-            map_data.redrawSelections();
-
-            $(map_data.base_canvas).show();
-            $(canvas_temp).remove();
-        }
-    };
-
-    vmlMethods = {
-
-        renderShape: function (mapArea, options, cssclass) {
-            var me = this, fill,stroke, e, t_fill, el_name, el_class, template, c = mapArea.coords();
-            el_name = me.elementName ? 'name="' + me.elementName + '" ' : '';
-            el_class = cssclass ? 'class="' + cssclass + '" ' : '';
-
-            t_fill = '<v:fill color="#' + options.fillColor + '" class="_fill" opacity="' + 
-                (options.fill ? 
-                    options.fillOpacity :
-                    0) + 
-                '" /><v:stroke class="_fill" opacity="' + 
-                options.strokeOpacity + '"/>';
-
-
-            stroke = options.stroke ?
-                ' strokeweight=' + options.strokeWidth + ' stroked="t" strokecolor="#' + 
-                    options.strokeColor + '"' :
-                ' stroked="f"';
-            
-            fill = options.fill ? 
-                ' filled="t"' :
-                ' filled="f"';
-
-            switch (mapArea.shape) {
-                case 'rect':
-                    template = '<v:rect ' + el_class + el_name + fill + stroke + 
-                        ' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + 
-                          c[0] + 'px;top:' + c[1]  + 'px;width:' + (c[2] - c[0]) + 
-                          'px;height:' + (c[3] - c[1]) + 'px;">' + t_fill + '</v:rect>';
-                    break;
-                case 'poly':
-                    template = '<v:shape ' + el_class + el_name + fill + stroke + ' coordorigin="0,0" coordsize="' + me.width + ',' + me.height
-                                + '" path="m ' + c[0] + ',' + c[1] + ' l ' + c.slice(2).join(',')
-                                + ' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:' + me.width + 'px;height:' + me.height + 'px;">' + t_fill + '</v:shape>';
-                    break;
-                case 'circ':
-                case 'circle':
-                    template = '<v:oval ' + el_class + el_name + fill + stroke
-                                + ' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + (c[0] - c[2]) + 'px;top:' + (c[1] - c[2])
-                                + 'px;width:' + (c[2] * 2) + 'px;height:' + (c[2] * 2) + 'px;">' + t_fill + '</v:oval>';
-                    break;
-            }
-            e = $(template);
-            $(me.canvas).append(e);
-
-            return e;
-        },
-        render: function () {
-            var opts, me = this;
-
-            $.each(this.shapes, function (i,e) {
-                me.renderShape(e.mapArea, e.options);
-            });
-
-            if (this.masks.length) {
-                $.each(this.masks, function (i,e) {
-                    opts = u.updateProps({},
-                        e.options, {
-                            fillOpacity: 1,
-                            fillColor: e.options.fillColorMask
-                        });
-                    me.renderShape(e.mapArea, opts, 'mapster_mask');
-                });
-            }
-
-            this.active = false;
-            return this.canvas;
-        },
-
-        createCanvasFor: function (md) {
-            var w = md.scaleInfo.width,
-                h = md.scaleInfo.height;
-            return $('<var width="' + w + '" height="' + h 
-                + '" style="zoom:1;overflow:hidden;display:block;width:' 
-                + w + 'px;height:' + h + 'px;"></var>')[0];
-        },
-
-        clearHighlight: function () {
-            $(this.map_data.overlay_canvas).children().remove();
-        },
-        // remove single or all selections
-        removeSelections: function (area_id) {
-            if (area_id >= 0) {
-                $(this.map_data.base_canvas).find('[name="static_' + area_id.toString() + '"]').remove();
-            }
-            else {
-                $(this.map_data.base_canvas).children().remove();
-            }
-        }
-
-    };
-
-    // for all methods with two implemenatations, add a function that will automatically replace itself with the correct
-    // method on first invocation
-    
-    $.each(['renderShape',
-           'addAltImage',
-           'render',
-           'createCanvasFor',
-           'clearHighlight',
-           'removeSelections',
-           'refreshSelections'],
-        function(i,e) {
-            p[e]=(function(method) {
-                return function() {
-                    p[method] = (m.hasCanvas() ?
-                        canvasMethods[method] : 
-                        vmlMethods[method]) || noop;
-                  
-                    return p[method].apply(this,arguments);
-                };
-            }(e));
-    });
-
-
-} (jQuery));
-/* mapimage.js
-   the MapImage object, repesents an instance of a single bound imagemap
-*/
-
-(function ($) {
-
-    var m = $.mapster, 
-        u = m.utils,
-        ap=[];
-    /**
-     * An object encapsulating all the images used by a MapData.
-     */
-    
-    m.MapImages = function(owner) {
-        this.owner = owner;
-        this.clear();
-    };
-
-    
-    m.MapImages.prototype = {
-        constructor: m.MapImages,
-
-        /* interface to make this array-like */
-
-        slice: function() {
-            return ap.slice.apply(this,arguments);
-        },
-        splice: function() {
-            ap.slice.apply(this.status,arguments);
-            var result= ap.slice.apply(this,arguments);
-            return result;
-        },
-     
-        /** 
-         * a boolean value indicates whether all images are done loading 
-         * @return {bool} true when all are done
-         */
-        complete: function() {
-            return $.inArray(false, this.status) < 0;
-        },
-        
-        /**
-         * Save an image in the images array and return its index 
-         * @param  {Image} image An Image object
-         * @return {int} the index of the image
-         */
-        
-        _add: function(image) {
-            var index = ap.push.call(this,image)-1;
-            this.status[index] = false;
-            return index;
-        },
-
-        /**
-         * Return the index of an Image within the images array
-         * @param  {Image} img An Image
-         * @return {int} the index within the array, or -1 if it was not found
-         */
-        
-        indexOf: function(image) {
-            return $.inArray(image, this);
-        },
-        
-        /**
-         * Clear this object and reset it to its initial state after binding.
-         */
-        
-        clear: function() {
-            var me=this;
-
-            if (me.ids && me.ids.length>0) {
-                $.each(me.ids,function(i,e) {
-                    delete me[e];
-                });
-            }
-            
-            /**
-             * A list of the cross-reference IDs bound to this object
-             * @type {string[]}
-             */
-            
-            me.ids=[];
-
-            /**
-             * Length property for array-like behavior, set to zero when initializing. Array prototype
-             * methods will update it after that.
-             * 
-             * @type {int}
-             */
-            
-            me.length=0;
-
-            /**
-             * the loaded status of the corresponding image
-             * @type {boolean[]}
-             */
-            
-            me.status=[];
-            
-            
-            // actually erase the images
-            
-            me.splice(0);
-            
-        },
-
-        /**
-         * Bind an image to the map and add it to the queue to be loaded; return an ID that
-         * can be used to reference the
-         * 
-         * @param {Image|string} image An Image object or a URL to an image
-         * @param {string} [id] An id to refer to this image
-         * @returns {int} an ID referencing the index of the image object in 
-         *                map_data.images
-         */
-     
-        add: function(image,id) {
-            var index,src,me = this;
-
-            if (!image) { return; }
-
-            if (typeof image === 'string') {
-                src = image;
-                image = me[src];
-                if (typeof image==='object') {
-                    return me.indexOf(image);
-                }
-
-                image = $('<img />')
-                    .addClass('mapster_el')
-                    .hide();
-
-                index=me._add(image[0]);
-                
-                image
-                    .bind('load',function(e) {
-                        me.imageLoaded.call(me,e);
-                    })
-                    .bind('error',function(e) {
-                        me.imageLoadError.call(me,e);
-                    });
-                
-                image.attr('src', src);
-            } else {
-
-                // use attr because we want the actual source, not the resolved path the browser will return directly calling image.src
-                
-                index=me._add($(image)[0]);
-            }
-            if (id) {
-                if (this[id]) {
-                    throw(id+" is already used or is not available as an altImage alias.");
-                }
-                me.ids.push(id);
-                me[id]=me[index];
-            }
-            return index;
-        },
-
-        /**
-         * Bind the images in this object, 
-         * @param  {boolean} retry when true, indicates that the function is calling itself after failure 
-         * @return {Promise} a promise that resolves when the images have finished loading
-         */
-        
-        bind: function(retry) {
-            var me = this,
-                promise,
-                triesLeft = me.owner.options.configTimeout / 200,
-
-            /* A recursive function to continue checking that the images have been 
-               loaded until a timeout has elapsed */
-
-            check=function() {
-                var i;
-
-                // refresh status of images
-                
-                i=me.length;
-
-                while (i-->0) {
-                    if (!me.isLoaded(i)) {
-                        break;
-                    }
-                }
-
-                // check to see if every image has already been loaded
-                
-                if (me.complete()) {
-                    me.resolve();
-                } else {
-                    // to account for failure of onLoad to fire in rare situations
-                    if (triesLeft-- > 0) {
-                        me.imgTimeout=window.setTimeout(function() {
-                            check.call(me,true);
-                        }, 50);
-                    } else {
-                        me.imageLoadError.call(me);
-                    }
-                }
-            
-            };
-
-            promise = me.deferred=u.defer();
-            
-            check();
-            return promise;
-        },
-   
-        resolve: function() {
-            var me=this,
-                resolver=me.deferred;
-                
-            if (resolver) {
-                // Make a copy of the resolver before calling & removing it to ensure
-                // it is not called twice
-                me.deferred=null;
-                resolver.resolve();
-            }
-        },
-
-        /**
-         * Event handler for image onload
-         * @param  {object} e jQuery event data
-         */
-        
-        imageLoaded: function(e) {
-            var me=this,
-                index = me.indexOf(e.target);
-
-            if (index>=0) {
-
-                me.status[index] = true;
-                if ($.inArray(false, me.status) < 0) {
-                    me.resolve();
-                }
-            }
-        },
-        
-        /**
-         * Event handler for onload error
-         * @param  {object} e jQuery event data
-         */
-        
-        imageLoadError: function(e) {
-            clearTimeout(this.imgTimeout);
-            this.triesLeft=0;
-            var err = e ? 'The image ' + e.target.src + ' failed to load.' : 
-                'The images never seemed to finish loading. You may just need to increase the configTimeout if images could take a long time to load.';
-            throw err;
-        },
-        /**
-         * Test if the image at specificed index has finished loading
-         * @param  {int}  index The image index
-         * @return {boolean} true if loaded, false if not
-         */
-        
-        isLoaded: function(index) {
-            var img,
-                me=this,
-                status=me.status;
-
-            if (status[index]) { return true; }
-            img = me[index];
-            
-            if (typeof img.complete !== 'undefined') {
-                status[index]=img.complete;
-            } else {
-                status[index]=!!u.imgWidth(img);
-            }
-            // if complete passes, the image is loaded, but may STILL not be available because of stuff like adblock.
-            // make sure it is.
-
-            return status[index];
-        }
-    };
-    } (jQuery));
-/* mapdata.js
-   the MapData object, repesents an instance of a single bound imagemap
-*/
-
-
-(function ($) {
-
-    var m = $.mapster, 
-        u = m.utils;
-   
-    /**
-     * Set default values for MapData object properties
-     * @param  {MapData} me The MapData object
-     */
-    
-    function initializeDefaults(me) {
-        $.extend(me,{
-            complete: false,         // (bool)    when configuration is complete       
-            map: null,                // ($)      the image map
-            base_canvas: null,       // (canvas|var)  where selections are rendered
-            overlay_canvas: null,    // (canvas|var)  where highlights are rendered
-            commands: [],            // {}        commands that were run before configuration was completed (b/c images weren't loaded)
-            data: [],                // MapData[] area groups
-            mapAreas: [],            // MapArea[] list. AreaData entities contain refs to this array, so options are stored with each.
-            _xref: {},               // (int)      xref of mapKeys to data[]
-            highlightId: -1,        // (int)      the currently highlighted element.
-            currentAreaId: -1,
-            _tooltip_events: [],     // {}         info on events we bound to a tooltip container, so we can properly unbind them
-            scaleInfo: null,         // {}         info about the image size, scaling, defaults
-            index: -1,                 // index of this in map_cache - so we have an ID to use for wraper div
-            activeAreaEvent: null
-        });
-    }
-
-    /**
-     * Return an array of all image-containing options from an options object; 
-     * that is, containers that may have an "altImage" property
-     * 
-     * @param  {object} obj     An options object
-     * @return {object[]}       An array of objects
-     */
-    function getOptionImages(obj) {
-        return [obj, obj.render_highlight, obj.render_select];
-    }
-
-    /**
-     * Parse all the altImage references, adding them to the library so they can be preloaded
-     * and aliased.
-     * 
-     * @param  {MapData} me The MapData object on which to operate
-     */
-    function configureAltImages(me)
-    {
-        var opts = me.options,
-            mi = me.images;
-
-        // add alt images
-        
-        if (m.hasCanvas()) {
-            // map altImage library first
-            
-            $.each(opts.altImages || {}, function(i,e) {
-                mi.add(e,i);
-            });
-            
-            // now find everything else
-
-            $.each([opts].concat(opts.areas),function(i,e) {
-                $.each(getOptionImages(e),function(i2,e2) {
-                    if (e2 && e2.altImage) {
-                        e2.altImageId=mi.add(e2.altImage);
-                    }
-                });
-            });
-        }
-
-        // set area_options
-        me.area_options = u.updateProps({}, // default options for any MapArea
-            m.area_defaults,
-            opts);
-    }
-
-    /**
-     * Queue a mouse move action based on current delay settings 
-     * (helper for mouseover/mouseout handlers)
-     * 
-     * @param  {MapData}    me       The MapData context
-     * @param  {number}     delay    The number of milliseconds to delay the action
-     * @param  {AreaData}   area     AreaData affected
-     * @param  {Deferred}   deferred A deferred object to return (instead of a new one)
-     * @return {Promise}    A promise that resolves when the action is completed
-     */
-    function queueMouseEvent(me,delay,area, deferred) {
-        
-        deferred = deferred || u.when.defer();
-
-        function cbFinal(areaId) {
-            if (me.currentAreaId!==areaId && me.highlightId>=0) {
-                deferred.resolve();
-            }
-        }
-        if (me.activeAreaEvent) {
-            window.clearTimeout(me.activeAreaEvent);
-            me.activeAreaEvent=0;
-        }
-        if (delay<0) {
-            return;
-        }
-
-        if (area.owner.currentAction || delay) {
-            me.activeAreaEvent = window.setTimeout((function() {
-                    return function() {
-                        queueMouseEvent(me,0,area,deferred);
-                    };
-                }(area)),
-                delay || 100);
-        } else {
-             cbFinal(area.areaId);
-        }
-        return deferred;
-    }
-
-     /**
-     * Mousedown event. This is captured only to prevent browser from drawing an outline around an
-     * area when it's clicked.
-     *
-     * @param  {EventData} e jQuery event data
-     */
-    
-    function mousedown(e) {
-        if (!m.hasCanvas()) {
-            this.blur();
-        }
-        e.preventDefault();
-    }
-
-    /**
-     * Mouseover event. Handle highlight rendering and client callback on mouseover
-     * 
-     * @param  {MapData} me The MapData context
-     * @param  {EventData} e jQuery event data
-     * @return {[type]}   [description]
-     */
-    
-    function mouseover(me,e) {
-        var arData = me.getAllDataForArea(this),
-            ar=arData.length ? arData[0] : null;
-
-        // mouseover events are ignored entirely while resizing, though we do care about mouseout events
-        // and must queue the action to keep things clean.
-
-        if (!ar || ar.isNotRendered() || ar.owner.currentAction) {
-            return;
-        }
-
-        if (me.currentAreaId === ar.areaId) {
-            return;
-        }
-        if (me.highlightId !== ar.areaId) {
-            me.clearEffects();
-
-            ar.highlight();
-
-            if (me.options.showToolTip) {
-                $.each(arData,function(i,e) {
-                    if (e.effectiveOptions().toolTip) {
-                        e.showToolTip();
-                    }
-                });
-            }
-        }
-
-        me.currentAreaId = ar.areaId;
-
-        if ($.isFunction(me.options.onMouseover)) {
-            me.options.onMouseover.call(this,
-            {
-                e: e,
-                options:ar.effectiveOptions(),
-                key: ar.key,
-                selected: ar.isSelected()
-            });
-        }
-    }
-
-    /**
-     * Mouseout event.
-     *
-     * @param  {MapData} me The MapData context
-     * @param  {EventData} e jQuery event data
-     * @return {[type]}   [description]
-     */
-    
-    function mouseout(me,e) {
-        var newArea,
-            ar = me.getDataForArea(this),
-            opts = me.options;
-
-
-        if (me.currentAreaId<0 || !ar) {
-            return;
-        }
-
-        newArea=me.getDataForArea(e.relatedTarget);
-        
-        if (newArea === ar) {
-            return;
-        }
-
-        me.currentAreaId = -1;
-        ar.area=null;
-
-        queueMouseEvent(me,opts.mouseoutDelay,ar)
-            .then(me.clearEffects);
-
-        if ($.isFunction(opts.onMouseout)) {
-            opts.onMouseout.call(this,
-            {
-                e: e,
-                options: opts,
-                key: ar.key,
-                selected: ar.isSelected()
-            });
-        }
-
-    }
-    
-    /**
-     * Clear any active tooltip or highlight
-     *
-     * @param  {MapData} me The MapData context
-     * @param  {EventData} e jQuery event data
-     * @return {[type]}   [description]
-     */
-    
-    function clearEffects(me) {
-        var opts = me.options;
-
-        me.ensureNoHighlight();
-
-        if (opts.toolTipClose 
-            && $.inArray('area-mouseout', opts.toolTipClose) >= 0 
-            && me.activeToolTip) 
-        {
-            me.clearToolTip();
-        }
-    }
-
-    /**
-     * Mouse click event handler
-     *
-     * @param  {MapData} me The MapData context
-     * @param  {EventData} e jQuery event data
-     * @return {[type]}   [description]
-     */
-    
-    function click(me,e) {
-        var selected, list, list_target, newSelectionState, canChangeState, cbResult,
-            that = this,
-            ar = me.getDataForArea(this),
-            opts = me.options;
-
-        function clickArea(ar) {
-            var areaOpts,target;
-            canChangeState = (ar.isSelectable() &&
-                (ar.isDeselectable() || !ar.isSelected()));
-            
-            if (canChangeState) {
-                newSelectionState = !ar.isSelected();
-            } else {
-                newSelectionState = ar.isSelected();
-            }
-
-            list_target = m.getBoundList(opts, ar.key);
-
-            if ($.isFunction(opts.onClick)) 
-            {
-                cbResult= opts.onClick.call(that,
-                {
-                    e: e,
-                    listTarget: list_target,
-                    key: ar.key,
-                    selected: newSelectionState
-                });
-
-                if (u.isBool(cbResult)) {
-                    if (!cbResult) {
-                        return false;
-                    }
-                    target = $(ar.area).attr('href');
-                    if (target!=='#') {
-                        window.location.href=target;
-                        return false;
-                    }
-                }
-            }
-
-            if (canChangeState) {
-                selected = ar.toggle();
-            }
-
-            if (opts.boundList && opts.boundList.length > 0) {
-                m.setBoundListProperties(opts, list_target, ar.isSelected());
-            }
-
-            areaOpts = ar.effectiveOptions();
-            if (areaOpts.includeKeys) {
-                list = u.split(areaOpts.includeKeys);
-                $.each(list, function (i, e) {
-                    var ar = me.getDataForKey(e.toString());
-                    if (!ar.options.isMask) {
-                        clickArea(ar);
-                    }
-                });
-            }
-        }
-
-        mousedown.call(this,e);
-
-        if (opts.clickNavigate && ar.href) {
-            window.location.href=ar.href;
-            return;
-        }
-
-        if (ar && !ar.owner.currentAction) {
-            opts = me.options;
-            clickArea(ar);
-        }
-    }
-
-    /**
-     * Prototype for a MapData object, representing an ImageMapster bound object
-     * @param {Element} image   an IMG element
-     * @param {object} options  ImageMapster binding options
-     */
-    m.MapData = function (image, options) 
-    {
-        var me = this;
-        
-        // (Image)  main map image
-        
-        me.image = image;              
-
-        me.images = new m.MapImages(me); 
-        me.graphics = new m.Graphics(me);
-
-        // save the initial style of the image for unbinding. This is problematic, chrome 
-        // duplicates styles when assigning, and cssText is apparently not universally supported.
-        // Need to do something more robust to make unbinding work universally.
-        
-        me.imgCssText = image.style.cssText || null;
-
-        initializeDefaults(me);
-
-        me.configureOptions(options);
-        
-        // create context-bound event handlers from our private functions
-        
-        me.mouseover = function(e) { mouseover.call(this,me,e); };
-        me.mouseout = function(e) { mouseout.call(this,me,e); };
-        me.click = function(e) { click.call(this,me,e); };
-        me.clearEffects = function(e) { clearEffects.call(this,me,e); };
-    };
-
-    m.MapData.prototype = {
-        constructor: m.MapData,
-
-         /**
-         * Set target.options from defaults + options
-         * @param  {[type]} target      The target
-         * @param  {[type]} options     The options to merge
-         */
-        
-        configureOptions: function(options) {
-            this.options= u.updateProps({}, m.defaults, options);
-        },
-
-        /**
-         * Ensure all images are loaded
-         * @return {Promise} A promise that resolves when the images have finished loading (or fail)
-         */
-    
-        bindImages: function() {
-            var me=this,
-                mi = me.images;
-
-            // reset the images if this is a rebind
-            
-            if (mi.length>2) {
-                mi.splice(2);
-            } else if (mi.length===0) {
-
-                // add the actual main image
-                mi.add(me.image);
-                // will create a duplicate of the main image, we need this to get raw size info
-                mi.add(me.image.src);
-            }
-            
-            configureAltImages(me);
-
-            return me.images.bind();
-        },
-
-        /**
-         * Test whether an async action is currently in progress
-         * @return {Boolean} true or false indicating state
-         */
-        
-        isActive: function() {
-            return !this.complete || this.currentAction;
-        },
-
-        /**
-         * Return an object indicating the various states. This isn't really used by 
-         * production code.
-         * 
-         * @return {object} An object with properties for various states
-         */
-        
-        state: function () {
-            return {
-                complete: this.complete,
-                resizing: this.currentAction==='resizing',
-                zoomed: this.zoomed,
-                zoomedArea: this.zoomedArea,
-                scaleInfo: this.scaleInfo
-            };
-        },   
-
-        /**
-         * Get a unique ID for the wrapper of this imagemapster
-         * @return {string} A string that is unique to this image
-         */
-        
-        wrapId: function () {
-            return 'mapster_wrap_' + this.index;
-        },
-        _idFromKey: function (key) {
-            return typeof key === "string" && this._xref.hasOwnProperty(key) ?
-                        this._xref[key] : -1;
-        },
-
-        /**
-         * Return a comma-separated string of all selected keys
-         * @return {string} CSV of all keys that are currently selected
-         */
-        
-        getSelected: function () {
-            var result = '';
-            $.each(this.data, function (i,e) {
-                if (e.isSelected()) {
-                    result += (result ? ',' : '') + this.key;
-                }
-            });
-            return result;
-        },
-
-        /**
-         * Get an array of MapAreas associated with a specific AREA based on the keys for that area
-         * @param  {Element} area   An HTML AREA
-         * @param  {number} atMost  A number limiting the number of areas to be returned (typically 1 or 0 for no limit)
-         * @return {MapArea[]}      Array of MapArea objects
-         */
-        
-        getAllDataForArea:function (area,atMost) {
-            var i,ar, result,
-                me=this,
-                key = $(area).filter('area').attr(me.options.mapKey);
-
-            if (key) {
-                result=[];
-                key = u.split(key);
-
-                for (i=0;i<(atMost || key.length);i++) {
-                    ar = me.data[me._idFromKey(key[i])];
-                    ar.area=area.length ? area[0]:area;
-                    // set the actual area moused over/selected
-                    // TODO: this is a brittle model for capturing which specific area - if this method was not used,
-                    // ar.area could have old data. fix this.
-                    result.push(ar);
-                }
-            }
-
-            return result;
-        },
-        getDataForArea: function(area) {
-            var ar=this.getAllDataForArea(area,1);
-            return ar ? ar[0] || null : null;
-        },
-        getDataForKey: function (key) {
-            return this.data[this._idFromKey(key)];
-        },
-        
-        /**
-         * Get the primary keys associated with an area group.
-         * If this is a primary key, it will be returned.
-         * 
-         * @param  {string key An area key
-         * @return {string} A CSV of area keys
-         */
-        
-        getKeysForGroup: function(key) {
-            var ar=this.getDataForKey(key);
-            
-            return !ar ? '':
-                ar.isPrimary ? 
-                    ar.key :
-                    this.getPrimaryKeysForMapAreas(ar.areas()).join(',');
-        },
-        
-        /**
-         * given an array of MapArea object, return an array of its unique primary keys
-         * @param  {MapArea[]} areas The areas to analyze
-         * @return {string[]} An array of unique primary keys
-         */
-        
-        getPrimaryKeysForMapAreas: function(areas)
-        {
-            var keys=[];
-            $.each(areas,function(i,e) {
-                if ($.inArray(e.keys[0],keys)<0) {
-                    keys.push(e.keys[0]);
-                }
-            });
-            return keys;
-        },
-        getData: function (obj) {
-            if (typeof obj === 'string') {
-                return this.getDataForKey(obj);
-            } else if (obj && obj.mapster || u.isElement(obj)) {
-                return this.getDataForArea(obj);
-            } else {
-                return null;
-            }
-        },
-        // remove highlight if present, raise event
-        ensureNoHighlight: function () {
-            var ar;
-            if (this.highlightId >= 0) {
-                this.graphics.clearHighlight();
-                ar = this.data[this.highlightId];
-                ar.changeState('highlight', false);
-                this.setHighlightId(-1);
-            }
-        },
-        setHighlightId: function(id) {
-            this.highlightId = id;
-        },
-        
-        /**
-         * Clear all active selections on this map
-         */
-        
-        clearSelections: function () {
-            $.each(this.data, function (i,e) {
-                if (e.selected) {
-                    e.deselect(true);
-                 }
-            });
-            this.removeSelectionFinish();
-            
-        },
-
-        /**
-         * Set area options from an array of option data.
-         * 
-         * @param {object[]} areas An array of objects containing area-specific options
-         */
-        
-        setAreaOptions: function (areas) {
-            var i, area_options, ar;
-            areas = areas || [];
-
-            // refer by: map_data.options[map_data.data[x].area_option_id]
-            
-            for (i = areas.length - 1; i >= 0; i--) {
-                area_options = areas[i];
-                if (area_options) {
-                    ar = this.getDataForKey(area_options.key);
-                    if (ar) {
-                        u.updateProps(ar.options, area_options);
-                        
-                        // TODO: will not deselect areas that were previously selected, so this only works
-                        // for an initial bind.
-                        
-                        if (u.isBool(area_options.selected)) {
-                            ar.selected = area_options.selected;
-                        }
-                    }
-                }
-            }
-        },
-        // keys: a comma-separated list
-        drawSelections: function (keys) {
-            var i, key_arr = u.asArray(keys);
-
-            for (i = key_arr.length - 1; i >= 0; i--) {
-                this.data[key_arr[i]].drawSelection();
-            }
-        },
-        redrawSelections: function () {
-            $.each(this.data, function (i, e) {
-                if (e.isSelectedOrStatic()) {
-                    e.drawSelection();
-                }
-            });
-
-        },
-        ///called when images are done loading
-        initialize: function () {
-            var imgCopy, base_canvas, overlay_canvas, wrap, parentId, css, i,size,
-                img,sort_func, sorted_list,  scale,  
-                        me = this,
-                        opts = me.options;
-
-            if (me.complete) {
-                return;
-            }
-
-            img = $(me.image);
-            
-            parentId = img.parent().attr('id');
-
-            // create a div wrapper only if there's not already a wrapper, otherwise, own it
-            
-            if (parentId && parentId.length >= 12 && parentId.substring(0, 12) === "mapster_wrap") {
-                wrap = img.parent();
-                wrap.attr('id', me.wrapId());
-            } else {
-                wrap = $('<div id="' + me.wrapId() + '"></div>');
-
-                if (opts.wrapClass) {
-                    if (opts.wrapClass === true) {
-                        wrap.addClass(img[0].className);
-                    }
-                    else {
-                        wrap.addClass(opts.wrapClass);
-                    }
-                }
-            }
-            me.wrapper = wrap;
-            
-            // me.images[1] is the copy of the original image. It should be loaded & at its native size now so we can obtain the true
-            // width & height. This is needed to scale the imagemap if not being shown at its native size. It is also needed purely
-            // to finish binding in case the original image was not visible. It can be impossible in some browsers to obtain the
-            // native size of a hidden image.
-
-            me.scaleInfo = scale = u.scaleMap(me.images[0],me.images[1], opts.scaleMap);
-            
-            me.base_canvas = base_canvas = me.graphics.createVisibleCanvas(me);
-            me.overlay_canvas = overlay_canvas = me.graphics.createVisibleCanvas(me);
-
-            // Now we got what we needed from the copy -clone from the original image again to make sure any other attributes are copied
-            imgCopy = $(me.images[1])
-                .addClass('mapster_el '+ me.images[0].className)
-                .attr({id:null, usemap: null});
-                
-            size=u.size(me.images[0]);
-            
-            if (size.complete) {
-                imgCopy.css({
-                    width: size.width,
-                    height: size.height
-                });
-            }
-     
-            me.buildDataset();
-
-            // now that we have processed all the areas, set css for wrapper, scale map if needed
-
-            css = {
-                display: 'block',
-                position: 'relative',
-                padding: 0,
-                width: scale.width,
-                height: scale.height
-            };
-
-            if (opts.wrapCss) {
-                $.extend(css, opts.wrapCss);
-            }
-            // if we were rebinding with an existing wrapper, the image will aready be in it
-            if (img.parent()[0] !== me.wrapper[0]) {
-
-                img.before(me.wrapper);
-            }
-
-            wrap.css(css);
-
-            // move all generated images into the wrapper for easy removal later
-
-            $(me.images.slice(2)).hide();
-            for (i = 1; i < me.images.length; i++) {
-                wrap.append(me.images[i]);
-            }
-
-            //me.images[1].style.cssText = me.image.style.cssText;
-
-            wrap.append(base_canvas)
-                        .append(overlay_canvas)
-                        .append(img.css(m.canvas_style));
-
-            // images[0] is the original image with map, images[1] is the copy/background that is visible
-
-            u.setOpacity(me.images[0], 0);
-            $(me.images[1]).show();
-
-            u.setOpacity(me.images[1],1);
-
-            if (opts.isSelectable && opts.onGetList) {
-                sorted_list = me.data.slice(0);
-                if (opts.sortList) {
-                    if (opts.sortList === "desc") {
-                        sort_func = function (a, b) {
-                            return a === b ? 0 : (a > b ? -1 : 1);
-                        };
-                    }
-                    else {
-                        sort_func = function (a, b) {
-                            return a === b ? 0 : (a < b ? -1 : 1);
-                        };
-                    }
-
-                    sorted_list.sort(function (a, b) {
-                        a = a.value;
-                        b = b.value;
-                        return sort_func(a, b);
-                    });
-                }
-
-                me.options.boundList = opts.onGetList.call(me.image, sorted_list);
-            }
-            
-            me.complete=true;
-            me.processCommandQueue();
-            
-            if (opts.onConfigured && typeof opts.onConfigured === 'function') {
-                opts.onConfigured.call(img, true);
-            }
-        },
-
-        // when rebind is true, the MapArea data will not be rebuilt.
-        buildDataset: function(rebind) {
-            var sel,areas,j,area_id,$area,area,curKey,mapArea,key,keys,mapAreaId,group_value,dataItem,href,
-                me=this,
-                opts=me.options,
-                default_group;
-
-            function addAreaData(key, value) {
-                var dataItem = new m.AreaData(me, key, value);
-                dataItem.areaId = me._xref[key] = me.data.push(dataItem) - 1;
-                return dataItem.areaId;
-            }
-
-            me._xref = {};
-            me.data = [];
-            if (!rebind) {
-                me.mapAreas=[];
-            }
-
-            default_group = !opts.mapKey;
-            if (default_group) {
-                opts.mapKey = 'data-mapster-key';
-            }
-
-            // the [attribute] selector is broken on old IE with jQuery. hasVml() is a quick and dirty
-            // way to test for that
-            
-            sel = m.hasVml() ? 'area' :
-                        (default_group ? 
-                            'area[coords]' : 
-                            'area[' + opts.mapKey + ']');
-
-            areas = $(me.map).find(sel).unbind('.mapster');
-                        
-            for (mapAreaId = 0;mapAreaId<areas.length; mapAreaId++) {
-                area_id = 0;
-                area = areas[mapAreaId];
-                $area = $(area);
-
-                // skip areas with no coords - selector broken for older ie
-                if (!area.coords) {
-                    continue;
-                }
-                // Create a key if none was assigned by the user
-
-                if (default_group) {
-                     curKey=String(mapAreaId);
-                    $area.attr('data-mapster-key', curKey);
-                   
-                } else {
-                    curKey = area.getAttribute(opts.mapKey);
-                }
-
-                // conditions for which the area will be bound to mouse events
-                // only bind to areas that don't have nohref. ie 6&7 cannot detect the presence of nohref, so we have to also not bind if href is missing.
-
-                if (rebind) {
-                    mapArea = me.mapAreas[$area.data('mapster')-1];
-                    mapArea.configure(curKey);
-                } else {
-                    mapArea = new m.MapArea(me, area,curKey);
-                    me.mapAreas.push(mapArea);
-                }
-
-                keys = mapArea.keys; // converted to an array by mapArea
-
-
-                // Iterate through each mapKey assigned to this area
-                for (j = keys.length - 1; j >= 0; j--) {
-                    key = keys[j];
-
-                    if (opts.mapValue) {
-                        group_value = $area.attr(opts.mapValue);
-                    }
-                    if (default_group) {
-                        // set an attribute so we can refer to the area by index from the DOM object if no key
-                        area_id = addAreaData(me.data.length, group_value);
-                        dataItem = me.data[area_id];
-                        dataItem.key = key = area_id.toString();
-                    }
-                    else {
-                        area_id = me._xref[key];
-                        if (area_id >= 0) {
-                            dataItem = me.data[area_id];
-                            if (group_value && !me.data[area_id].value) {
-                                dataItem.value = group_value;
-                            }
-                        }
-                        else {
-                            area_id = addAreaData(key, group_value);
-                            dataItem = me.data[area_id];
-                            dataItem.isPrimary=j===0;
-                        }
-                    }
-                    mapArea.areaDataXref.push(area_id);
-                    dataItem.areasXref.push(mapAreaId);
-                }
-
-                href=$area.attr('href');
-                if (href && href!=='#' && !dataItem.href)
-                {
-                    dataItem.href=href;
-                }
-
-                if (!mapArea.nohref) {
-                    $area.bind('click.mapster', me.click);
-                       
-                    if (!m.isTouch) {
-                        $area.bind('mouseover.mapster', me.mouseover)
-                            .bind('mouseout.mapster', me.mouseout)
-                            .bind('mousedown.mapster', me.mousedown);
-                        
-                    }
-                        
-                }
-
-                // store an ID with each area. 
-                $area.data("mapster", mapAreaId+1);
-            }
-           
-            // TODO listenToList
-            //            if (opts.listenToList && opts.nitG) {
-            //                opts.nitG.bind('click.mapster', event_hooks[map_data.hooks_index].listclick_hook);
-            //            }
-
-            // populate areas from config options
-            me.setAreaOptions(opts.areas);
-            me.redrawSelections();
-
-        },
-        processCommandQueue: function() {
-            
-            var cur,me=this;
-            while (!me.currentAction && me.commands.length) {
-                cur = me.commands[0];
-                me.commands.splice(0,1);
-                m.impl[cur.command].apply(cur.that, cur.args);
-            }
-        },
-        clearEvents: function () {
-            $(this.map).find('area')
-                        .unbind('.mapster');
-            $(this.images)
-                        .unbind('.mapster');
-        },
-        _clearCanvases: function (preserveState) {
-            // remove the canvas elements created
-            if (!preserveState) {
-                $(this.base_canvas).remove();
-            }
-            $(this.overlay_canvas).remove();
-        },
-        clearMapData: function (preserveState) {
-            var me = this;
-            this._clearCanvases(preserveState);
-
-            // release refs to DOM elements
-            $.each(this.data, function (i, e) {
-                e.reset();
-            });
-            this.data = null;
-            if (!preserveState) {
-                // get rid of everything except the original image
-                this.image.style.cssText = this.imgCssText;
-                $(this.wrapper).before(this.image).remove();
-            }
-
-            me.images.clear();
-
-            this.image = null;
-            u.ifFunction(this.clearTooltip, this);
-        },
-
-        // Compelete cleanup process for deslecting items. Called after a batch operation, or by AreaData for single
-        // operations not flagged as "partial"
-        
-        removeSelectionFinish: function () {
-            var g = this.graphics;
-
-            g.refreshSelections();
-            // do not call ensure_no_highlight- we don't really want to unhilight it, just remove the effect
-            g.clearHighlight();
-        }
-    };
-} (jQuery));
-/* areadata.js
-   AreaData and MapArea protoypes
-*/
-
-(function ($) {
-    var m = $.mapster, u = m.utils;
-    
-    /**
-     * Select this area
-     * 
-     * @param {AreaData} me  AreaData context
-     * @param {object} options Options for rendering the selection
-     */
-    function select(options) {
-        // need to add the new one first so that the double-opacity effect leaves the current one highlighted for singleSelect
-        
-        var me=this, o = me.owner;
-        if (o.options.singleSelect) {
-            o.clearSelections();
-        }
-
-        // because areas can overlap - we can't depend on the selection state to tell us anything about the inner areas.
-        // don't check if it's already selected
-        if (!me.isSelected()) {
-            if (options) {
-                
-                // cache the current options, and map the altImageId if an altimage 
-                // was passed
-
-                me.optsCache = $.extend(me.effectiveRenderOptions('select'),
-                    options,
-                    { 
-                        altImageId: o.images.add(options.altImage)
-                    });
-            }
-
-            me.drawSelection();
-
-            me.selected = true;
-            me.changeState('select', true);
-        }
-
-        if (o.options.singleSelect) {
-            o.graphics.refreshSelections();
-        }
-    }
-
-    /**
-     * Deselect this area, optionally deferring finalization so additional areas can be deselected
-     * in a single operation
-     * 
-     * @param  {boolean} partial when true, the caller must invoke "finishRemoveSelection" to render 
-     */
-    
-    function deselect(partial) {
-        var me=this;
-        me.selected = false;
-        me.changeState('select', false);
-
-        // release information about last area options when deselecting.
-        
-        me.optsCache=null;
-        me.owner.graphics.removeSelections(me.areaId);
-
-        // Complete selection removal process. This is separated because it's very inefficient to perform the whole
-        // process for multiple removals, as the canvas must be totally redrawn at the end of the process.ar.remove
-        
-        if (!partial) {
-            me.owner.removeSelectionFinish();
-        }
-    }
-
-    /**
-     * Toggle the selection state of this area
-     * @param  {object} options Rendering options, if toggling on
-     * @return {bool} The new selection state
-     */
-    function toggle(options) {
-        var me=this;
-        if (!me.isSelected()) {
-            me.select(options);
-        }
-        else {
-            me.deselect();
-        }
-        return me.isSelected();
-    }
-
-    /**
-     * An AreaData object; represents a conceptual area that can be composed of 
-     * one or more MapArea objects
-     * 
-     * @param {MapData} owner The MapData object to which this belongs
-     * @param {string} key   The key for this area
-     * @param {string} value The mapValue string for this area
-     */
-    
-    m.AreaData = function (owner, key, value) {
-        $.extend(this,{
-            owner: owner, 
-            key: key || '',
-            // means this represents the first key in a list of keys (it's the area group that gets highlighted on mouseover)
-            isPrimary: true,
-            areaId: -1,
-            href: '',
-            value: value || '',
-            options:{},
-            // "null" means unchanged. Use "isSelected" method to just test true/false 
-            selected: null,       
-            // xref to MapArea objects
-            areasXref: [],
-            // (temporary storage) - the actual area moused over
-            area: null,
-            // the last options used to render this. Cache so when re-drawing after a remove, changes in options won't
-            // break already selected things. 
-            optsCache: null
-         });
-    };
-
-    /**
-     * The public API for AreaData object
-     */
-
-    m.AreaData.prototype = {
-        constuctor: m.AreaData,
-        select: select,
-        deselect: deselect,
-        toggle: toggle,
-        areas: function() {
-            var i,result=[];
-            for (i=0;i<this.areasXref.length;i++) {
-                result.push(this.owner.mapAreas[this.areasXref[i]]);
-            }
-            return result;
-        },
-        // return all coordinates for all areas
-        coords: function(offset) {
-            var coords = [];
-            $.each(this.areas(), function (i, el) {
-                coords = coords.concat(el.coords(offset));
-            });
-            return coords;
-        },
-        reset: function () {
-            $.each(this.areas(), function (i, e) {
-                e.reset();
-            });
-            this.areasXref = [];
-            this.options = null;
-        },
-        // Return the effective selected state of an area, incorporating staticState
-        isSelectedOrStatic: function () {
-
-            var o = this.effectiveOptions();
-            return u.isBool(o.staticState) ? o.staticState :
-                        this.isSelected();
-        },
-        isSelected: function () {
-            return u.isBool(this.selected) ? this.selected :
-                u.isBool(this.owner.area_options.selected) ? this.owner.area_options.selected : false;
-        },
-        isSelectable: function () {
-            return u.isBool(this.effectiveOptions().staticState) ? false :
-                        (u.isBool(this.owner.options.staticState) ? false : u.boolOrDefault(this.effectiveOptions().isSelectable,true));
-        },
-        isDeselectable: function () {
-            return u.isBool(this.effectiveOptions().staticState) ? false :
-                        (u.isBool(this.owner.options.staticState) ? false : u.boolOrDefault(this.effectiveOptions().isDeselectable,true));
-        },
-        isNotRendered: function() {
-            var area = $(this.area);
-            return area.attr('nohref') ||
-                !area.attr('href') ||
-                this.effectiveOptions().isMask;
-
-        },
-
-        
-         /**
-         * Return the overall options effective for this area. 
-         * This should get the default options, and merge in area-specific options, finally
-         * overlaying options passed by parameter
-         * 
-         * @param  {[type]} options  options which will supercede all other options for this area
-         * @return {[type]}          the combined options
-         */
-        
-        effectiveOptions: function (options) {
-            
-            var opts = u.updateProps({},
-                    this.owner.area_options,
-                    this.options,
-                    options || {},
-                    {
-                        id: this.areaId 
-                    }
-                );
-
-            opts.selected = this.isSelected();
-            
-            return opts;
-        },
-
-        /**
-         * Return the options effective for this area for a "render" or "highlight" mode. 
-         * This should get the default options, merge in the areas-specific options, 
-         * and then the mode-specific options.
-         * @param  {string} mode    'render' or 'highlight'
-         * @param  {[type]} options  options which will supercede all other options for this area
-         * @return {[type]}          the combined options
-         */
-        
-        effectiveRenderOptions: function (mode, options) {
-            var allOpts,opts=this.optsCache;
-            
-            if (!opts || mode==='highlight') {
-                allOpts = this.effectiveOptions(options);
-                opts = u.updateProps({},
-                    allOpts,
-                    allOpts["render_" + mode]
-                );
-                    
-                if (mode!=='highlight') {
-                    this.optsCache=opts;
-                }
-            }
-            return $.extend({},opts);
-        },
-
-        // Fire callback on area state change
-        changeState: function (state_type, state) {
-            if ($.isFunction(this.owner.options.onStateChange)) {
-                this.owner.options.onStateChange.call(this.owner.image,
-                    {
-                        key: this.key,
-                        state: state_type,
-                        selected: state
-                    }
-                );
-            }
-        },
-
-        // highlight this area
-         
-        highlight: function (options) {
-            var o = this.owner;
-            if (this.effectiveOptions().highlight) {
-                o.graphics.addShapeGroup(this, "highlight",options);
-            }
-            o.setHighlightId(this.areaId);
-            this.changeState('highlight', true);
-        },
-
-        // select this area. if "callEvent" is true then the state change event will be called. (This method can be used
-        // during config operations, in which case no event is indicated)
-        
-        drawSelection: function () {
-        
-
-            this.owner.graphics.addShapeGroup(this, "select");
-        
-        }
-
-
-    };
-    // represents an HTML area
-    m.MapArea = function (owner,areaEl,keys) {
-        if (!owner) {
-            return;
-        }
-        var me = this;
-        me.owner = owner;   // a MapData object
-        me.area = areaEl;
-        me.areaDataXref=[]; // a list of map_data.data[] id's for each areaData object containing this
-        me.originalCoords = [];
-        $.each(u.split(areaEl.coords), function (i, el) {
-            me.originalCoords.push(parseFloat(el));
-        });
-        me.length = me.originalCoords.length;
-        me.shape = areaEl.shape.toLowerCase();
-        me.nohref = areaEl.nohref || !areaEl.href;
-        me.configure(keys);
-    };
-    m.MapArea.prototype= {
-        constructor: m.MapArea,
-        configure: function(keys) {
-            this.keys = u.split(keys);
-        },
-        reset: function() {
-            this.area=null;
-        },
-        coords: function (offset) {
-            return $.map(this.originalCoords,function(e) {
-                return offset ? e : e+offset;
-            });
-        }
-    };
-} (jQuery));
-/* areacorners.js
-   determine the best place to put a box of dimensions (width,height) given a circle, rect or poly
-*/
-
-(function ($) {
-    var u=$.mapster.utils;
-
-
-    /**
-     * Compute positions that will place a target with dimensions [width,height] outside 
-     * but near the boundaries of the elements "elements". When an imagemap is passed, the 
-     *
-     * @param  {Element|Element[]} elements An element or an array of elements (such as a jQuery object)
-     * @param  {Element} image The image to which area elements are bound, if this is an image map.
-     * @param  {Element} container The contianer in which the target must be constrained (or document, if missing)
-     * @param  {int} width The width of the target object
-     * @return {object} a structure with the x and y positions
-     */
-    u.areaCorners = function (elements, image, container, width, height) {
-        var pos,found, minX, minY, maxX, maxY, bestMinX, bestMaxX, bestMinY, bestMaxY, curX, curY, nest, j,
-           offsetx=0, 
-           offsety=0,
-           rootx,
-           rooty,
-           iCoords,radius,angle,el,
-           coords=[];
-
-        // if a single element was passed, map it to an array
-        
-        elements = elements.length ? 
-            elements:
-            [elements];
-
-        container = container ? 
-            $(container):
-            $(document.body);
-
-        // get the relative root of calculation
-
-        pos = container.offset();
-        rootx = pos.left;
-        rooty = pos.top;
-
-        // with areas, all we know about is relative to the top-left corner of the image. We need to add an offset compared to
-        // the actual container. After this calculation, offsetx/offsety can be added to either the area coords, or the target's
-        // absolute position to get the correct top/left boundaries of the container.
-
-        if (image) {
-            pos = $(image).offset();
-            offsetx = pos.left;
-            offsety = pos.top;
-        }
-
-        // map the coordinates of any type of shape to a poly and use the logic. simpler than using three different
-        // calculation methods. Circles use a 20 degree increment for this estimation.
-
-        for (j=0;j<elements.length;j++) 
-        {
-            el=elements[j];
-            if (el.nodeName==='AREA') {
-                iCoords = u.split(el.coords,parseInt);
-
-                switch(el.shape) {
-                    case 'circle':
-                        curX=iCoords[0];
-                        curY=iCoords[1];
-                        radius=iCoords[2];
-                        coords=[];
-                        for (j=0;j<360;j+=20) {
-                             angle=j*Math.PI/180;
-                             coords.push(curX+radius*Math.cos(angle),curY+radius*Math.sin(angle));
-                        }
-                        break;
-                      case 'rect':
-                          coords.push(iCoords[0],iCoords[1],iCoords[2],iCoords[1],iCoords[2],iCoords[3],iCoords[0],iCoords[3]);
-                          break;
-                      default:
-                          coords=coords.concat(iCoords);
-                         break;
-                }
-
-                // map area positions to it's real position in the container
-
-                for (j=0;j<coords.length;j+=2)
-                {
-                    coords[j]=parseInt(coords[j],10)+offsetx;
-                    coords[j+1]=parseInt(coords[j+1],10)+offsety;
-                }
-            } else {
-                el=$(el);
-                pos = el.position();
-                coords.push(pos.left,pos.top,
-                            pos.left+el.width(),pos.top,
-                            pos.left+el.width(),pos.top+el.height(),
-                            pos.left,pos.top+el.height());
-
-            }
-        }
-        
-        minX = minY = bestMinX = bestMinY = 999999;
-        maxX = maxY = bestMaxX = bestMaxY = -1;
-
-        for (j = coords.length - 2; j >= 0; j -= 2) {
-            curX = coords[j];
-            curY = coords[j + 1];
-            
-            if (curX < minX) {
-                minX = curX;
-                bestMaxY = curY;
-            }
-            if (curX > maxX) {
-                maxX = curX;
-                bestMinY = curY;
-            }
-            if (curY < minY) {
-                minY = curY;
-                bestMaxX = curX;
-            }
-            if (curY > maxY) {
-                maxY = curY;
-                bestMinX = curX;
-            }
-
-        }
-
-        // try to figure out the best place for the tooltip
-        
-        if (width && height) {
-            found=false;
-            $.each([[bestMaxX - width, minY - height], [bestMinX, minY - height],
-                             [minX - width, bestMaxY - height], [minX - width, bestMinY],
-                             [maxX,bestMaxY - height], [ maxX,bestMinY],
-                             [bestMaxX - width, maxY], [bestMinX, maxY]
-                      ],function (i, e) {
-                          if (!found && (e[0] > rootx && e[1] > rooty)) {
-                              nest = e;
-                              found=true;
-                              return false;
-                  }
-             });
-             
-             // default to lower-right corner if nothing fit inside the boundaries of the image
-             
-             if (!found) {
-                 nest=[maxX,maxY];
-             }
-        }
-        return nest;
-    };
-} (jQuery));
-/* scale.js: resize and zoom functionality
-   requires areacorners.js, when.js
-*/
-
-
-(function ($) {
-    var m = $.mapster, u = m.utils, p = m.MapArea.prototype;
-
-    m.utils.getScaleInfo = function (eff, actual) {
-        var pct;
-        if (!actual) {
-            pct = 1;
-            actual=eff;
-        } else {
-            pct = eff.width / actual.width || eff.height / actual.height;
-            // make sure a float error doesn't muck us up
-            if (pct > 0.98 && pct < 1.02) { pct = 1; }
-        }
-        return {
-            scale: (pct !== 1),
-            scalePct: pct,
-            realWidth: actual.width,
-            realHeight: actual.height,
-            width: eff.width,
-            height: eff.height,
-            ratio: eff.width / eff.height
-        };
-    };
-    // Scale a set of AREAs, return old data as an array of objects
-    m.utils.scaleMap = function (image, imageRaw, scale) {
-        
-        // stunningly, jQuery width can return zero even as width does not, seems to happen only
-        // with adBlock or maybe other plugins. These must interfere with onload events somehow.
-
-
-        var vis=u.size(image),
-            raw=u.size(imageRaw,true);
-
-        if (!raw.complete()) {
-            throw("Another script, such as an extension, appears to be interfering with image loading. Please let us know about this.");
-        }
-        if (!vis.complete()) {
-            vis=raw;
-        }
-        return this.getScaleInfo(vis, scale ? raw : null);
-    };
-    
-    /**
-     * Resize the image map. Only one of newWidth and newHeight should be passed to preserve scale
-     * 
-     * @param  {int}   width       The new width OR an object containing named parameters matching this function sig
-     * @param  {int}   height      The new height
-     * @param  {int}   effectDuration Time in ms for the resize animation, or zero for no animation
-     * @param  {function} callback    A function to invoke when the operation finishes
-     * @return {promise}              NOT YET IMPLEMENTED
-     */
-    
-    m.MapData.prototype.resize = function (width, height, duration, callback) {
-        var p,promises,newsize,els, highlightId, ratio, 
-            me = this;
-        
-        // allow omitting duration
-        callback = callback || duration;
-
-        function sizeCanvas(canvas, w, h) {
-            if (m.hasCanvas()) {
-                canvas.width = w;
-                canvas.height = h;
-            } else {
-                $(canvas).width(w);
-                $(canvas).height(h);
-            }
-        }
-
-        // Finalize resize action, do callback, pass control to command queue
-
-        function cleanupAndNotify() {
-
-            me.currentAction = '';
-            
-            if ($.isFunction(callback)) {
-                callback();
-            }
-            
-            me.processCommandQueue();
-        }
-
-        // handle cleanup after the inner elements are resized
-        
-        function finishResize() {
-            sizeCanvas(me.overlay_canvas, width, height);
-
-            // restore highlight state if it was highlighted before
-            if (highlightId >= 0) {
-                var areaData = me.data[highlightId];
-                areaData.tempOptions = { fade: false };
-                me.getDataForKey(areaData.key).highlight();
-                areaData.tempOptions = null;
-            }
-            sizeCanvas(me.base_canvas, width, height);
-            me.redrawSelections();
-            cleanupAndNotify();
-        }
-
-        function resizeMapData() {
-            $(me.image).css(newsize);
-            // start calculation at the same time as effect
-            me.scaleInfo = u.getScaleInfo({
-                    width: width,
-                    height: height
-                },
-                { 
-                    width: me.scaleInfo.realWidth,
-                    height: me.scaleInfo.realHeight
-                });
-            $.each(me.data, function (i, e) {
-                $.each(e.areas(), function (i, e) {
-                    e.resize();
-                });
-            });
-        }
-
-        if (me.scaleInfo.width === width && me.scaleInfo.height === height) {
-            return;
-        }
-
-        highlightId = me.highlightId;
-
-        
-        if (!width) {
-            ratio = height / me.scaleInfo.realHeight;
-            width = Math.round(me.scaleInfo.realWidth * ratio);
-        }
-        if (!height) {
-            ratio = width / me.scaleInfo.realWidth;
-            height = Math.round(me.scaleInfo.realHeight * ratio);
-        }
-
-        newsize = { 'width': String(width) + 'px', 'height': String(height) + 'px' };
-        if (!m.hasCanvas()) {
-            $(me.base_canvas).children().remove();
-        }
-
-        // resize all the elements that are part of the map except the image itself (which is not visible)
-        // but including the div wrapper
-        els = $(me.wrapper).find('.mapster_el').add(me.wrapper);
-
-        if (duration) {
-            promises = [];
-            me.currentAction = 'resizing';
-            els.each(function (i, e) {
-                p = u.defer();
-                promises.push(p);
-
-                $(e).animate(newsize, {
-                    duration: duration,
-                    complete: p.resolve,
-                    easing: "linear"
-                });
-            });
-
-            p = u.defer();
-            promises.push(p);
-
-            // though resizeMapData is not async, it needs to be finished just the same as the animations,
-            // so add it to the "to do" list.
-            
-            u.when.all(promises).then(finishResize);
-            resizeMapData();
-            p.resolve();
-        } else {
-            els.css(newsize);
-            resizeMapData();
-            finishResize();
-            
-        }
-    };
-
-
-    m.MapArea = u.subclass(m.MapArea, function () {
-        //change the area tag data if needed
-        this.base.init();
-        if (this.owner.scaleInfo.scale) {
-            this.resize();
-        }
-    });
-
-    p.coords = function (percent, coordOffset) {
-        var j, newCoords = [],
-                    pct = percent || this.owner.scaleInfo.scalePct,
-                    offset = coordOffset || 0;
-
-        if (pct === 1 && coordOffset === 0) {
-            return this.originalCoords;
-        }
-
-        for (j = 0; j < this.length; j++) {
-            //amount = j % 2 === 0 ? xPct : yPct;
-            newCoords.push(Math.round(this.originalCoords[j] * pct) + offset);
-        }
-        return newCoords;
-    };
-    p.resize = function () {
-        this.area.coords = this.coords().join(',');
-    };
-
-    p.reset = function () {
-        this.area.coords = this.coords(1).join(',');
-    };
-    
-    m.impl.resize = function (width, height, duration, callback) {
-        if (!width && !height) {
-            return false;
-        }
-        var x= (new m.Method(this,
-                function () {
-                    this.resize(width, height, duration, callback);
-                },
-                null,
-                {
-                    name: 'resize',
-                    args: arguments
-                }
-            )).go();
-        return x;
-    };
-
-/*
-    m.impl.zoom = function (key, opts) {
-        var options = opts || {};
-
-        function zoom(areaData) {
-            // this will be MapData object returned by Method
-
-            var scroll, corners, height, width, ratio,
-                    diffX, diffY, ratioX, ratioY, offsetX, offsetY, newWidth, newHeight, scrollLeft, scrollTop,
-                    padding = options.padding || 0,
-                    scrollBarSize = areaData ? 20 : 0,
-                    me = this,
-                    zoomOut = false;
-
-            if (areaData) {
-                // save original state on first zoom operation
-                if (!me.zoomed) {
-                    me.zoomed = true;
-                    me.preZoomWidth = me.scaleInfo.width;
-                    me.preZoomHeight = me.scaleInfo.height;
-                    me.zoomedArea = areaData;
-                    if (options.scroll) {
-                        me.wrapper.css({ overflow: 'auto' });
-                    }
-                }
-                corners = $.mapster.utils.areaCorners(areaData.coords(1, 0));
-                width = me.wrapper.innerWidth() - scrollBarSize - padding * 2;
-                height = me.wrapper.innerHeight() - scrollBarSize - padding * 2;
-                diffX = corners.maxX - corners.minX;
-                diffY = corners.maxY - corners.minY;
-                ratioX = width / diffX;
-                ratioY = height / diffY;
-                ratio = Math.min(ratioX, ratioY);
-                offsetX = (width - diffX * ratio) / 2;
-                offsetY = (height - diffY * ratio) / 2;
-
-                newWidth = me.scaleInfo.realWidth * ratio;
-                newHeight = me.scaleInfo.realHeight * ratio;
-                scrollLeft = (corners.minX) * ratio - padding - offsetX;
-                scrollTop = (corners.minY) * ratio - padding - offsetY;
-            } else {
-                if (!me.zoomed) {
-                    return;
-                }
-                zoomOut = true;
-                newWidth = me.preZoomWidth;
-                newHeight = me.preZoomHeight;
-                scrollLeft = null;
-                scrollTop = null;
-            }
-
-            this.resize({
-                width: newWidth,
-                height: newHeight,
-                duration: options.duration,
-                scroll: scroll,
-                scrollLeft: scrollLeft,
-                scrollTop: scrollTop,
-                // closure so we can be sure values are correct
-                callback: (function () {
-                    var isZoomOut = zoomOut,
-                            scroll = options.scroll,
-                            areaD = areaData;
-                    return function () {
-                        if (isZoomOut) {
-                            me.preZoomWidth = null;
-                            me.preZoomHeight = null;
-                            me.zoomed = false;
-                            me.zoomedArea = false;
-                            if (scroll) {
-                                me.wrapper.css({ overflow: 'inherit' });
-                            }
-                        } else {
-                            // just to be sure it wasn't canceled & restarted
-                            me.zoomedArea = areaD;
-                        }
-                    };
-                } ())
-            });
-        }
-        return (new m.Method(this,
-                function (opts) {
-                    zoom.call(this);
-                },
-                function () {
-                    zoom.call(this.owner, this);
-                },
-                {
-                    name: 'zoom',
-                    args: arguments,
-                    first: true,
-                    key: key
-                }
-                )).go();
-
-
-    };
-    */
-} (jQuery));
-/* tooltip.js - tooltip functionality
-   requires areacorners.js
-*/
-
-(function ($) {
-
-    var m = $.mapster, u = m.utils;
-    
-    $.extend(m.defaults, {
-        toolTipContainer: '<div style="border: 2px solid black; background: #EEEEEE; width:160px; padding:4px; margin: 4px; -moz-box-shadow: 3px 3px 5px #535353; ' +
-        '-webkit-box-shadow: 3px 3px 5px #535353; box-shadow: 3px 3px 5px #535353; -moz-border-radius: 6px 6px 6px 6px; -webkit-border-radius: 6px; ' +
-        'border-radius: 6px 6px 6px 6px; opacity: 0.9;"></dteniv>',
-        showToolTip: false,
-        toolTipFade: true,
-        toolTipClose: ['area-mouseout','image-mouseout'],
-        onShowToolTip: null,
-        onHideToolTip: null
-    });
-    
-    $.extend(m.area_defaults, {
-        toolTip: null,
-        toolTipClose: null
-    });
-    
-
-    /**
-     * Show a tooltip positioned near this area.
-     * 
-     * @param {string|jquery} html A string of html or a jQuery object containing the tooltip content.
-     * @param {string|jquery} [template] The html template in which to wrap the content
-     * @param {string|object} [css] CSS to apply to the outermost element of the tooltip 
-     * @return {jquery} The tooltip that was created
-     */
-    
-    function createToolTip(html, template, css) {
-        var tooltip;
-
-        // wrap the template in a jQuery object, or clone the template if it's already one.
-        // This assumes that anything other than a string is a jQuery object; if it's not jQuery will
-        // probably throw an error.
-        
-        if (template) {
-            tooltip = typeof template === 'string' ?
-                $(template) : 
-                $(template).clone();
-
-            tooltip.append(html);
-        } else {
-            tooltip=$(html);
-        }
-
-        // always set display to block, or the positioning css won't work if the end user happened to
-        // use a non-block type element.
-
-        tooltip.css($.extend((css || {}),{
-                display:"block",
-                position:"absolute"
-            })).hide();
-        
-        $('body').append(tooltip);
-
-        // we must actually add the tooltip to the DOM and "show" it in order to figure out how much space it
-        // consumes, and then reposition it with that knowledge.
-        // We also cache the actual opacity setting to restore finally.
-        
-        tooltip.attr("data-opacity",tooltip.css("opacity"))
-            .css("opacity",0);
-        
-        // doesn't really show it because opacity=0
-        
-        return tooltip.show();
-    }
-
-
-    /**
-     * Show a tooltip positioned near this area.
-     * 
-     * @param {jquery} tooltip The tooltip
-     * @param {object} [options] options for displaying the tooltip.
-     *  @config {int} [left] The 0-based absolute x position for the tooltip
-     *  @config {int} [top] The 0-based absolute y position for the tooltip
-     *  @config {string|object} [css] CSS to apply to the outermost element of the tooltip 
-     *  @config {bool} [fadeDuration] When non-zero, the duration in milliseconds of a fade-in effect for the tooltip.
-     */
-    
-    function showToolTipImpl(tooltip,options)
-    {
-        var tooltipCss = { 
-                "left":  options.left + "px",
-                "top": options.top + "px"
-            }, 
-            actalOpacity=tooltip.attr("data-opacity") || 0,
-            zindex = tooltip.css("z-index");
-        
-        if (parseInt(zindex,10)===0 
-            || zindex === "auto") {
-            tooltipCss["z-index"] = 9999;
-        }
-
-        tooltip.css(tooltipCss)
-            .addClass('mapster_tooltip');
-
-        
-        if (options.fadeDuration && options.fadeDuration>0) {
-            u.fader(tooltip[0], 0, actalOpacity, options.fadeDuration);
-        } else {
-            u.setOpacity(tooltip[0], actalOpacity);
-        }
-    }
-      
-    /**
-     * Hide and remove active tooltips
-     * 
-     * @param  {MapData} this The mapdata object to which the tooltips belong
-     */
-    
-    m.MapData.prototype.clearToolTip = function() {
-        if (this.activeToolTip) {
-            this.activeToolTip.stop().remove();
-            this.activeToolTip = null;
-            this.activeToolTipID = null;
-            u.ifFunction(this.options.onHideToolTip, this);
-        }
-    };
-
-    /**
-     * Configure the binding between a named tooltip closing option, and a mouse event.
-     *
-     * If a callback is passed, it will be called when the activating event occurs, and the tooltip will
-     * only closed if it returns true.
-     *
-     * @param  {MapData}  [this]     The MapData object to which this tooltip belongs.
-     * @param  {String}   option     The name of the tooltip closing option
-     * @param  {String}   event      UI event to bind to this option
-     * @param  {Element}  target     The DOM element that is the target of the event
-     * @param  {Function} [beforeClose] Callback when the tooltip is closed
-     * @param  {Function} [onClose]  Callback when the tooltip is closed
-     */
-    function bindToolTipClose(options, bindOption, event, target, beforeClose, onClose) {
-        var event_name = event + '.mapster-tooltip';
-        
-        if ($.inArray(bindOption, options) >= 0) {
-            target.unbind(event_name)
-                .bind(event_name, function (e) {
-                    if (!beforeClose || beforeClose.call(this,e)) {
-                        target.unbind('.mapster-tooltip');
-                        if (onClose) {
-                            onClose.call(this);
-                        }
-                    }
-                });
-            
-            return {
-                object: target, 
-                event: event_name
-            };
-        }
-    }
-    
-    /**
-     * Show a tooltip.
-     *
-     * @param {string|jquery}   [tooltip]       A string of html or a jQuery object containing the tooltip content.
-     * 
-     * @param {string|jquery}   [target]        The target of the tooltip, to be used to determine positioning. If null,
-     *                                          absolute position values must be passed with left and top.
-     *
-     * @param {string|jquery}   [image]         If target is an [area] the image that owns it
-     * 
-     * @param {string|jquery}   [container]     An element within which the tooltip must be bounded
-     *
-     *
-     * 
-     * @param {object|string|jQuery} [options]  options to apply when creating this tooltip - OR -
-     *                                          The markup, or a jquery object, containing the data for the tooltip 
-     *                                         
-     *  @config {string}        [closeEvents]   A string with one or more comma-separated values that determine when the tooltip
-     *                                          closes: 'area-click','tooltip-click','image-mouseout' are valid values
-     *                                          then no template will be used.
-     *  @config {int}           [offsetx]       the horizontal amount to offset the tooltip 
-     *  @config {int}           [offsety]       the vertical amount to offset the tooltip 
-     *  @config {string|object} [css]           CSS to apply to the outermost element of the tooltip 
-     */
-    
-    function showToolTip(tooltip,target,image,container,options) {
-        var corners,
-            ttopts = {};
-    
-        options = options || {};
-
-
-        if (target) {
-
-            corners = u.areaCorners(target,image,container,
-                                    tooltip.outerWidth(true),
-                                    tooltip.outerHeight(true));
-
-            // Try to upper-left align it first, if that doesn't work, change the parameters
-
-            ttopts.left = corners[0];
-            ttopts.top = corners[1];
-
-        } else {
-            
-            ttopts.left = options.left;
-            ttopts.top = options.top;
-        }
-
-        ttopts.left += (options.offsetx || 0);
-        ttopts.top +=(options.offsety || 0);
-
-        ttopts.css= options.css;
-        ttopts.fadeDuration = options.fadeDuration;
-
-        showToolTipImpl(tooltip,ttopts);
-
-        return tooltip;
-    }
-    
-    /**
-     * Show a tooltip positioned near this area.
-      *
-     * @param {string|jquery}   [content]       A string of html or a jQuery object containing the tooltip content.
-     
-     * @param {object|string|jQuery} [options]  options to apply when creating this tooltip - OR -
-     *                                          The markup, or a jquery object, containing the data for the tooltip 
-     *  @config {string|jquery}   [container]     An element within which the tooltip must be bounded
-     *  @config {bool}          [template]      a template to use instead of the default. If this property exists and is null,
-     *                                          then no template will be used.
-     *  @config {string}        [closeEvents]   A string with one or more comma-separated values that determine when the tooltip
-     *                                          closes: 'area-click','tooltip-click','image-mouseout' are valid values
-     *                                          then no template will be used.
-     *  @config {int}           [offsetx]       the horizontal amount to offset the tooltip 
-     *  @config {int}           [offsety]       the vertical amount to offset the tooltip 
-     *  @config {string|object} [css]           CSS to apply to the outermost element of the tooltip 
-     */
-    m.AreaData.prototype.showToolTip= function(content,options) {
-        var tooltip, closeOpts, target, tipClosed, template,
-            ttopts = {},
-            ad=this,
-            md=ad.owner,
-            areaOpts = ad.effectiveOptions();
-    
-        // copy the options object so we can update it
-        options = options ? $.extend({},options) : {};
-
-        content = content || areaOpts.toolTip;
-        closeOpts = options.closeEvents || areaOpts.toolTipClose || md.options.toolTipClose || 'tooltip-click';
-        
-        template = typeof options.template !== 'undefined' ? 
-                options.template :
-                md.options.toolTipContainer;
-
-        options.closeEvents = typeof closeOpts === 'string' ?
-            closeOpts = u.split(closeOpts) :
-            closeOpts;
-
-        options.fadeDuration = options.fadeDuration ||
-                 (md.options.toolTipFade ? 
-                    (md.options.fadeDuration || areaOpts.fadeDuration) : 0);
-
-        target = ad.area ? 
-            ad.area :
-            $.map(ad.areas(),
-                function(e) {
-                    return e.area;
-                });
-
-        if (md.activeToolTipID===ad.areaId) {
-            return;
-        }
-
-        md.clearToolTip();
-
-        md.activeToolTip = tooltip = createToolTip(content,
-            template,
-            options.css);
-
-        md.activeToolTipID = ad.areaId;
-
-        tipClosed = function() {
-            md.clearToolTip();
-        };
-
-        bindToolTipClose(closeOpts,'area-click', 'click', $(md.map), null, tipClosed);
-        bindToolTipClose(closeOpts,'tooltip-click', 'click', tooltip,null, tipClosed);
-        bindToolTipClose(closeOpts,'image-mouseout', 'mouseout', $(md.image), function(e) {
-            return (e.relatedTarget && e.relatedTarget.nodeName!=='AREA' && e.relatedTarget!==ad.area);
-        }, tipClosed);
-
-
-        showToolTip(tooltip,
-                    target,
-                    md.image,
-                    options.container,
-                    template,
-                    options);
-
-        u.ifFunction(md.options.onShowToolTip, ad.area,
-        {
-            toolTip: tooltip,
-            options: ttopts,
-            areaOptions: areaOpts,
-            key: ad.key,
-            selected: ad.isSelected()
-        });
-
-        return tooltip;
-    };
-    
-
-    /**
-     * Parse an object that could be a string, a jquery object, or an object with a "contents" property
-     * containing html or a jQuery object.
-     * 
-     * @param  {object|string|jQuery} options The parameter to parse
-     * @return {string|jquery} A string or jquery object
-     */
-    function getHtmlFromOptions(options) {
-
-            // see if any html was passed as either the options object itself, or the content property
-
-            return (options ?
-                ((typeof options === 'string' || options.jquery) ?
-                    options :
-                    options.content) :
-                null);
-    }
-
-    /**
-     * Activate or remove a tooltip for an area. When this method is called on an area, the
-     * key parameter doesn't apply and "options" is the first parameter.
-     *
-     * When called with no parameters, or "key" is a falsy value, any active tooltip is cleared.
-     * 
-     * When only a key is provided, the default tooltip for the area is used. 
-     * 
-     * When html is provided, this is used instead of the default tooltip.
-     * 
-     * When "noTemplate" is true, the default tooltip template will not be used either, meaning only
-     * the actual html passed will be used.
-     *  
-     * @param  {string|AreaElement} key The area for which to activate a tooltip, or a DOM element.
-     * 
-     * @param {object|string|jquery} [options] options to apply when creating this tooltip - OR -
-     *                                         The markup, or a jquery object, containing the data for the tooltip 
-     *  @config {string|jQuery} [content]   the inner content of the tooltip; the tooltip text or HTML
-     *  @config {Element|jQuery} [container]   the inner content of the tooltip; the tooltip text or HTML
-     *  @config {bool}          [template]  a template to use instead of the default. If this property exists and is null,
-     *                                      then no template will be used.
-     *  @config {int}           [offsetx]   the horizontal amount to offset the tooltip.
-     *  @config {int}           [offsety]   the vertical amount to offset the tooltip.
-     *  @config {string|object} [css]       CSS to apply to the outermost element of the tooltip 
-     *  @config {string|object} [css] CSS to apply to the outermost element of the tooltip 
-     *  @config {bool}          [fadeDuration] When non-zero, the duration in milliseconds of a fade-in effect for the tooltip.
-     * @return {jQuery} The jQuery object
-     */
-    
-    m.impl.tooltip = function (key,options) {
-        return (new m.Method(this,
-        function mapData() {
-            var tooltip, target, md=this;
-            if (!key) {
-                md.clearToolTip();
-            } else {
-                target=$(key);
-                if (md.activeToolTipID ===target[0]) {
-                    return;
-                }
-                md.clearToolTip();
-
-                md.activeToolTip = tooltip = createToolTip(getHtmlFromOptions(options),
-                            options.template || md.options.toolTipContainer,
-                            options.css);
-                md.activeToolTipID = target[0];
-
-                bindToolTipClose(['tooltip-click'],'tooltip-click', 'click', tooltip, null, function() {
-                    md.clearToolTip();
-                });
-
-                md.activeToolTip = tooltip = showToolTip(tooltip,
-                    target,
-                    md.image,
-                    options.container,
-                    options);
-            }
-        },
-        function areaData() {
-            if ($.isPlainObject(key) && !options) {
-                options = key;
-            }
-
-            this.showToolTip(getHtmlFromOptions(options),options);
-        },
-        { 
-            name: 'tooltip',
-            args: arguments,
-            key: key
-        }
-    )).go();
-    };
-} (jQuery));
--- a/src/pyams_content/skin/resources/js/jquery-imagemapster-1.2.10.min.js	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-(function(a){a(function(){var d,j,u,c;k.defer=f;k.reject=i;k.isPromise=q;k.all=e;k.some=o;k.any=p;k.map=x;k.reduce=n;k.chain=s;d=Object.freeze||function(y){return y};function g(){}g.prototype=d({always:function(y,z){return this.then(y,y,z)},otherwise:function(y){return this.then(c,y)}});function t(y){var z=new g();z.then=function(C){var A;try{if(C){A=C(y)}return r(A===c?y:A)}catch(B){return w(B)}};return d(z)}function w(z){var y=new g();y.then=function(D,A){var B;try{if(A){B=A(z);return r(B===c?z:B)}return w(z)}catch(C){return w(C)}};return d(y)}function i(y){return k(y,function(z){return w(z)})}function f(){var H,J,F,D,B,z,A;F=[];D=[];B=function E(N,L,M){var K=f();F.push(function(O){O.then(N,L).then(K.resolve,K.reject,K.progress)});M&&D.push(M);return K.promise};function C(M,K,L){return B(M,K,L)}function G(K){A(t(K))}function I(K){A(w(K))}z=function(M){var K,L=0;while(K=D[L++]){K(M)}};function y(K){z(K)}A=function(L){var N,K=0;B=L.then;A=z=function M(){throw new Error("already completed")};D=c;while(N=F[K++]){N(L)}F=[]};H={};J=new g();J.then=H.then=C;H.promise=d(J);H.resolver=d({resolve:(H.resolve=G),reject:(H.reject=I),progress:(H.progress=y)});return H}function q(y){return y&&typeof y.then==="function"}function k(A,C,B,z){var y=r(A);return y.then(C,B,z)}function r(y){var A,z;if(y instanceof g){A=y}else{z=f();if(q(y)){y.then(z.resolve,z.reject,z.progress);A=z.promise}else{z.resolve(y);A=z.promise}}return A}function o(B,A,C,z,y){m(2,arguments);return k(B,function(H){var M,J,L,P,F,G,O,K,I;K=H.length>>>0;M=Math.max(0,Math.min(A,K));J=[];P=f();L=k(P,C,z,y);function N(R){F(R)}function Q(R){G(R)}function D(R){O(R)}function E(){F=G=O=h}if(!M){P.resolve(J)}else{F=function(R){J.push(R);if(!--M){E();P.resolve(J)}};G=function(R){E();P.reject(R)};O=P.progress;for(I=0;I<K;++I){if(I in H){k(H[I],N,Q,D)}}}return L})}function e(A,B,z,y){m(1,arguments);return k(A,function(C){return v(C,l,[])}).then(B,z,y)}function l(z,A,y){z[y]=A;return z}function p(A,C,z,y){function B(D){return C?C(D[0]):D[0]}return o(A,1,B,z,y)}function x(z,y){return k(z,function(A){return b(A,y)})}function b(B,C){var A,y,z;y=B.length>>>0;A=new Array(y);for(z=0;z<y;z++){if(z in B){A[z]=k(B[z],C)}}return v(A,l,A)}function n(B,A,y){var z=u.call(arguments,1);return k(B,function(C){return v.apply(c,[C].concat(z))})}function v(C,A,y){var B,z;B=C.length;z=[function(E,F,D){return k(E,function(G){return k(F,function(H){return A(G,H,D,B)})})}];if(arguments.length>2){z.push(y)}return j.apply(C,z)}function s(y,B,A){var z=arguments.length>2;return k(y,function(C){if(z){C=A}B.resolve(C);return C},function(C){B.reject(C);return w(C)},B.progress)}function m(B,A){var y,z=A.length;while(z>B){y=A[--z];if(y!=null&&typeof y!="function"){throw new Error("callback is not a function")}}}function h(){}u=[].slice;j=[].reduce||function(D){var z,B,A,y,C;C=0;z=Object(this);y=z.length>>>0;B=arguments;if(B.length<=1){for(;;){if(C in z){A=z[C++];break}if(++C>=y){throw new TypeError()}}}else{A=B[1]}for(;C<y;++C){if(C in z){A=D(A,z[C],C,z)}}return A};return k})})(typeof define=="function"?define:function(a){typeof module!="undefined"?(module.exports=a()):(jQuery.mapster_when=a())});(function($){$.fn.mapster=function(method){var m=$.mapster.impl;if($.isFunction(m[method])){return m[method].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof method==="object"||!method){return m.bind.apply(this,arguments)}else{$.error("Method "+method+" does not exist on jQuery.mapster")}}};$.mapster={version:"1.2.10",render_defaults:{isSelectable:true,isDeselectable:true,fade:false,fadeDuration:150,fill:true,fillColor:"000000",fillColorMask:"FFFFFF",fillOpacity:0.7,highlight:true,stroke:false,strokeColor:"ff0000",strokeOpacity:1,strokeWidth:1,includeKeys:"",altImage:null,altImageId:null,altImages:{}},defaults:{clickNavigate:false,wrapClass:null,wrapCss:null,onGetList:null,sortList:false,listenToList:false,mapKey:"",mapValue:"",singleSelect:false,listKey:"value",listSelectedAttribute:"selected",listSelectedClass:null,onClick:null,onMouseover:null,onMouseout:null,mouseoutDelay:0,onStateChange:null,boundList:null,onConfigured:null,configTimeout:30000,noHrefIsMask:true,scaleMap:true,safeLoad:false,areas:[]},shared_defaults:{render_highlight:{fade:true},render_select:{fade:false},staticState:null,selected:null},area_defaults:{includeKeys:"",isMask:false},canvas_style:{position:"absolute",left:0,top:0,padding:0,border:0},hasCanvas:null,isTouch:null,map_cache:[],hooks:{},addHook:function(name,callback){this.hooks[name]=(this.hooks[name]||[]).push(callback)},callHooks:function(name,context){$.each(this.hooks[name]||[],function(i,e){e.apply(context)})},utils:{when:$.mapster_when,defer:$.mapster_when.defer,subclass:function(BaseClass,constr){var Subclass=function(){var me=this,args=Array.prototype.slice.call(arguments,0);me.base=BaseClass.prototype;me.base.init=function(){BaseClass.prototype.constructor.apply(me,args)};constr.apply(me,args)};Subclass.prototype=new BaseClass();Subclass.prototype.constructor=Subclass;return Subclass},asArray:function(obj){return obj.constructor===Array?obj:this.split(obj)},split:function(text,cb){var i,el,arr=text.split(",");for(i=0;i<arr.length;i++){el=$.trim(arr[i]);if(el===""){arr.splice(i,1)}else{arr[i]=cb?cb(el):el}}return arr},updateProps:function(_target,_template){var onlyProps,target=_target||{},template=$.isEmptyObject(target)?_template:_target;onlyProps=[];$.each(template,function(prop){onlyProps.push(prop)});$.each(Array.prototype.slice.call(arguments,1),function(i,src){$.each(src||{},function(prop){if(!onlyProps||$.inArray(prop,onlyProps)>=0){var p=src[prop];if($.isPlainObject(p)){target[prop]=$.extend(target[prop]||{},p)}else{if(p&&p.constructor===Array){target[prop]=p.slice(0)}else{if(typeof p!=="undefined"){target[prop]=src[prop]}}}}})});return target},isElement:function(o){return(typeof HTMLElement==="object"?o instanceof HTMLElement:o&&typeof o==="object"&&o.nodeType===1&&typeof o.nodeName==="string")},indexOfProp:function(obj,prop,val){var result=obj.constructor===Array?-1:null;$.each(obj,function(i,e){if(e&&(prop?e[prop]:e)===val){result=i;return false}});return result},boolOrDefault:function(obj,def){return this.isBool(obj)?obj:def||false},isBool:function(obj){return typeof obj==="boolean"},isUndef:function(obj){return typeof obj==="undefined"},ifFunction:function(obj,that,args){if($.isFunction(obj)){obj.call(that,args)}},size:function(image,raw){var u=$.mapster.utils;return{width:raw?(image.width||image.naturalWidth):u.imgWidth(image,true),height:raw?(image.height||image.naturalHeight):u.imgHeight(image,true),complete:function(){return !!this.height&&!!this.width}}},setOpacity:function(el,opacity){if($.mapster.hasCanvas()){el.style.opacity=opacity}else{$(el).each(function(i,e){if(typeof e.opacity!=="undefined"){e.opacity=opacity}else{$(e).css("opacity",opacity)}})}},fader:(function(){var elements={},lastKey=0,fade_func=function(el,op,endOp,duration){var index,cbIntervals=duration/15,obj,u=$.mapster.utils;if(typeof el==="number"){obj=elements[el];if(!obj){return}}else{index=u.indexOfProp(elements,null,el);if(index){delete elements[index]}elements[++lastKey]=obj=el;el=lastKey}endOp=endOp||1;op=(op+(endOp/cbIntervals)>endOp-0.01)?endOp:op+(endOp/cbIntervals);u.setOpacity(obj,op);if(op<endOp){setTimeout(function(){fade_func(el,op,endOp,duration)},15)}};return fade_func}())},getBoundList:function(opts,key_list){if(!opts.boundList){return null}var index,key,result=$(),list=$.mapster.utils.split(key_list);opts.boundList.each(function(i,e){for(index=0;index<list.length;index++){key=list[index];if($(e).is("["+opts.listKey+'="'+key+'"]')){result=result.add(e)}}});return result},setBoundListProperties:function(opts,target,selected){target.each(function(i,e){if(opts.listSelectedClass){if(selected){$(e).addClass(opts.listSelectedClass)}else{$(e).removeClass(opts.listSelectedClass)}}if(opts.listSelectedAttribute){$(e).attr(opts.listSelectedAttribute,selected)}})},getMapDataIndex:function(obj){var img,id;switch(obj.tagName&&obj.tagName.toLowerCase()){case"area":id=$(obj).parent().attr("name");img=$("img[usemap='#"+id+"']")[0];break;case"img":img=obj;break}return img?this.utils.indexOfProp(this.map_cache,"image",img):-1},getMapData:function(obj){var index=this.getMapDataIndex(obj.length?obj[0]:obj);if(index>=0){return index>=0?this.map_cache[index]:null}},queueCommand:function(map_data,that,command,args){if(!map_data){return false}if(!map_data.complete||map_data.currentAction){map_data.commands.push({that:that,command:command,args:args});return true}return false},unload:function(){this.impl.unload();this.utils=null;this.impl=null;$.fn.mapster=null;$.mapster=null;$("*").unbind()}};var m=$.mapster,u=m.utils,ap=Array.prototype;$.each(["width","height"],function(i,e){var capProp=e.substr(0,1).toUpperCase()+e.substr(1);u["img"+capProp]=function(img,jqwidth){return(jqwidth?$(img)[e]():0)||img[e]||img["natural"+capProp]||img["client"+capProp]||img["offset"+capProp]}});m.Method=function(that,func_map,func_area,opts){var me=this;me.name=opts.name;me.output=that;me.input=that;me.first=opts.first||false;me.args=opts.args?ap.slice.call(opts.args,0):[];me.key=opts.key;me.func_map=func_map;me.func_area=func_area;me.name=opts.name;me.allowAsync=opts.allowAsync||false};m.Method.prototype={constructor:m.Method,go:function(){var i,data,ar,len,result,src=this.input,area_list=[],me=this;len=src.length;for(i=0;i<len;i++){data=$.mapster.getMapData(src[i]);if(data){if(!me.allowAsync&&m.queueCommand(data,me.input,me.name,me.args)){if(this.first){result=""}continue}ar=data.getData(src[i].nodeName==="AREA"?src[i]:this.key);if(ar){if($.inArray(ar,area_list)<0){area_list.push(ar)}}else{result=this.func_map.apply(data,me.args)}if(this.first||typeof result!=="undefined"){break}}}$(area_list).each(function(i,e){result=me.func_area.apply(e,me.args)});if(typeof result!=="undefined"){return result}else{return this.output}}};$.mapster.impl=(function(){var me={},addMap=function(map_data){return m.map_cache.push(map_data)-1},removeMap=function(map_data){m.map_cache.splice(map_data.index,1);for(var i=m.map_cache.length-1;i>=this.index;i--){m.map_cache[i].index--}};function hasVml(){var a=$("<div />").appendTo("body");a.html('<v:shape id="vml_flag1" adj="1" />');var b=a[0].firstChild;b.style.behavior="url(#default#VML)";var has=b?typeof b.adj==="object":true;a.remove();return has}function namespaces(){return typeof(document.namespaces)==="object"?document.namespaces:null}function hasCanvas(){var d=namespaces();return d&&d.g_vml_?false:$("<canvas />")[0].getContext?true:false}function merge_areas(map_data,areas){var ar,index,map_areas=map_data.options.areas;if(areas){$.each(areas,function(i,e){if(!e||!e.key){return}index=u.indexOfProp(map_areas,"key",e.key);if(index>=0){$.extend(map_areas[index],e)}else{map_areas.push(e)}ar=map_data.getDataForKey(e.key);if(ar){$.extend(ar.options,e)}})}}function merge_options(map_data,options){var temp_opts=u.updateProps({},options);delete temp_opts.areas;u.updateProps(map_data.options,temp_opts);merge_areas(map_data,options.areas);u.updateProps(map_data.area_options,map_data.options)}me.get=function(key){var md=m.getMapData(this);if(!(md&&md.complete)){throw ("Can't access data until binding complete.")}return(new m.Method(this,function(){return this.getSelected()},function(){return this.isSelected()},{name:"get",args:arguments,key:key,first:true,allowAsync:true,defaultReturn:""})).go()};me.data=function(key){return(new m.Method(this,null,function(){return this},{name:"data",args:arguments,key:key})).go()};me.highlight=function(key){return(new m.Method(this,function(){if(key===false){this.ensureNoHighlight()}else{var id=this.highlightId;return id>=0?this.data[id].key:null}},function(){this.highlight()},{name:"highlight",args:arguments,key:key,first:true})).go()};me.keys=function(key,all){var keyList=[],md=m.getMapData(this);if(!(md&&md.complete)){throw ("Can't access data until binding complete.")}function addUniqueKeys(ad){var areas,keys=[];if(!all){keys.push(ad.key)}else{areas=ad.areas();$.each(areas,function(i,e){keys=keys.concat(e.keys)})}$.each(keys,function(i,e){if($.inArray(e,keyList)<0){keyList.push(e)}})}if(!(md&&md.complete)){return""}if(typeof key==="string"){if(all){addUniqueKeys(md.getDataForKey(key))}else{keyList=[md.getKeysForGroup(key)]}}else{all=key;this.each(function(i,e){if(e.nodeName==="AREA"){addUniqueKeys(md.getDataForArea(e))}})}return keyList.join(",")};me.select=function(){me.set.call(this,true)};me.deselect=function(){me.set.call(this,false)};me.set=function(selected,key,options){var lastMap,map_data,opts=options,key_list,area_list;function setSelection(ar){if(ar){switch(selected){case true:ar.select(opts);break;case false:ar.deselect(true);break;default:ar.toggle(opts);break}}}function addArea(ar){if(ar&&$.inArray(ar,area_list)<0){area_list.push(ar);key_list+=(key_list===""?"":",")+ar.key}}function finishSetForMap(map_data){$.each(area_list,function(i,el){setSelection(el)});if(!selected){map_data.removeSelectionFinish()}if(map_data.options.boundList){m.setBoundListProperties(map_data.options,m.getBoundList(map_data.options,key_list),selected)}}this.filter("img,area").each(function(i,e){var keys;map_data=m.getMapData(e);if(map_data!==lastMap){if(lastMap){finishSetForMap(lastMap)}area_list=[];key_list=""}if(map_data){keys="";if(e.nodeName.toUpperCase()==="IMG"){if(!m.queueCommand(map_data,$(e),"set",[selected,key,opts])){if(key instanceof Array){if(key.length){keys=key.join(",")}}else{keys=key}if(keys){$.each(u.split(keys),function(i,key){addArea(map_data.getDataForKey(key.toString()));lastMap=map_data})}}}else{opts=key;if(!m.queueCommand(map_data,$(e),"set",[selected,opts])){addArea(map_data.getDataForArea(e));lastMap=map_data}}}});if(map_data){finishSetForMap(map_data)}return this};me.unbind=function(preserveState){return(new m.Method(this,function(){this.clearEvents();this.clearMapData(preserveState);removeMap(this)},null,{name:"unbind",args:arguments})).go()};me.rebind=function(options){return(new m.Method(this,function(){var me=this;me.complete=false;me.configureOptions(options);me.bindImages().then(function(){me.buildDataset(true);me.complete=true})},null,{name:"rebind",args:arguments})).go()};me.get_options=function(key,effective){var eff=u.isBool(key)?key:effective;return(new m.Method(this,function(){var opts=$.extend({},this.options);if(eff){opts.render_select=u.updateProps({},m.render_defaults,opts,opts.render_select);opts.render_highlight=u.updateProps({},m.render_defaults,opts,opts.render_highlight)}return opts},function(){return eff?this.effectiveOptions():this.options},{name:"get_options",args:arguments,first:true,allowAsync:true,key:key})).go()};me.set_options=function(options){return(new m.Method(this,function(){merge_options(this,options)},null,{name:"set_options",args:arguments})).go()};me.unload=function(){var i;for(i=m.map_cache.length-1;i>=0;i--){if(m.map_cache[i]){me.unbind.call($(m.map_cache[i].image))}}me.graphics=null};me.snapshot=function(){return(new m.Method(this,function(){$.each(this.data,function(i,e){e.selected=false});this.base_canvas=this.graphics.createVisibleCanvas(this);$(this.image).before(this.base_canvas)},null,{name:"snapshot"})).go()};me.state=function(){var md,result=null;$(this).each(function(i,e){if(e.nodeName==="IMG"){md=m.getMapData(e);if(md){result=md.state()}return false}});return result};me.bind=function(options){return this.each(function(i,e){var img,map,usemap,md;img=$(e);md=m.getMapData(e);if(md){me.unbind.apply(img);if(!md.complete){img.bind();return true}md=null}usemap=this.getAttribute("usemap");map=usemap&&$('map[name="'+usemap.substr(1)+'"]');if(!(img.is("img")&&usemap&&map.size()>0)){return true}img.css("border",0);if(!md){md=new m.MapData(this,options);md.index=addMap(md);md.map=map;md.bindImages().then(function(){md.initialize()})}})};me.init=function(useCanvas){var style,shapes;m.hasCanvas=function(){if(!u.isBool(m.hasCanvas.value)){m.hasCanvas.value=u.isBool(useCanvas)?useCanvas:hasCanvas()}return m.hasCanvas.value};m.hasVml=function(){if(!u.isBool(m.hasVml.value)){var d=namespaces();if(d&&!d.v){d.add("v","urn:schemas-microsoft-com:vml");style=document.createStyleSheet();shapes=["shape","rect","oval","circ","fill","stroke","imagedata","group","textbox"];$.each(shapes,function(i,el){style.addRule("v\\:"+el,"behavior: url(#default#VML); antialias:true")})}m.hasVml.value=hasVml()}return m.hasVml.value};m.isTouch=!!document.documentElement.ontouchstart;$.extend(m.defaults,m.render_defaults,m.shared_defaults);$.extend(m.area_defaults,m.render_defaults,m.shared_defaults)};me.test=function(obj){return eval(obj)};return me}());$.mapster.impl.init()}(jQuery));(function(e){var a,d=e.mapster,i=d.utils,g,b;function h(l,n,m){var o=l,p=o.map_data,k=m.isMask;e.each(n.areas(),function(q,r){m.isMask=k||(r.nohref&&p.options.noHrefIsMask);o.addShape(r,m)});m.isMask=k}function c(k){return Math.max(0,Math.min(parseInt(k,16),255))}function f(k,l){return"rgba("+c(k.substr(0,2))+","+c(k.substr(2,2))+","+c(k.substr(4,2))+","+l+")"}d.Graphics=function(l){var k=this;k.active=false;k.canvas=null;k.width=0;k.height=0;k.shapes=[];k.masks=[];k.map_data=l};a=d.Graphics.prototype={constructor:d.Graphics,begin:function(l,k){var m=e(l);this.elementName=k;this.canvas=l;this.width=m.width();this.height=m.height();this.shapes=[];this.masks=[];this.active=true},addShape:function(m,l){var k=l.isMask?this.masks:this.shapes;k.push({mapArea:m,options:l})},createVisibleCanvas:function(k){return e(this.createCanvasFor(k)).addClass("mapster_el").css(d.canvas_style)[0]},addShapeGroup:function(r,n,s){var q=this,o,l,m,p=this.map_data,k=r.effectiveRenderOptions(n);if(s){e.extend(k,s)}if(n==="select"){l="static_"+r.areaId.toString();m=p.base_canvas}else{m=p.overlay_canvas}q.begin(m,l);if(k.includeKeys){o=i.split(k.includeKeys);e.each(o,function(u,v){var t=p.getDataForKey(v.toString());h(q,t,t.effectiveRenderOptions(n))})}h(q,r,k);q.render();if(k.fade){i.fader(d.hasCanvas()?m:e(m).find("._fill").not(".mapster_mask"),0,d.hasCanvas()?1:k.fillOpacity,k.fadeDuration)}}};function j(){}g={renderShape:function(l,m,n){var k,o=m.coords(null,n);switch(m.shape){case"rect":l.rect(o[0],o[1],o[2]-o[0],o[3]-o[1]);break;case"poly":l.moveTo(o[0],o[1]);for(k=2;k<m.length;k+=2){l.lineTo(o[k],o[k+1])}l.lineTo(o[0],o[1]);break;case"circ":case"circle":l.arc(o[0],o[1],o[2],0,Math.PI*2,false);break}},addAltImage:function(l,n,m,k){l.beginPath();this.renderShape(l,m);l.closePath();l.clip();l.globalAlpha=k.altImageOpacity||k.fillOpacity;l.drawImage(n,0,0,m.owner.scaleInfo.width,m.owner.scaleInfo.height)},render:function(){var p,n,m=this,o=m.map_data,r=m.masks.length,q=m.createCanvasFor(o),l=q.getContext("2d"),k=m.canvas.getContext("2d");if(r){p=m.createCanvasFor(o);n=p.getContext("2d");n.clearRect(0,0,p.width,p.height);e.each(m.masks,function(s,t){n.save();n.beginPath();m.renderShape(n,t.mapArea);n.closePath();n.clip();n.lineWidth=0;n.fillStyle="#000";n.fill();n.restore()})}e.each(m.shapes,function(t,u){l.save();if(u.options.fill){if(u.options.altImageId){m.addAltImage(l,o.images[u.options.altImageId],u.mapArea,u.options)}else{l.beginPath();m.renderShape(l,u.mapArea);l.closePath();l.fillStyle=f(u.options.fillColor,u.options.fillOpacity);l.fill()}}l.restore()});e.each(m.shapes.concat(m.masks),function(t,u){var v=u.options.strokeWidth===1?0.5:0;if(u.options.stroke){l.save();l.strokeStyle=f(u.options.strokeColor,u.options.strokeOpacity);l.lineWidth=u.options.strokeWidth;l.beginPath();m.renderShape(l,u.mapArea,v);l.closePath();l.stroke();l.restore()}});if(r){n.globalCompositeOperation="source-out";n.drawImage(q,0,0);k.drawImage(p,0,0)}else{k.drawImage(q,0,0)}m.active=false;return m.canvas},createCanvasFor:function(k){return e('<canvas width="'+k.scaleInfo.width+'" height="'+k.scaleInfo.height+'"></canvas>')[0]},clearHighlight:function(){var k=this.map_data.overlay_canvas;k.getContext("2d").clearRect(0,0,k.width,k.height)},refreshSelections:function(){var k,l=this.map_data;k=l.base_canvas;l.base_canvas=this.createVisibleCanvas(l);e(l.base_canvas).hide();e(k).before(l.base_canvas);l.redrawSelections();e(l.base_canvas).show();e(k).remove()}};b={renderShape:function(n,v,k){var p=this,t,u,m,l,r,q,s,o=n.coords();r=p.elementName?'name="'+p.elementName+'" ':"";q=k?'class="'+k+'" ':"";l='<v:fill color="#'+v.fillColor+'" class="_fill" opacity="'+(v.fill?v.fillOpacity:0)+'" /><v:stroke class="_fill" opacity="'+v.strokeOpacity+'"/>';u=v.stroke?" strokeweight="+v.strokeWidth+' stroked="t" strokecolor="#'+v.strokeColor+'"':' stroked="f"';t=v.fill?' filled="t"':' filled="f"';switch(n.shape){case"rect":s="<v:rect "+q+r+t+u+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+o[0]+"px;top:"+o[1]+"px;width:"+(o[2]-o[0])+"px;height:"+(o[3]-o[1])+'px;">'+l+"</v:rect>";break;case"poly":s="<v:shape "+q+r+t+u+' coordorigin="0,0" coordsize="'+p.width+","+p.height+'" path="m '+o[0]+","+o[1]+" l "+o.slice(2).join(",")+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+p.width+"px;height:"+p.height+'px;">'+l+"</v:shape>";break;case"circ":case"circle":s="<v:oval "+q+r+t+u+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(o[0]-o[2])+"px;top:"+(o[1]-o[2])+"px;width:"+(o[2]*2)+"px;height:"+(o[2]*2)+'px;">'+l+"</v:oval>";break}m=e(s);e(p.canvas).append(m);return m},render:function(){var l,k=this;e.each(this.shapes,function(m,n){k.renderShape(n.mapArea,n.options)});if(this.masks.length){e.each(this.masks,function(m,n){l=i.updateProps({},n.options,{fillOpacity:1,fillColor:n.options.fillColorMask});k.renderShape(n.mapArea,l,"mapster_mask")})}this.active=false;return this.canvas},createCanvasFor:function(m){var k=m.scaleInfo.width,l=m.scaleInfo.height;return e('<var width="'+k+'" height="'+l+'" style="zoom:1;overflow:hidden;display:block;width:'+k+"px;height:"+l+'px;"></var>')[0]},clearHighlight:function(){e(this.map_data.overlay_canvas).children().remove()},removeSelections:function(k){if(k>=0){e(this.map_data.base_canvas).find('[name="static_'+k.toString()+'"]').remove()}else{e(this.map_data.base_canvas).children().remove()}}};e.each(["renderShape","addAltImage","render","createCanvasFor","clearHighlight","removeSelections","refreshSelections"],function(k,l){a[l]=(function(m){return function(){a[m]=(d.hasCanvas()?g[m]:b[m])||j;return a[m].apply(this,arguments)}}(l))})}(jQuery));(function(d){var a=d.mapster,b=a.utils,c=[];a.MapImages=function(e){this.owner=e;this.clear()};a.MapImages.prototype={constructor:a.MapImages,slice:function(){return c.slice.apply(this,arguments)},splice:function(){c.slice.apply(this.status,arguments);var e=c.slice.apply(this,arguments);return e},complete:function(){return d.inArray(false,this.status)<0},_add:function(f){var e=c.push.call(this,f)-1;this.status[e]=false;return e},indexOf:function(e){return d.inArray(e,this)},clear:function(){var e=this;if(e.ids&&e.ids.length>0){d.each(e.ids,function(f,g){delete e[g]})}e.ids=[];e.length=0;e.status=[];e.splice(0)},add:function(g,i){var e,h,f=this;if(!g){return}if(typeof g==="string"){h=g;g=f[h];if(typeof g==="object"){return f.indexOf(g)}g=d("<img />").addClass("mapster_el").hide();e=f._add(g[0]);g.bind("load",function(j){f.imageLoaded.call(f,j)}).bind("error",function(j){f.imageLoadError.call(f,j)});g.attr("src",h)}else{e=f._add(d(g)[0])}if(i){if(this[i]){throw (i+" is already used or is not available as an altImage alias.")}f.ids.push(i);f[i]=f[e]}return e},bind:function(g){var h=this,i,e=h.owner.options.configTimeout/200,f=function(){var j;j=h.length;while(j-->0){if(!h.isLoaded(j)){break}}if(h.complete()){h.resolve()}else{if(e-->0){h.imgTimeout=window.setTimeout(function(){f.call(h,true)},50)}else{h.imageLoadError.call(h)}}};i=h.deferred=b.defer();f();return i},resolve:function(){var e=this,f=e.deferred;if(f){e.deferred=null;f.resolve()}},imageLoaded:function(h){var g=this,f=g.indexOf(h.target);if(f>=0){g.status[f]=true;if(d.inArray(false,g.status)<0){g.resolve()}}},imageLoadError:function(g){clearTimeout(this.imgTimeout);this.triesLeft=0;var f=g?"The image "+g.target.src+" failed to load.":"The images never seemed to finish loading. You may just need to increase the configTimeout if images could take a long time to load.";throw f},isLoaded:function(g){var f,h=this,e=h.status;if(e[g]){return true}f=h[g];if(typeof f.complete!=="undefined"){e[g]=f.complete}else{e[g]=!!b.imgWidth(f)}return e[g]}}}(jQuery));(function(h){var d=h.mapster,k=d.utils;function a(m){h.extend(m,{complete:false,map:null,base_canvas:null,overlay_canvas:null,commands:[],data:[],mapAreas:[],_xref:{},highlightId:-1,currentAreaId:-1,_tooltip_events:[],scaleInfo:null,index:-1,activeAreaEvent:null})}function e(m){return[m,m.render_highlight,m.render_select]}function g(o){var n=o.options,m=o.images;if(d.hasCanvas()){h.each(n.altImages||{},function(p,q){m.add(q,p)});h.each([n].concat(n.areas),function(p,q){h.each(e(q),function(r,s){if(s&&s.altImage){s.altImageId=m.add(s.altImage)}})})}o.area_options=k.updateProps({},d.area_defaults,n)}function f(q,o,p,n){n=n||k.when.defer();function m(r){if(q.currentAreaId!==r&&q.highlightId>=0){n.resolve()}}if(q.activeAreaEvent){window.clearTimeout(q.activeAreaEvent);q.activeAreaEvent=0}if(o<0){return}if(p.owner.currentAction||o){q.activeAreaEvent=window.setTimeout((function(){return function(){f(q,0,p,n)}}(p)),o||100)}else{m(p.areaId)}return n}function c(m){if(!d.hasCanvas()){this.blur()}m.preventDefault()}function j(n,o){var p=n.getAllDataForArea(this),m=p.length?p[0]:null;if(!m||m.isNotRendered()||m.owner.currentAction){return}if(n.currentAreaId===m.areaId){return}if(n.highlightId!==m.areaId){n.clearEffects();m.highlight();if(n.options.showToolTip){h.each(p,function(q,r){if(r.effectiveOptions().toolTip){r.showToolTip()}})}}n.currentAreaId=m.areaId;if(h.isFunction(n.options.onMouseover)){n.options.onMouseover.call(this,{e:o,options:m.effectiveOptions(),key:m.key,selected:m.isSelected()})}}function i(p,q){var n,m=p.getDataForArea(this),o=p.options;if(p.currentAreaId<0||!m){return}n=p.getDataForArea(q.relatedTarget);if(n===m){return}p.currentAreaId=-1;m.area=null;f(p,o.mouseoutDelay,m).then(p.clearEffects);if(h.isFunction(o.onMouseout)){o.onMouseout.call(this,{e:q,options:o,key:m.key,selected:m.isSelected()})}}function b(n){var m=n.options;n.ensureNoHighlight();if(m.toolTipClose&&h.inArray("area-mouseout",m.toolTipClose)>=0&&n.activeToolTip){n.clearToolTip()}}function l(w,u){var r,v,o,q,x,s,t=this,p=w.getDataForArea(this),n=w.options;function m(z){var y,A;x=(z.isSelectable()&&(z.isDeselectable()||!z.isSelected()));if(x){q=!z.isSelected()}else{q=z.isSelected()}o=d.getBoundList(n,z.key);if(h.isFunction(n.onClick)){s=n.onClick.call(t,{e:u,listTarget:o,key:z.key,selected:q});if(k.isBool(s)){if(!s){return false}A=h(z.area).attr("href");if(A!=="#"){window.location.href=A;return false}}}if(x){r=z.toggle()}if(n.boundList&&n.boundList.length>0){d.setBoundListProperties(n,o,z.isSelected())}y=z.effectiveOptions();if(y.includeKeys){v=k.split(y.includeKeys);h.each(v,function(C,D){var B=w.getDataForKey(D.toString());if(!B.options.isMask){m(B)}})}}c.call(this,u);if(n.clickNavigate&&p.href){window.location.href=p.href;return}if(p&&!p.owner.currentAction){n=w.options;m(p)}}d.MapData=function(o,m){var n=this;n.image=o;n.images=new d.MapImages(n);n.graphics=new d.Graphics(n);n.imgCssText=o.style.cssText||null;a(n);n.configureOptions(m);n.mouseover=function(p){j.call(this,n,p)};n.mouseout=function(p){i.call(this,n,p)};n.click=function(p){l.call(this,n,p)};n.clearEffects=function(p){b.call(this,n,p)}};d.MapData.prototype={constructor:d.MapData,configureOptions:function(m){this.options=k.updateProps({},d.defaults,m)},bindImages:function(){var n=this,m=n.images;if(m.length>2){m.splice(2)}else{if(m.length===0){m.add(n.image);m.add(n.image.src)}}g(n);return n.images.bind()},isActive:function(){return !this.complete||this.currentAction},state:function(){return{complete:this.complete,resizing:this.currentAction==="resizing",zoomed:this.zoomed,zoomedArea:this.zoomedArea,scaleInfo:this.scaleInfo}},wrapId:function(){return"mapster_wrap_"+this.index},_idFromKey:function(m){return typeof m==="string"&&this._xref.hasOwnProperty(m)?this._xref[m]:-1},getSelected:function(){var m="";h.each(this.data,function(n,o){if(o.isSelected()){m+=(m?",":"")+this.key}});return m},getAllDataForArea:function(s,r){var p,n,m,q=this,o=h(s).filter("area").attr(q.options.mapKey);if(o){m=[];o=k.split(o);for(p=0;p<(r||o.length);p++){n=q.data[q._idFromKey(o[p])];n.area=s.length?s[0]:s;m.push(n)}}return m},getDataForArea:function(n){var m=this.getAllDataForArea(n,1);return m?m[0]||null:null},getDataForKey:function(m){return this.data[this._idFromKey(m)]},getKeysForGroup:function(n){var m=this.getDataForKey(n);return !m?"":m.isPrimary?m.key:this.getPrimaryKeysForMapAreas(m.areas()).join(",")},getPrimaryKeysForMapAreas:function(m){var n=[];h.each(m,function(o,p){if(h.inArray(p.keys[0],n)<0){n.push(p.keys[0])}});return n},getData:function(m){if(typeof m==="string"){return this.getDataForKey(m)}else{if(m&&m.mapster||k.isElement(m)){return this.getDataForArea(m)}else{return null}}},ensureNoHighlight:function(){var m;if(this.highlightId>=0){this.graphics.clearHighlight();m=this.data[this.highlightId];m.changeState("highlight",false);this.setHighlightId(-1)}},setHighlightId:function(m){this.highlightId=m},clearSelections:function(){h.each(this.data,function(m,n){if(n.selected){n.deselect(true)}});this.removeSelectionFinish()},setAreaOptions:function(n){var p,o,m;n=n||[];for(p=n.length-1;p>=0;p--){o=n[p];if(o){m=this.getDataForKey(o.key);if(m){k.updateProps(m.options,o);if(k.isBool(o.selected)){m.selected=o.selected}}}}},drawSelections:function(o){var m,n=k.asArray(o);for(m=n.length-1;m>=0;m--){this.data[n[m]].drawSelection()}},redrawSelections:function(){h.each(this.data,function(m,n){if(n.isSelectedOrStatic()){n.drawSelection()}})},initialize:function(){var y,r,n,p,u,v,t,z,s,o,x,q,w=this,m=w.options;if(w.complete){return}s=h(w.image);u=s.parent().attr("id");if(u&&u.length>=12&&u.substring(0,12)==="mapster_wrap"){p=s.parent();p.attr("id",w.wrapId())}else{p=h('<div id="'+w.wrapId()+'"></div>');if(m.wrapClass){if(m.wrapClass===true){p.addClass(s[0].className)}else{p.addClass(m.wrapClass)}}}w.wrapper=p;w.scaleInfo=q=k.scaleMap(w.images[0],w.images[1],m.scaleMap);w.base_canvas=r=w.graphics.createVisibleCanvas(w);w.overlay_canvas=n=w.graphics.createVisibleCanvas(w);y=h(w.images[1]).addClass("mapster_el "+w.images[0].className).attr({id:null,usemap:null});z=k.size(w.images[0]);if(z.complete){y.css({width:z.width,height:z.height})}w.buildDataset();v={display:"block",position:"relative",padding:0,width:q.width,height:q.height};if(m.wrapCss){h.extend(v,m.wrapCss)}if(s.parent()[0]!==w.wrapper[0]){s.before(w.wrapper)}p.css(v);h(w.images.slice(2)).hide();for(t=1;t<w.images.length;t++){p.append(w.images[t])}p.append(r).append(n).append(s.css(d.canvas_style));k.setOpacity(w.images[0],0);h(w.images[1]).show();k.setOpacity(w.images[1],1);if(m.isSelectable&&m.onGetList){x=w.data.slice(0);if(m.sortList){if(m.sortList==="desc"){o=function(B,A){return B===A?0:(B>A?-1:1)}}else{o=function(B,A){return B===A?0:(B<A?-1:1)}}x.sort(function(B,A){B=B.value;A=A.value;return o(B,A)})}w.options.boundList=m.onGetList.call(w.image,x)}w.complete=true;w.processCommandQueue();if(m.onConfigured&&typeof m.onConfigured==="function"){m.onConfigured.call(s,true)}},buildDataset:function(o){var y,n,z,x,m,C,u,r,E,t,w,p,q,B,D=this,s=D.options,v;function A(G,H){var F=new d.AreaData(D,G,H);F.areaId=D._xref[G]=D.data.push(F)-1;return F.areaId}D._xref={};D.data=[];if(!o){D.mapAreas=[]}v=!s.mapKey;if(v){s.mapKey="data-mapster-key"}y=d.hasVml()?"area":(v?"area[coords]":"area["+s.mapKey+"]");n=h(D.map).find(y).unbind(".mapster");for(w=0;w<n.length;w++){x=0;C=n[w];m=h(C);if(!C.coords){continue}if(v){u=String(w);m.attr("data-mapster-key",u)}else{u=C.getAttribute(s.mapKey)}if(o){r=D.mapAreas[m.data("mapster")-1];r.configure(u)}else{r=new d.MapArea(D,C,u);D.mapAreas.push(r)}t=r.keys;for(z=t.length-1;z>=0;z--){E=t[z];if(s.mapValue){p=m.attr(s.mapValue)}if(v){x=A(D.data.length,p);q=D.data[x];q.key=E=x.toString()}else{x=D._xref[E];if(x>=0){q=D.data[x];if(p&&!D.data[x].value){q.value=p}}else{x=A(E,p);q=D.data[x];q.isPrimary=z===0}}r.areaDataXref.push(x);q.areasXref.push(w)}B=m.attr("href");if(B&&B!=="#"&&!q.href){q.href=B}if(!r.nohref){m.bind("click.mapster",D.click);if(!d.isTouch){m.bind("mouseover.mapster",D.mouseover).bind("mouseout.mapster",D.mouseout).bind("mousedown.mapster",D.mousedown)}}m.data("mapster",w+1)}D.setAreaOptions(s.areas);D.redrawSelections()},processCommandQueue:function(){var n,m=this;while(!m.currentAction&&m.commands.length){n=m.commands[0];m.commands.splice(0,1);d.impl[n.command].apply(n.that,n.args)}},clearEvents:function(){h(this.map).find("area").unbind(".mapster");h(this.images).unbind(".mapster")},_clearCanvases:function(m){if(!m){h(this.base_canvas).remove()}h(this.overlay_canvas).remove()},clearMapData:function(n){var m=this;this._clearCanvases(n);h.each(this.data,function(o,p){p.reset()});this.data=null;if(!n){this.image.style.cssText=this.imgCssText;h(this.wrapper).before(this.image).remove()}m.images.clear();this.image=null;k.ifFunction(this.clearTooltip,this)},removeSelectionFinish:function(){var m=this.graphics;m.refreshSelections();m.clearHighlight()}}}(jQuery));(function(f){var c=f.mapster,d=c.utils;function b(g){var h=this,i=h.owner;if(i.options.singleSelect){i.clearSelections()}if(!h.isSelected()){if(g){h.optsCache=f.extend(h.effectiveRenderOptions("select"),g,{altImageId:i.images.add(g.altImage)})}h.drawSelection();h.selected=true;h.changeState("select",true)}if(i.options.singleSelect){i.graphics.refreshSelections()}}function e(g){var h=this;h.selected=false;h.changeState("select",false);h.optsCache=null;h.owner.graphics.removeSelections(h.areaId);if(!g){h.owner.removeSelectionFinish()}}function a(g){var h=this;if(!h.isSelected()){h.select(g)}else{h.deselect()}return h.isSelected()}c.AreaData=function(g,h,i){f.extend(this,{owner:g,key:h||"",isPrimary:true,areaId:-1,href:"",value:i||"",options:{},selected:null,areasXref:[],area:null,optsCache:null})};c.AreaData.prototype={constuctor:c.AreaData,select:b,deselect:e,toggle:a,areas:function(){var h,g=[];for(h=0;h<this.areasXref.length;h++){g.push(this.owner.mapAreas[this.areasXref[h]])}return g},coords:function(h){var g=[];f.each(this.areas(),function(j,k){g=g.concat(k.coords(h))});return g},reset:function(){f.each(this.areas(),function(g,h){h.reset()});this.areasXref=[];this.options=null},isSelectedOrStatic:function(){var g=this.effectiveOptions();return d.isBool(g.staticState)?g.staticState:this.isSelected()},isSelected:function(){return d.isBool(this.selected)?this.selected:d.isBool(this.owner.area_options.selected)?this.owner.area_options.selected:false},isSelectable:function(){return d.isBool(this.effectiveOptions().staticState)?false:(d.isBool(this.owner.options.staticState)?false:d.boolOrDefault(this.effectiveOptions().isSelectable,true))},isDeselectable:function(){return d.isBool(this.effectiveOptions().staticState)?false:(d.isBool(this.owner.options.staticState)?false:d.boolOrDefault(this.effectiveOptions().isDeselectable,true))},isNotRendered:function(){var g=f(this.area);return g.attr("nohref")||!g.attr("href")||this.effectiveOptions().isMask},effectiveOptions:function(g){var h=d.updateProps({},this.owner.area_options,this.options,g||{},{id:this.areaId});h.selected=this.isSelected();return h},effectiveRenderOptions:function(j,g){var h,i=this.optsCache;if(!i||j==="highlight"){h=this.effectiveOptions(g);i=d.updateProps({},h,h["render_"+j]);if(j!=="highlight"){this.optsCache=i}}return f.extend({},i)},changeState:function(g,h){if(f.isFunction(this.owner.options.onStateChange)){this.owner.options.onStateChange.call(this.owner.image,{key:this.key,state:g,selected:h})}},highlight:function(g){var h=this.owner;if(this.effectiveOptions().highlight){h.graphics.addShapeGroup(this,"highlight",g)}h.setHighlightId(this.areaId);this.changeState("highlight",true)},drawSelection:function(){this.owner.graphics.addShapeGroup(this,"select")}};c.MapArea=function(g,h,j){if(!g){return}var i=this;i.owner=g;i.area=h;i.areaDataXref=[];i.originalCoords=[];f.each(d.split(h.coords),function(k,l){i.originalCoords.push(parseFloat(l))});i.length=i.originalCoords.length;i.shape=h.shape.toLowerCase();i.nohref=h.nohref||!h.href;i.configure(j)};c.MapArea.prototype={constructor:c.MapArea,configure:function(g){this.keys=d.split(g)},reset:function(){this.area=null},coords:function(g){return f.map(this.originalCoords,function(h){return g?h:h+g})}}}(jQuery));(function(b){var a=b.mapster.utils;a.areaCorners=function(p,r,o,s,q){var i,n,D,B,C,A,y,w,v,t,l,k,E,u,e=0,d=0,h,f,m,g,z,c,x=[];p=p.length?p:[p];o=o?b(o):b(document.body);i=o.offset();h=i.left;f=i.top;if(r){i=b(r).offset();e=i.left;d=i.top}for(u=0;u<p.length;u++){c=p[u];if(c.nodeName==="AREA"){m=a.split(c.coords,parseInt);switch(c.shape){case"circle":l=m[0];k=m[1];g=m[2];x=[];for(u=0;u<360;u+=20){z=u*Math.PI/180;x.push(l+g*Math.cos(z),k+g*Math.sin(z))}break;case"rect":x.push(m[0],m[1],m[2],m[1],m[2],m[3],m[0],m[3]);break;default:x=x.concat(m);break}for(u=0;u<x.length;u+=2){x[u]=parseInt(x[u],10)+e;x[u+1]=parseInt(x[u+1],10)+d}}else{c=b(c);i=c.position();x.push(i.left,i.top,i.left+c.width(),i.top,i.left+c.width(),i.top+c.height(),i.left,i.top+c.height())}}D=B=y=v=999999;C=A=w=t=-1;for(u=x.length-2;u>=0;u-=2){l=x[u];k=x[u+1];if(l<D){D=l;t=k}if(l>C){C=l;v=k}if(k<B){B=k;w=l}if(k>A){A=k;y=l}}if(s&&q){n=false;b.each([[w-s,B-q],[y,B-q],[D-s,t-q],[D-s,v],[C,t-q],[C,v],[w-s,A],[y,A]],function(j,F){if(!n&&(F[0]>h&&F[1]>f)){E=F;n=true;return false}});if(!n){E=[C,A]}}return E}}(jQuery));(function(c){var a=c.mapster,b=a.utils,d=a.MapArea.prototype;a.utils.getScaleInfo=function(e,g){var f;if(!g){f=1;g=e}else{f=e.width/g.width||e.height/g.height;if(f>0.98&&f<1.02){f=1}}return{scale:(f!==1),scalePct:f,realWidth:g.width,realHeight:g.height,width:e.width,height:e.height,ratio:e.width/e.height}};a.utils.scaleMap=function(h,f,i){var g=b.size(h),e=b.size(f,true);if(!e.complete()){throw ("Another script, such as an extension, appears to be interfering with image loading. Please let us know about this.")}if(!g.complete()){g=e}return this.getScaleInfo(g,i?e:null)};a.MapData.prototype.resize=function(g,t,j,s){var f,r,i,k,e,n,o=this;s=s||j;function q(u,p,v){if(a.hasCanvas()){u.width=p;u.height=v}else{c(u).width(p);c(u).height(v)}}function l(){o.currentAction="";if(c.isFunction(s)){s()}o.processCommandQueue()}function m(){q(o.overlay_canvas,g,t);if(e>=0){var p=o.data[e];p.tempOptions={fade:false};o.getDataForKey(p.key).highlight();p.tempOptions=null}q(o.base_canvas,g,t);o.redrawSelections();l()}function h(){c(o.image).css(i);o.scaleInfo=b.getScaleInfo({width:g,height:t},{width:o.scaleInfo.realWidth,height:o.scaleInfo.realHeight});c.each(o.data,function(p,u){c.each(u.areas(),function(v,w){w.resize()})})}if(o.scaleInfo.width===g&&o.scaleInfo.height===t){return}e=o.highlightId;if(!g){n=t/o.scaleInfo.realHeight;g=Math.round(o.scaleInfo.realWidth*n)}if(!t){n=g/o.scaleInfo.realWidth;t=Math.round(o.scaleInfo.realHeight*n)}i={width:String(g)+"px",height:String(t)+"px"};if(!a.hasCanvas()){c(o.base_canvas).children().remove()}k=c(o.wrapper).find(".mapster_el").add(o.wrapper);if(j){r=[];o.currentAction="resizing";k.each(function(p,u){f=b.defer();r.push(f);c(u).animate(i,{duration:j,complete:f.resolve,easing:"linear"})});f=b.defer();r.push(f);b.when.all(r).then(m);h();f.resolve()}else{k.css(i);h();m()}};a.MapArea=b.subclass(a.MapArea,function(){this.base.init();if(this.owner.scaleInfo.scale){this.resize()}});d.coords=function(f,i){var e,h=[],g=f||this.owner.scaleInfo.scalePct,k=i||0;if(g===1&&i===0){return this.originalCoords}for(e=0;e<this.length;e++){h.push(Math.round(this.originalCoords[e]*g)+k)}return h};d.resize=function(){this.area.coords=this.coords().join(",")};d.reset=function(){this.area.coords=this.coords(1).join(",")};a.impl.resize=function(g,f,h,i){if(!g&&!f){return false}var e=(new a.Method(this,function(){this.resize(g,f,h,i)},null,{name:"resize",args:arguments})).go();return e}}(jQuery));(function(g){var a=g.mapster,d=a.utils;g.extend(a.defaults,{toolTipContainer:'<div style="border: 2px solid black; background: #EEEEEE; width:160px; padding:4px; margin: 4px; -moz-box-shadow: 3px 3px 5px #535353; -webkit-box-shadow: 3px 3px 5px #535353; box-shadow: 3px 3px 5px #535353; -moz-border-radius: 6px 6px 6px 6px; -webkit-border-radius: 6px; border-radius: 6px 6px 6px 6px; opacity: 0.9;"></dteniv>',showToolTip:false,toolTipFade:true,toolTipClose:["area-mouseout","image-mouseout"],onShowToolTip:null,onHideToolTip:null});g.extend(a.area_defaults,{toolTip:null,toolTipClose:null});function e(j,k,i){var l;if(k){l=typeof k==="string"?g(k):g(k).clone();l.append(j)}else{l=g(j)}l.css(g.extend((i||{}),{display:"block",position:"absolute"})).hide();g("body").append(l);l.attr("data-opacity",l.css("opacity")).css("opacity",0);return l.show()}function h(m,k){var i={left:k.left+"px",top:k.top+"px"},j=m.attr("data-opacity")||0,l=m.css("z-index");if(parseInt(l,10)===0||l==="auto"){i["z-index"]=9999}m.css(i).addClass("mapster_tooltip");if(k.fadeDuration&&k.fadeDuration>0){d.fader(m[0],0,j,k.fadeDuration)}else{d.setOpacity(m[0],j)}}a.MapData.prototype.clearToolTip=function(){if(this.activeToolTip){this.activeToolTip.stop().remove();this.activeToolTip=null;this.activeToolTipID=null;d.ifFunction(this.options.onHideToolTip,this)}};function b(k,i,l,o,m,j){var n=l+".mapster-tooltip";if(g.inArray(i,k)>=0){o.unbind(n).bind(n,function(p){if(!m||m.call(this,p)){o.unbind(".mapster-tooltip");if(j){j.call(this)}}});return{object:o,event:n}}}function f(m,o,n,i,k){var j,l={};k=k||{};if(o){j=d.areaCorners(o,n,i,m.outerWidth(true),m.outerHeight(true));l.left=j[0];l.top=j[1]}else{l.left=k.left;l.top=k.top}l.left+=(k.offsetx||0);l.top+=(k.offsety||0);l.css=k.css;l.fadeDuration=k.fadeDuration;h(m,l);return m}a.AreaData.prototype.showToolTip=function(m,s){var r,j,l,n,p,k={},q=this,o=q.owner,i=q.effectiveOptions();s=s?g.extend({},s):{};m=m||i.toolTip;j=s.closeEvents||i.toolTipClose||o.options.toolTipClose||"tooltip-click";p=typeof s.template!=="undefined"?s.template:o.options.toolTipContainer;s.closeEvents=typeof j==="string"?j=d.split(j):j;s.fadeDuration=s.fadeDuration||(o.options.toolTipFade?(o.options.fadeDuration||i.fadeDuration):0);l=q.area?q.area:g.map(q.areas(),function(t){return t.area});if(o.activeToolTipID===q.areaId){return}o.clearToolTip();o.activeToolTip=r=e(m,p,s.css);o.activeToolTipID=q.areaId;n=function(){o.clearToolTip()};b(j,"area-click","click",g(o.map),null,n);b(j,"tooltip-click","click",r,null,n);b(j,"image-mouseout","mouseout",g(o.image),function(t){return(t.relatedTarget&&t.relatedTarget.nodeName!=="AREA"&&t.relatedTarget!==q.area)},n);f(r,l,o.image,s.container,p,s);d.ifFunction(o.options.onShowToolTip,q.area,{toolTip:r,options:k,areaOptions:i,key:q.key,selected:q.isSelected()});return r};function c(i){return(i?((typeof i==="string"||i.jquery)?i:i.content):null)}a.impl.tooltip=function(k,j){return(new a.Method(this,function l(){var n,o,m=this;if(!k){m.clearToolTip()}else{o=g(k);if(m.activeToolTipID===o[0]){return}m.clearToolTip();m.activeToolTip=n=e(c(j),j.template||m.options.toolTipContainer,j.css);m.activeToolTipID=o[0];b(["tooltip-click"],"tooltip-click","click",n,null,function(){m.clearToolTip()});m.activeToolTip=n=f(n,o,m.image,j.container,j)}},function i(){if(g.isPlainObject(k)&&!j){j=k}this.showToolTip(c(j),j)},{name:"tooltip",args:arguments,key:k})).go()}}(jQuery));
\ No newline at end of file
--- a/src/pyams_content/skin/resources/js/pyams_content.js	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,665 +0,0 @@
-(function($, globals) {
-
-	"use strict";
-
-	var MyAMS = globals.MyAMS;
-
-	var PyAMS_content = {
-
-		/**
-		 * Custom widgets management
-		 */
-		widget: {
-
-			/** Treeview widget */
-			treeview: {
-
-				selectFolder: function(event, node) {
-					var target = $(event.target);
-					target.siblings('input[type="hidden"]').val(node.id);
-				},
-
-				unselectFolder: function(event, node) {
-					var target = $(event.target);
-					target.siblings('input[type="hidden"]').val(null);
-				}
-			}
-		},
-
-		/**
-		 * TinyMCE editor configuration
-		 */
-		TinyMCE: {
-
-			initEditor: function(settings) {
-
-				// Update TinyMCE translations
-				tinyMCE.addI18n('fr', {
-					"Link list": "Liste de liens",
-					"Toggle h3 header": "En-tête H3",
-					"Toggle h4 header": "En-tête H4",
-					"Insert internal link": "Insérer un lien interne",
-					"Link title": "Texte à afficher",
-					"Internal number": "N° interne"
-				});
-
-				// Declare internal link input plug-in
-				tinymce.PluginManager.add('internal_links', function(editor, url) {
-					editor.addButton('internal_links', {
-						icon: 'cloud-check',
-						tooltip: "Insert internal link",
-						image: '/--static--/pyams_content/img/internal-link.png',
-						onclick: function() {
-							editor.windowManager.open({
-								title: "Insert internal link",
-								body: [
-									{
-										type: 'textbox',
-										name: 'oid',
-										label:'Internal number'
-									}, {
-										type: 'textbox',
-										name: 'title',
-										label: 'Link title',
-										value: editor.selection.getContent()
-									}
-								],
-								onsubmit: function(e) {
-									editor.insertContent('<a href="oid://' + e.data.oid + '">' + e.data.title + '</a>');
-								}
-							});
-						}
-					})
-				});
-
-				// Declare direct H3 and H4 style formatter
-				tinyMCE.PluginManager.add('headers', function (editor, url) {
-					['h3', 'h4'].forEach(function (name) {
-						editor.addButton("header-" + name, {
-							tooltip: "Toggle " + name + " header",
-							text: name.toUpperCase(),
-							onClick: function () {
-								editor.execCommand('mceToggleFormat', false, name);
-							},
-							onPostRender: function () {
-								var self = this,
-									setup = function () {
-										editor.formatter.formatChanged(name, function (state) {
-											self.active(state);
-										});
-									};
-								editor.formatter ? setup() : editor.on('init', setup);
-							}
-						})
-					});
-				});
-
-				// Update TinyMCE settings
-				settings.image_list = PyAMS_content.TinyMCE.getImagesList;
-				settings.link_list = PyAMS_content.TinyMCE.getLinksList;
-				settings.style_formats = [
-					{
-						title: 'Inline',
-						items: [
-							{title: 'Bold', icon: 'bold', format: 'bold'},
-							{title: 'Italic', icon: 'italic', format: 'italic'},
-							{title: 'Underline', icon: 'underline', format: 'underline'},
-							{title: 'Strikethrough', icon: 'strikethrough', format: 'strikethrough'},
-							{title: 'Superscript', icon: 'superscript', format: 'superscript'},
-							{title: 'Subscript', icon: 'subscript', format: 'subscript'},
-							{title: 'Code', icon: 'code', format: 'code'}
-						]
-					},
-					{
-						title: 'Blocks',
-						items: [
-							{title: 'Paragraph', format: 'p'},
-							{title: 'Blockquote', format: 'blockquote'},
-							{title: 'Div', format: 'div'},
-							{title: 'Pre', format: 'pre'}
-						]
-					},
-					{
-						title: 'Alignment',
-						items: [
-							{title: 'Left', icon: 'alignleft', format: 'alignleft'},
-							{title: 'Center', icon: 'aligncenter', format: 'aligncenter'},
-							{title: 'Right', icon: 'alignright', format: 'alignright'},
-							{title: 'Justify', icon: 'alignjustify', format: 'alignjustify'}
-						]
-					}
-				];
-				settings.plugins += ' internal_links headers';
-				if (settings.toolbar1) {
-					settings.toolbar1 = "undo redo | header-h3 header-h4 styleselect | bold italic | " +
-										"alignleft aligncenter alignright alignjustify | bullist numlist outdent indent";
-				}
-				if (settings.toolbar2) {
-					settings.toolbar2 = "forecolor backcolor | charmap internal_links link | fullscreen preview print | code";
-				}
-				return settings;
-			},
-
-			getImagesList: function(callback) {
-				var form = $(document.activeElement).parents('form');
-				if (form.exists()) {
-					var base = form.attr('data-ams-form-handler') || form.attr('action');
-					var target = base.substr(0, base.lastIndexOf('/') + 1);
-					return MyAMS.ajax.post(target + 'get-images-list.json', {}, callback);
-				}
-			},
-
-			getLinksList: function(callback) {
-				var form = $(document.activeElement).parents('form');
-				if (form.exists()) {
-					var base = form.attr('data-ams-form-handler') || form.attr('action');
-					var target = base.substr(0, base.lastIndexOf('/')+1);
-					return MyAMS.ajax.post(target + 'get-links-list.json', {}, callback);
-				}
-			}
-		},
-
-		/**
-		 * Galleries management
-		 */
-		galleries: {
-
-			addMediaCallback: function(options) {
-				var gallery = $('.gallery', $('[id="' + options.parent + '"]'));
-				var switcher = gallery.siblings('.switcher');
-				if (switcher.parents('fieldset:first').hasClass('switched')) {
-					switcher.click();
-				}
-				for (var i=0; i < options.medias.length; i++) {
-					gallery.append(options.medias[i]);
-				}
-				gallery.sortable({
-					helper: 'clone',
-					stop: PyAMS_content.galleries.setOrder
-				})
-			},
-
-			updateMediaTitle: function(options) {
-				$('img[id="' + options.media_id + '"]').attr('original-title', options.title);
-			},
-
-			switchMediaVisibility: function(element) {
-				return function() {
-					var source = $(this);
-					var media = source.parents('.media');
-					var gallery = media.parents('.gallery');
-					$('i', source).attr('class', 'fa fa-fw fa-spinner fa-pulse');
-					MyAMS.ajax.post(gallery.data('ams-location') + '/set-media-visibility.json',
-									{object_name: media.data('ams-element-name')},
-									function(result, status) {
-										if (result.visible) {
-											$('i', source).attr('class', 'fa fa-fw fa-eye');
-											source.parents('.btn-group').siblings('a.fancyimg').removeClass('not-visible');
-										} else {
-											$('i', source).attr('class', 'fa fa-fw fa-eye-slash text-danger');
-											source.parents('.btn-group').siblings('a.fancyimg').addClass('not-visible');
-										}
-									});
-				};
-			},
-
-			setOrder: function(event, ui) {
-				if (ui && ui.item.hasClass('already-dropped')) {
-					return;
-				}
-				var gallery = ui.item.parents('.gallery');
-				var ids = $('.media', gallery).listattr('data-ams-element-name');
-				MyAMS.ajax.post(gallery.data('ams-location') + '/set-medias-order.json',
-								{medias: JSON.stringify(ids)});
-			},
-
-			removeMedia: function(element) {
-				return function() {
-					var link = $(this);
-					MyAMS.skin.bigBox({
-						title: MyAMS.i18n.WARNING,
-						content: '<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; ' + MyAMS.i18n.DELETE_WARNING,
-						buttons: MyAMS.i18n.BTN_OK_CANCEL
-					}, function(button) {
-						if (button === MyAMS.i18n.BTN_OK) {
-							var gallery = link.parents('.gallery');
-							var location = gallery.data('ams-location');
-							var media = link.parents('.media');
-							var object_name = media.data('ams-element-name');
-							MyAMS.ajax.post(location + '/delete-element.json',
-											{object_name: object_name},
-											function(result, status) {
-												media.remove();
-												if (result.handle_json) {
-													MyAMS.ajax.handleJSON(result);
-												}
-											});
-						}
-					});
-				};
-			},
-
-			afterFancyboxLoad: function(current, previous) {
-				var element = current.element;
-				if (element.hasClass('not-visible')) {
-					current.inner.prepend('<div class="hidden-mask"></div>');
-				}
-			}
-		},
-
-		/**
-		 * Illustrations management
-		 */
-		illustration: {
-
-			addIllustration: function() {
-				var source = $(this);
-				var group = source.parents('.btn-group');
-				var legend = group.siblings('legend.switcher');
-				$('i.fa-plus', legend).click();
-				source.hide();
-				$('input[type="file"]', legend.siblings('.form-group:first')).click();
-			}
-		},
-
-		/**
-		 * Paragraphs management
-		 */
-		paragraphs: {
-
-			/* Store and restore paragraphs state on reload */
-			preReload: function() {
-				PyAMS_content.paragraphs.switched = $('i.switch.fa-minus-square-o', '#paragraphs_list').parents('tr').listattr('id');
-			},
-
-			postReload: function() {
-				$(PyAMS_content.paragraphs.switched).each(function() {
-					$('i.switch.fa-plus-square-o', '[id="' + this + '"]').parents('div').first().click();
-				});
-				delete PyAMS_content.paragraphs.switched;
-			},
-
-			refreshParagraph: function(changes) {
-				var para = $('tr[id="' + changes.object_id + '"]');
-				$('span.title', para).html(changes.title || ' - - - - - - - -');
-			},
-
-			switchEditor: function(element) {
-				var source = $(this);
-				var switcher = $('i.switch', source);
-				var td = source.parents('td');
-				var editor = $('.editor', td);
-				var para = source.parents('tr');
-				if (switcher.hasClass('fa-plus-square-o')) {
-					var container = para.parents('table');
-					editor.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>');
-					MyAMS.ajax.post(container.data('ams-location') + '/get-paragraph-editor.json',
-									{object_name: para.data('ams-element-name')},
-									function(result) {
-										editor.html(result);
-										if (result) {
-											MyAMS.initContent(editor);
-											switcher.removeClass('fa-plus-square-o')
-													.addClass('fa-minus-square-o');
-											para.data('ams-disabled-handlers', true);
-											MyAMS.skin.scrollTo(editor, {
-												offset: editor.height() - para.height()
-											});
-										}
-									});
-				} else {
-					MyAMS.skin.cleanContainer(editor);
-					editor.empty();
-					switcher.removeClass('fa-minus-square-o')
-							.addClass('fa-plus-square-o');
-					para.removeData('ams-disabled-handlers');
-				}
-			},
-
-			switchLastEditor: function(table_id) {
-				var table = $('table[id="' + table_id + '"]');
-				var tr = $('tr:last', table);
-				$('[data-ams-click-handler="PyAMS_content.paragraphs.switchEditor"]', tr).click();
-			},
-
-			switchAllEditors: function(element) {
-				var source = $(this);
-				var switcher = $('i', source);
-				var container = source.parents('table');
-				if (switcher.hasClass('fa-plus-square-o')) {
-					switcher.removeClass('fa-plus-square-o')
-							.addClass('fa-cog fa-spin');
-					MyAMS.ajax.post(container.data('ams-location') + '/get-paragraphs-editors.json',
-									{},
-									function(result) {
-										for (var para_id in result) {
-											if (!result.hasOwnProperty(para_id)) {
-												continue;
-											}
-											var para = $('tr[data-ams-element-name="' + para_id + '"]', container);
-											var editor = $('.editor', para);
-											if (editor.is(':empty')) {
-												editor.html(result[para_id]);
-											}
-											$('.fa-plus-square-o', para).removeClass('fa-plus-square-o')
-																		.addClass('fa-minus-square-o');
-											para.data('ams-disabled-handlers', true);
-										}
-										if (!$('i.fa-plus-square-o', $('tbody', container)).exists()) {
-											switcher.removeClass('fa-cog fa-spin')
-													.addClass('fa-minus-square-o');
-										}
-										MyAMS.initContent(container);
-									});
-				} else {
-					$('.editor', container).each(function() {
-						MyAMS.skin.cleanContainer($(this));
-						$(this).empty();
-					});
-					$('.fa-minus-square-o', container).removeClass('fa-minus-square-o')
-													  .addClass('fa-plus-square-o');
-					$('tr', container).removeData('ams-disabled-handlers');
-				}
-			},
-
-			updateToolbar: function(settings) {
-				var para = $('tr[id="' + settings.object_id + '"]');
-				var toolbar = $('.title-toolbar', para);
-				toolbar.replaceWith(settings.toolbar_tag);
-				toolbar = $('.title-toolbar', para);
-				MyAMS.initContent(toolbar);
-			},
-
-			updateMarkers: function(settings) {
-				var para = $('tr[id="' + settings.object_id + '"]');
-				var toolbar = $('.title-toolbar', para);
-				var marker = $('DIV.action.' + settings.marker_type, toolbar);
-				if (marker.exists()) {
-					marker.replaceWith(settings.marker_tag);
-				} else {
-					$(settings.marker_tag).appendTo(toolbar);
-				}
-				if (settings.marker_tag) {
-					marker = $('DIV.action.' + settings.marker_type, toolbar);
-					MyAMS.initContent(marker);
-				}
-				MyAMS.helpers.sort(toolbar, 'weight');
-			}
-		},
-
-		/**
-		 * Pictograms management
-		 */
-		pictograms: {
-
-			initManagerSelection: function() {
-				var form = $(this);
-				var selected = $('input[type="hidden"]', $('.selected-pictograms', form)).listattr('value');
-				return {
-					selected: JSON.stringify(selected)
-				};
-			},
-
-			switchPictogram: function() {
-				var pictogram = $(this);
-				var parent = pictogram.parents('.pictograms');
-				var manager = parent.parents('.pictograms-manager');
-				if (parent.hasClass('available-pictograms')) {
-					$('.selected-pictograms', manager).append(pictogram);
-				} else {
-					$('.available-pictograms', manager).append(pictogram);
-				}
-			}
-		},
-
-		/**
-		 * Themes management
-		 */
-		themes: {
-
-			initExtracts: function(element) {
-				var thesaurus = $('select[name="manager_themes.widgets.thesaurus_name:list"]', element);
-				var thesaurus_name = thesaurus.val();
-				var extract = $('select[name="manager_themes.widgets.extract_name:list"]', element);
-				var extract_name = extract.val();
-				if (thesaurus_name) {
-					MyAMS.jsonrpc.post('getExtracts',
-									   {thesaurus_name: thesaurus_name},
-									   {url: '/api/thesaurus/json'},
-									   function(data) {
-											extract.empty();
-											$(data.result).each(function() {
-												$('<option></option>').attr('value', this.id)
-																	  .attr('selected', this.id === extract_name)
-																	  .text(this.text)
-																	  .appendTo(extract);
-											});
-									   });
-				}
-			},
-
-			getExtracts: function(event) {
-				var select = $(event.currentTarget);
-				var form = select.parents('form');
-				var thesaurus_name = $('select[name="manager_themes.widgets.thesaurus_name:list"]', form).val();
-				var extract = $('select[name="manager_themes.widgets.extract_name:list"]', form);
-				var plugin = extract.data('select2');
-				if (thesaurus_name && (thesaurus_name !== '--NOVALUE--')) {
-					MyAMS.jsonrpc.post('getExtracts',
-									   {thesaurus_name: thesaurus_name},
-									   {url: '/api/thesaurus/json'},
-									   function(data) {
-											plugin.results.empty();
-											plugin.opts.populateResults.call(plugin, plugin.results, data.result,
-																			 {term: ''});
-									   });
-				} else {
-					extract.select2('data', null);
-					plugin.results.empty();
-					plugin.opts.populateResults.call(plugin, plugin.results, [], {term: ''});
-				}
-			}
-		},
-
-		/**
-		 * Form fields management
-		 */
-		fields: {
-
-			refreshField: function(changes) {
-				var container = $('table[id="form_fields_list"]');
-				var para = $('tr[data-ams-element-name="' + changes.object_name + '"]', container);
-				$('td:nth-child(4)', para).html(changes.title);
-			}
-		},
-
-		/**
-		 * Image map management
-		 */
-		imgmap: {
-
-			init: function() {
-				var image = $(this);
-				MyAMS.ajax.check($.fn.canvasAreaDraw,
-								 '/--static--/pyams_content/js/jquery-canvasAreaDraw' + MyAMS.devext + '.js',
-								 function() {
-									image.canvasAreaDraw({imageUrl: image.data('ams-image-url')});
-								 });
-			},
-
-			initPreview: function() {
-				var image = $(this);
-				MyAMS.ajax.check($.fn.mapster,
-								 '/--static--/pyams_content/js/jquery-imagemapster-1.2.10' + MyAMS.devext + '.js',
-								 function() {
-									image.mapster({
-										fillColor: 'ff0000',
-										fillOpacity: 0.35,
-										selected: true,
-										highlight: true,
-										staticState: true
-									});
-								 });
-			}
-		},
-
-		/**
-		 * Site management
-		 */
-		site: {
-
-			switchVisibility: function() {
-				return function() {
-					var source = $(this);
-					var content = source.parents('tr').first();
-					MyAMS.ajax.post(content.data('ams-location') + '/switch-content-visibility.json',
-									{object_name: content.data('ams-element-name')},
-									function(result, status) {
-										var klass = 'fa-eye';
-										if (!result.visible) {
-											klass += '-slash';
-										}
-										if (!result.published) {
-											klass += ' text-danger';
-										}
-										$('i', source).attr('class', 'fa fa-fw ' + klass);
-									});
-				};
-			}
-		},
-
-		/**
-		 * Review comments management
-		 */
-		review: {
-
-			timer: null,
-			timer_duration: {
-				general: 30000,
-				chat: 5000
-			},
-
-			initComments: function(element) {
-				var chat = $('.chat-body', element);
-				chat.animate({scrollTop: chat[0].scrollHeight}, 1000);
-				clearInterval(PyAMS_content.review.timer);
-				PyAMS_content.review.timer = setInterval(PyAMS_content.review.updateComments,
-														 PyAMS_content.review.timer_duration.chat);
-				MyAMS.skin.registerCleanCallback(PyAMS_content.review.cleanCommentsCallback);
-			},
-
-			cleanCommentsCallback: function() {
-				clearInterval(PyAMS_content.review.timer);
-				PyAMS_content.review.timer = setInterval(PyAMS_content.review.updateComments,
-														 PyAMS_content.review.timer_duration.general);
-			},
-
-			updateComments: function() {
-				var badge = $('.badge', 'nav a[href="#review-comments.html"]'),
-					count;
-				var chat = $('.chat-body', '.widget-body');
-				if (chat.exists()) {
-					count = $('.message', chat).length;
-				} else {
-					count = parseInt(badge.text());
-				}
-				MyAMS.ajax.post('get-last-review-comments.json', {count: count}, function(result) {
-					if (chat.exists()) {
-						badge.removeClass('bg-color-danger')
-							 .addClass('bg-color-info');
-					}
-					if (count !== result.count) {
-						badge.text(result.count).removeClass('hidden');
-						if (chat.exists()) {
-							$('.messages', chat).append(result.content);
-							chat.animate({scrollTop: chat[0].scrollHeight}, 1000);
-						}
-						if (!chat.exists()) {
-							badge.removeClass('bg-color-info')
-								 .addClass('bg-color-danger')
-								 .animate({'padding': '3px 12px 2px',
-										   'margin-right': '9px'}, 'slow', function() {
-									$(this).animate({'padding': '3px 6px 2px',
-													 'margin-right': '15px'}, 'slow');
-								 });
-						}
-					}
-				});
-			},
-
-			initCommentData: function(veto) {
-				var chat = $('.chat-body', '.widget-body');
-				return {count: $('.message', chat).length};
-			},
-
-			addCommentAction: function() {
-				return function() {
-					$('textarea[name="comment"]').focus();
-				};
-			},
-
-			addCommentCallback: function(options) {
-				var form = $(this);
-				var widget = form.parents('.widget-body');
-				$('.messages', widget).append(options.content);
-				$('textarea[name="comment"]', form).val('');
-				var chat = $('.chat-body', widget);
-				chat.animate({scrollTop: chat[0].scrollHeight}, 1000);
-				$('.badge', 'nav a[href="#review-comments.html"]').text(options.count).removeClass('hidden');
-			}
-		},
-
-		/**
-		 * Header management
-		 */
-		header: {
-
-			submitEditForm: function() {
-				var form = $(this).parents('form').first();
-				MyAMS.form.submit(form, {form_data: {'autosubmit': true}});
-			}
-		},
-
-		/**
-		 * Footer management
-		 */
-		footer: {
-
-			submitEditForm: function() {
-				var form = $(this).parents('form').first();
-				MyAMS.form.submit(form, {form_data: {'autosubmit': true}});
-			}
-		},
-
-		/**
-		 * User profile management
-		 */
-		profile: {
-
-			switchFavorite: function() {
-				var star = $(this);
-				var oid = star.data('sequence-oid');
-				MyAMS.ajax.post('switch-user-favorite.json',
-								{oid: oid},
-								function(result, status) {
-									if (result.favorite) {
-										star.removeClass('fa-star-o')
-											.addClass('fa-star');
-									} else {
-										star.removeClass('fa-star')
-											.addClass('fa-star-o');
-									}
-								});
-			}
-		}
-	};
-
-	var badge = $('.badge', 'nav a[href="#review-comments.html"]');
-	if (badge.exists()) {
-		PyAMS_content.review.timer = setInterval(PyAMS_content.review.updateComments,
-												 PyAMS_content.review.timer_duration.general);
-	}
-
-	globals.PyAMS_content = PyAMS_content;
-
-})(jQuery, this);
--- a/src/pyams_content/skin/resources/js/pyams_content.min.js	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-!function(t,e){"use strict";var a=e.MyAMS,i={widget:{treeview:{selectFolder:function(e,a){t(e.target).siblings('input[type="hidden"]').val(a.id)},unselectFolder:function(e,a){t(e.target).siblings('input[type="hidden"]').val(null)}}},TinyMCE:{initEditor:function(t){return tinyMCE.addI18n("fr",{"Link list":"Liste de liens","Toggle h3 header":"En-tête H3","Toggle h4 header":"En-tête H4","Insert internal link":"Insérer un lien interne","Link title":"Texte à afficher","Internal number":"N° interne"}),tinymce.PluginManager.add("internal_links",function(t,e){t.addButton("internal_links",{icon:"cloud-check",tooltip:"Insert internal link",image:"/--static--/pyams_content/img/internal-link.png",onclick:function(){t.windowManager.open({title:"Insert internal link",body:[{type:"textbox",name:"oid",label:"Internal number"},{type:"textbox",name:"title",label:"Link title",value:t.selection.getContent()}],onsubmit:function(e){t.insertContent('<a href="oid://'+e.data.oid+'">'+e.data.title+"</a>")}})}})}),tinyMCE.PluginManager.add("headers",function(t,e){["h3","h4"].forEach(function(e){t.addButton("header-"+e,{tooltip:"Toggle "+e+" header",text:e.toUpperCase(),onClick:function(){t.execCommand("mceToggleFormat",!1,e)},onPostRender:function(){var a=this,i=function(){t.formatter.formatChanged(e,function(t){a.active(t)})};t.formatter?i():t.on("init",i)}})})}),t.image_list=i.TinyMCE.getImagesList,t.link_list=i.TinyMCE.getLinksList,t.style_formats=[{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}],t.plugins+=" internal_links headers",t.toolbar1&&(t.toolbar1="undo redo | header-h3 header-h4 styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"),t.toolbar2&&(t.toolbar2="forecolor backcolor | charmap internal_links link | fullscreen preview print | code"),t},getImagesList:function(e){var i=t(document.activeElement).parents("form");if(i.exists()){var n=i.attr("data-ams-form-handler")||i.attr("action"),s=n.substr(0,n.lastIndexOf("/")+1);return a.ajax.post(s+"get-images-list.json",{},e)}},getLinksList:function(e){var i=t(document.activeElement).parents("form");if(i.exists()){var n=i.attr("data-ams-form-handler")||i.attr("action"),s=n.substr(0,n.lastIndexOf("/")+1);return a.ajax.post(s+"get-links-list.json",{},e)}}},galleries:{addMediaCallback:function(e){var a=t(".gallery",t('[id="'+e.parent+'"]')),n=a.siblings(".switcher");n.parents("fieldset:first").hasClass("switched")&&n.click();for(var s=0;s<e.medias.length;s++)a.append(e.medias[s]);a.sortable({helper:"clone",stop:i.galleries.setOrder})},updateMediaTitle:function(e){t('img[id="'+e.media_id+'"]').attr("original-title",e.title)},switchMediaVisibility:function(e){return function(){var e=t(this),i=e.parents(".media"),n=i.parents(".gallery");t("i",e).attr("class","fa fa-fw fa-spinner fa-pulse"),a.ajax.post(n.data("ams-location")+"/set-media-visibility.json",{object_name:i.data("ams-element-name")},function(a,i){a.visible?(t("i",e).attr("class","fa fa-fw fa-eye"),e.parents(".btn-group").siblings("a.fancyimg").removeClass("not-visible")):(t("i",e).attr("class","fa fa-fw fa-eye-slash text-danger"),e.parents(".btn-group").siblings("a.fancyimg").addClass("not-visible"))})}},setOrder:function(e,i){if(!i||!i.item.hasClass("already-dropped")){var n=i.item.parents(".gallery"),s=t(".media",n).listattr("data-ams-element-name");a.ajax.post(n.data("ams-location")+"/set-medias-order.json",{medias:JSON.stringify(s)})}},removeMedia:function(e){return function(){var e=t(this);a.skin.bigBox({title:a.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; '+a.i18n.DELETE_WARNING,buttons:a.i18n.BTN_OK_CANCEL},function(t){if(t===a.i18n.BTN_OK){var i=e.parents(".gallery").data("ams-location"),n=e.parents(".media"),s=n.data("ams-element-name");a.ajax.post(i+"/delete-element.json",{object_name:s},function(t,e){n.remove(),t.handle_json&&a.ajax.handleJSON(t)})}})}},afterFancyboxLoad:function(t,e){t.element.hasClass("not-visible")&&t.inner.prepend('<div class="hidden-mask"></div>')}},illustration:{addIllustration:function(){var e=t(this),a=e.parents(".btn-group").siblings("legend.switcher");t("i.fa-plus",a).click(),e.hide(),t('input[type="file"]',a.siblings(".form-group:first")).click()}},paragraphs:{preReload:function(){i.paragraphs.switched=t("i.switch.fa-minus-square-o","#paragraphs_list").parents("tr").listattr("id")},postReload:function(){t(i.paragraphs.switched).each(function(){t("i.switch.fa-plus-square-o",'[id="'+this+'"]').parents("div").first().click()}),delete i.paragraphs.switched},refreshParagraph:function(e){var a=t('tr[id="'+e.object_id+'"]');t("span.title",a).html(e.title||" - - - - - - - -")},switchEditor:function(e){var i=t(this),n=t("i.switch",i),s=i.parents("td"),r=t(".editor",s),o=i.parents("tr");if(n.hasClass("fa-plus-square-o")){var l=o.parents("table");r.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>'),a.ajax.post(l.data("ams-location")+"/get-paragraph-editor.json",{object_name:o.data("ams-element-name")},function(t){r.html(t),t&&(a.initContent(r),n.removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),o.data("ams-disabled-handlers",!0),a.skin.scrollTo(r,{offset:r.height()-o.height()}))})}else a.skin.cleanContainer(r),r.empty(),n.removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),o.removeData("ams-disabled-handlers")},switchLastEditor:function(e){var a=t('table[id="'+e+'"]'),i=t("tr:last",a);t('[data-ams-click-handler="PyAMS_content.paragraphs.switchEditor"]',i).click()},switchAllEditors:function(e){var i=t(this),n=t("i",i),s=i.parents("table");n.hasClass("fa-plus-square-o")?(n.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin"),a.ajax.post(s.data("ams-location")+"/get-paragraphs-editors.json",{},function(e){for(var i in e)if(e.hasOwnProperty(i)){var r=t('tr[data-ams-element-name="'+i+'"]',s),o=t(".editor",r);o.is(":empty")&&o.html(e[i]),t(".fa-plus-square-o",r).removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),r.data("ams-disabled-handlers",!0)}t("i.fa-plus-square-o",t("tbody",s)).exists()||n.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o"),a.initContent(s)})):(t(".editor",s).each(function(){a.skin.cleanContainer(t(this)),t(this).empty()}),t(".fa-minus-square-o",s).removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),t("tr",s).removeData("ams-disabled-handlers"))},updateToolbar:function(e){var i=t('tr[id="'+e.object_id+'"]'),n=t(".title-toolbar",i);n.replaceWith(e.toolbar_tag),n=t(".title-toolbar",i),a.initContent(n)},updateMarkers:function(e){var i=t('tr[id="'+e.object_id+'"]'),n=t(".title-toolbar",i),s=t("DIV.action."+e.marker_type,n);s.exists()?s.replaceWith(e.marker_tag):t(e.marker_tag).appendTo(n),e.marker_tag&&(s=t("DIV.action."+e.marker_type,n),a.initContent(s)),a.helpers.sort(n,"weight")}},pictograms:{initManagerSelection:function(){var e=t(this),a=t('input[type="hidden"]',t(".selected-pictograms",e)).listattr("value");return{selected:JSON.stringify(a)}},switchPictogram:function(){var e=t(this),a=e.parents(".pictograms"),i=a.parents(".pictograms-manager");a.hasClass("available-pictograms")?t(".selected-pictograms",i).append(e):t(".available-pictograms",i).append(e)}},themes:{initExtracts:function(e){var i=t('select[name="manager_themes.widgets.thesaurus_name:list"]',e).val(),n=t('select[name="manager_themes.widgets.extract_name:list"]',e),s=n.val();i&&a.jsonrpc.post("getExtracts",{thesaurus_name:i},{url:"/api/thesaurus/json"},function(e){n.empty(),t(e.result).each(function(){t("<option></option>").attr("value",this.id).attr("selected",this.id===s).text(this.text).appendTo(n)})})},getExtracts:function(e){var i=t(e.currentTarget).parents("form"),n=t('select[name="manager_themes.widgets.thesaurus_name:list"]',i).val(),s=t('select[name="manager_themes.widgets.extract_name:list"]',i),r=s.data("select2");n&&"--NOVALUE--"!==n?a.jsonrpc.post("getExtracts",{thesaurus_name:n},{url:"/api/thesaurus/json"},function(t){r.results.empty(),r.opts.populateResults.call(r,r.results,t.result,{term:""})}):(s.select2("data",null),r.results.empty(),r.opts.populateResults.call(r,r.results,[],{term:""}))}},fields:{refreshField:function(e){var a=t('table[id="form_fields_list"]'),i=t('tr[data-ams-element-name="'+e.object_name+'"]',a);t("td:nth-child(4)",i).html(e.title)}},imgmap:{init:function(){var e=t(this);a.ajax.check(t.fn.canvasAreaDraw,"/--static--/pyams_content/js/jquery-canvasAreaDraw"+a.devext+".js",function(){e.canvasAreaDraw({imageUrl:e.data("ams-image-url")})})},initPreview:function(){var e=t(this);a.ajax.check(t.fn.mapster,"/--static--/pyams_content/js/jquery-imagemapster-1.2.10"+a.devext+".js",function(){e.mapster({fillColor:"ff0000",fillOpacity:.35,selected:!0,highlight:!0,staticState:!0})})}},site:{switchVisibility:function(){return function(){var e=t(this),i=e.parents("tr").first();a.ajax.post(i.data("ams-location")+"/switch-content-visibility.json",{object_name:i.data("ams-element-name")},function(a,i){var n="fa-eye";a.visible||(n+="-slash"),a.published||(n+=" text-danger"),t("i",e).attr("class","fa fa-fw "+n)})}}},review:{timer:null,timer_duration:{general:3e4,chat:5e3},initComments:function(e){var n=t(".chat-body",e);n.animate({scrollTop:n[0].scrollHeight},1e3),clearInterval(i.review.timer),i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.chat),a.skin.registerCleanCallback(i.review.cleanCommentsCallback)},cleanCommentsCallback:function(){clearInterval(i.review.timer),i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.general)},updateComments:function(){var e,i=t(".badge",'nav a[href="#review-comments.html"]'),n=t(".chat-body",".widget-body");e=n.exists()?t(".message",n).length:parseInt(i.text()),a.ajax.post("get-last-review-comments.json",{count:e},function(a){n.exists()&&i.removeClass("bg-color-danger").addClass("bg-color-info"),e!==a.count&&(i.text(a.count).removeClass("hidden"),n.exists()&&(t(".messages",n).append(a.content),n.animate({scrollTop:n[0].scrollHeight},1e3)),n.exists()||i.removeClass("bg-color-info").addClass("bg-color-danger").animate({padding:"3px 12px 2px","margin-right":"9px"},"slow",function(){t(this).animate({padding:"3px 6px 2px","margin-right":"15px"},"slow")}))})},initCommentData:function(e){var a=t(".chat-body",".widget-body");return{count:t(".message",a).length}},addCommentAction:function(){return function(){t('textarea[name="comment"]').focus()}},addCommentCallback:function(e){var a=t(this),i=a.parents(".widget-body");t(".messages",i).append(e.content),t('textarea[name="comment"]',a).val("");var n=t(".chat-body",i);n.animate({scrollTop:n[0].scrollHeight},1e3),t(".badge",'nav a[href="#review-comments.html"]').text(e.count).removeClass("hidden")}},header:{submitEditForm:function(){var e=t(this).parents("form").first();a.form.submit(e,{form_data:{autosubmit:!0}})}},footer:{submitEditForm:function(){var e=t(this).parents("form").first();a.form.submit(e,{form_data:{autosubmit:!0}})}},profile:{switchFavorite:function(){var e=t(this),i=e.data("sequence-oid");a.ajax.post("switch-user-favorite.json",{oid:i},function(t,a){t.favorite?e.removeClass("fa-star-o").addClass("fa-star"):e.removeClass("fa-star").addClass("fa-star-o")})}}};t(".badge",'nav a[href="#review-comments.html"]').exists()&&(i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.general)),e.PyAMS_content=i}(jQuery,this);
--- a/src/pyams_content/skin/resources/js/tinymce/onflinks/langs/fr.js	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-tinyMCE.addI18n('fr', {
-	"Insert internal link": "Insérer un lien interne",
-	"Linktitle": "Texte du lien",
-	"Internal number": "N° interne"
-});
--- a/src/pyams_content/skin/resources/js/tinymce/onflinks/langs/fr.min.js	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-tinyMCE.addI18n("fr",{"Insert internal link":"Insérer un lien interne",Linktitle:"Texte du lien","Internal number":"N° interne"});
\ No newline at end of file
--- a/src/pyams_content/skin/resources/js/tinymce/onflinks/plugin.js	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-tinymce.PluginManager.add('internal_links', function(editor, url) {
-
-	editor.addButton('internal_links', {
-		icon: 'cloud-check',
-		tooltip: "Insert internal link",
-		image: '/--static--/pyams_content/img/external.png',
-		onclick: function() {
-			editor.windowManager.open({
-				title: "Insert internal link",
-				body: [
-					{type: 'textbox', name: 'title', label: 'Link title', value: editor.selection.getContent()},
-					{type: 'textbox', name: 'oid', label:'Internal number'}
-				],
-				onsubmit: function(e) {
-					editor.insertContent('<a href="oid://' + e.data.oid + '">' + e.data.title + '</a>');
-				}
-			});
-		}
-	})
-});
--- a/src/pyams_content/skin/resources/js/tinymce/onflinks/plugin.min.js	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-tinymce.PluginManager.add("internal_links",function(n,t){n.addButton("internal_links",{icon:"cloud-check",tooltip:"Insert internal link",image:"/--static--/pyams_content/img/external.png",onclick:function(){n.windowManager.open({title:"Insert internal link",body:[{type:"textbox",name:"title",label:"Link title",value:n.selection.getContent()},{type:"textbox",name:"oid",label:"Internal number"}],onsubmit:function(t){n.insertContent('<a href="oid://'+t.data.oid+'">'+t.data.title+"</a>")}})}})});
--- a/src/pyams_content/skin/resources/less/pyams_content.less	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-.ams-widget.comments {
-
-	.widget-body {
-		position: fixed;
-		height: ~"calc(100% - 337px)";
-
-		.chat-body {
-			position: relative;
-			height: 100%;
-		}
-
-		.chat-footer {
-			position: fixed;
-			bottom: 10px;
-		}
-
-		&,
-		.chat-footer {
-			width: ~"calc(100% - 240px)";
-
-			@media (max-width: 767px) {
-				width: ~"calc(100% - 10px)";
-			}
-			@media (min-width: 768px) and (max-width: 979px) {
-				width: ~"calc(100% - 20px)";
-			}
-
-			.minified & {
-				width: ~"calc(100% - 65px)";
-
-				@media (max-width: 767px) {
-					& {
-						width: ~"calc(100% - 55px)";
-					}
-				}
-			}
-			.hidden-menu & {
-				width: ~"calc(100% - 30px)";
-			}
-		}
-	}
-}
-
-
-.pictograms-manager {
-	.pictogram {
-		border-bottom: 1px solid silver;
-	}
-	.pictogram:last-child {
-		border-bottom: none;
-	}
-}
-
-
-.sortable {
-	&.gallery {
-		max-height: 550px;
-	}
-}
\ No newline at end of file
--- a/src/pyams_content/skin/zmi/__init__.py	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-# import standard library
-
-# import interfaces
-
-# import packages
--- a/src/pyams_content/skin/zmi/interfaces/__init__.py	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
-
-# import interfaces
-from pyams_skin.interfaces.viewlet import IMenuItem
-
-# import packages
-from zope.interface import Interface, Attribute
-
-
-#
-# Custom menus interfaces
-#
-
-class ISiteTreeMenu(IMenuItem):
-    """Site tree menu marker interface"""
-
-
-class ISiteTreeTable(Interface):
-    """Site tree table view marker interface"""
-
-
-class IDashboardMenu(IMenuItem):
-    """Dashboard menu"""
-
-
-class IMyDashboardMenu(IMenuItem):
-    """My contents dashboard menu"""
-
-
-class IAllContentsMenu(IMenuItem):
-    """Dashboard menu for all contents"""
-
-
-class ISummaryMenu(IMenuItem):
-    """Summary menu"""
-
-
-class IUserAddingsMenuLabel(Interface):
-    """Shared tool adding menu label"""
-
-    label = Attribute("Addings menu label")
--- a/src/pyams_content/skin/zmi/tinymce.py	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
-
-# import interfaces
-from pyams_content.skin import pyams_content
-from pyams_form.interfaces.form import IForm
-from pyams_skin.interfaces.tinymce import ITinyMCEConfiguration
-from pyams_skin.layer import IPyAMSLayer
-
-# import packages
-from pyams_utils.adapter import adapter_config, ContextRequestAdapter
-from pyams_utils.fanstatic import get_resource_path
-
-
-@adapter_config(context=(IForm, IPyAMSLayer), provides=ITinyMCEConfiguration)
-class TinyMCEEditorConfiguration(ContextRequestAdapter):
-    """TinyMCE editor configuration"""
-
-    @property
-    def configuration(self):
-        return {
-            'ams-plugins': 'pyams_content',
-            'ams-plugin-pyams_content-src': get_resource_path(pyams_content),
-            'ams-plugin-pyams_content-async': 'false',
-            'ams-tinymce-init-callback': 'PyAMS_content.TinyMCE.initEditor'
-        }
--- a/src/pyams_content/skin/zmi/viewlet/__init__.py	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
-
-# import interfaces
-
-# import packages
--- a/src/pyams_content/skin/zmi/viewlet/toplinks/__init__.py	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-import locale
-
-
-__docformat__ = 'restructuredtext'
-
-
-from hypatia.catalog import CatalogQuery
-from hypatia.interfaces import ICatalog
-from hypatia.query import And, Any, NotEq, Or
-
-from pyams_catalog.query import CatalogResultSet
-from pyams_content import _
-from pyams_content.shared.common.interfaces import IBaseSharedTool, ISharedSite
-from pyams_content.skin.zmi.interfaces import IUserAddingsMenuLabel
-from pyams_i18n.interfaces import II18n
-from pyams_skin.interfaces.viewlet import ITopLinksViewletManager
-from pyams_skin.viewlet.toplinks import TopLinksMenu, TopLinksViewlet
-from pyams_template.template import template_config
-from pyams_utils.list import unique
-from pyams_utils.registry import get_all_utilities_registered_for, get_utility
-from pyams_utils.url import absolute_url
-from pyams_viewlet.viewlet import viewlet_config
-from pyams_zmi.layer import IAdminLayer
-
-
-@viewlet_config(name='shared-sites.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=20)
-class SharedSitesMenu(TopLinksViewlet):
-    """Shared sites menu"""
-
-    label = ''
-    css_class = 'top-menu bordered margin-top-10'
-    dropdown_label = _("Shared sites")
-
-    def update(self):
-        super(SharedSitesMenu, self).update()
-        context = self.context
-        request = self.request
-        parent = self.__parent__
-        for site in sorted(get_all_utilities_registered_for(ISharedSite),
-                           key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', request=request) or '')):
-            menu = TopLinksMenu(context, request, parent, self)
-            menu.label = II18n(site).query_attribute('title', request=request) or site.__name__
-            menu.url = absolute_url(site, request, 'admin#dashboard.html')
-            self.viewlets.append(menu)
-
-
-@viewlet_config(name='shared-contents.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=30)
-class SharedContentsMenu(TopLinksViewlet):
-    """Shared contents menu"""
-
-    label = ''
-    css_class = 'top-menu bordered margin-top-10'
-    dropdown_label = _("Shared contents")
-
-    def update(self):
-        super(SharedContentsMenu, self).update()
-        context = self.context
-        request = self.request
-        parent = self.__parent__
-        for tool in sorted(get_all_utilities_registered_for(IBaseSharedTool),
-                           key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', request=request) or '')):
-            if ISharedSite.providedBy(tool) or (not tool.shared_content_menu):
-                continue
-            menu = TopLinksMenu(context, request, parent, self)
-            menu.label = II18n(tool).query_attribute('title', request=request) or tool.__name__
-            menu.url = absolute_url(tool, request, 'admin#dashboard.html')
-            self.viewlets.append(menu)
-
-
-@viewlet_config(name='shared-tools.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=40)
-class SharedToolsMenu(TopLinksViewlet):
-    """Shared tools menu"""
-
-    label = ''
-    css_class = 'top-menu bordered margin-top-10'
-    dropdown_label = _("Shared tools")
-
-    def update(self):
-        super(SharedToolsMenu, self).update()
-        context = self.context
-        request = self.request
-        parent = self.__parent__
-        for tool in sorted(get_all_utilities_registered_for(IBaseSharedTool),
-                           key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', request=request) or '')):
-            if ISharedSite.providedBy(tool) or tool.shared_content_menu:
-                continue
-            menu = TopLinksMenu(context, request, parent, self)
-            menu.label = II18n(tool).query_attribute('title', request=request) or tool.__name__
-            menu.url = absolute_url(tool, request, 'admin#dashboard.html')
-            self.viewlets.append(menu)
-
-
-@viewlet_config(name='user-roles.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=90)
-class UserRolesMenu(TopLinksViewlet):
-    """User roles menu"""
-
-    label = ''
-    css_class = 'top-menu bordered margin-top-10'
-    dropdown_label = _("My roles")
-
-    def update(self):
-        super(UserRolesMenu, self).update()
-        catalog = get_utility(ICatalog)
-        context = self.context
-        request = self.request
-        parent = self.__parent__
-        params = And(Or(Any(catalog['role:contributor'], {request.principal.id}),
-                        Any(catalog['role:manager'], {request.principal.id}),
-                        Any(catalog['role:pilot'], {request.principal.id})),
-                     NotEq(catalog['content_type'], None))
-        for tool in sorted(unique(CatalogResultSet(CatalogQuery(catalog).query(params))),
-                           key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', request=request) or '')):
-            menu = TopLinksMenu(context, request, parent, self)
-            menu.label = II18n(tool).query_attribute('title', request=request) or tool.__name__
-            menu.url = absolute_url(tool, request, 'admin#dashboard.html')
-            self.viewlets.append(menu)
-
-
-@viewlet_config(name='user-addings.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=95)
-@template_config(template='templates/user-addings.pt', layer=IAdminLayer)
-class UserAddingsMenu(TopLinksViewlet):
-    """User addings menu"""
-
-    label = ''
-    css_class = 'top-menu margin-top-5-neg'
-    dropdown_label = ''
-
-    def update(self):
-        super(UserAddingsMenu, self).update()
-        catalog = get_utility(ICatalog)
-        context = self.context
-        request = self.request
-        parent = self.__parent__
-        registry = request.registry
-        params = And(Any(catalog['role:contributor'], {request.principal.id}),
-                     NotEq(catalog['content_type'], None))
-        for tool in sorted(unique(CatalogResultSet(CatalogQuery(catalog).query(params))),
-                           key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', request=request) or '')):
-            content_class = tool.shared_content_factory.content_class
-            if content_class is None:
-                continue
-            menu = TopLinksMenu(context, request, parent, self)
-            adapter = registry.queryMultiAdapter((tool, request), IUserAddingsMenuLabel)
-            if adapter is None:
-                menu.label = request.localizer.translate(content_class.content_name)
-            else:
-                menu.label = adapter.label
-            menu.url = absolute_url(tool, request, 'add-shared-content.html')
-            menu.data = {'data-toggle': 'modal'}
-            self.viewlets.append(menu)
--- a/src/pyams_content/skin/zmi/viewlet/toplinks/templates/user-addings.pt	Thu Nov 08 08:46:58 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-<div class="top-menu" tal:attributes="class view.css_class" i18n:domain="pyams_content">
-	<span class="label" tal:content="view.label | default">Label:</span>
-	<span class="top-selector popover-trigger-element dropdown-toggle btn-success"
-		  data-toggle="dropdown">
-		<i class="fa fa-3x fa-plus-square text-success opaque hint"
-		   data-ams-hint-gravity="w"
-		   title="Create new content" i18n:attributes="title"></i>
-	</span>
-	<ul class="dropdown-menu">
-		<tal:loop repeat="menu view.viewlets">
-			<tal:li replace="structure menu.render()" />
-		</tal:loop>
-	</ul>
-</div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/__init__.py	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+from fanstatic import Library, Resource
+
+
+library = Library('pyams_content', 'resources')
+
+pyams_content_css = Resource(library, 'css/pyams_content.css',
+                             minified='css/pyams_content.min.css')
+
+pyams_content = Resource(library, 'js/pyams_content.js',
+                         minified='js/pyams_content.min.js',
+                         depends=(pyams_content_css,),
+                         bottom=True)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/interfaces.py	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,56 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_skin.interfaces.viewlet import IMenuItem
+
+# import packages
+from zope.interface import Interface, Attribute
+
+
+#
+# Custom menus interfaces
+#
+
+class ISiteTreeMenu(IMenuItem):
+    """Site tree menu marker interface"""
+
+
+class ISiteTreeTable(Interface):
+    """Site tree table view marker interface"""
+
+
+class IDashboardMenu(IMenuItem):
+    """Dashboard menu"""
+
+
+class IMyDashboardMenu(IMenuItem):
+    """My contents dashboard menu"""
+
+
+class IAllContentsMenu(IMenuItem):
+    """Dashboard menu for all contents"""
+
+
+class ISummaryMenu(IMenuItem):
+    """Summary menu"""
+
+
+class IUserAddingsMenuLabel(Interface):
+    """Shared tool adding menu label"""
+
+    label = Attribute("Addings menu label")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/css/pyams_content.css	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,51 @@
+.ams-widget.comments .widget-body {
+  position: fixed;
+  height: calc(100% - 337px);
+}
+.ams-widget.comments .widget-body .chat-body {
+  position: relative;
+  height: 100%;
+}
+.ams-widget.comments .widget-body .chat-footer {
+  position: fixed;
+  bottom: 10px;
+}
+.ams-widget.comments .widget-body,
+.ams-widget.comments .widget-body .chat-footer {
+  width: calc(100% - 240px);
+}
+@media (max-width: 767px) {
+  .ams-widget.comments .widget-body,
+  .ams-widget.comments .widget-body .chat-footer {
+    width: calc(100% - 10px);
+  }
+}
+@media (min-width: 768px) and (max-width: 979px) {
+  .ams-widget.comments .widget-body,
+  .ams-widget.comments .widget-body .chat-footer {
+    width: calc(100% - 20px);
+  }
+}
+.minified .ams-widget.comments .widget-body,
+.minified .ams-widget.comments .widget-body .chat-footer {
+  width: calc(100% - 65px);
+}
+@media (max-width: 767px) {
+  .minified .ams-widget.comments .widget-body,
+  .minified .ams-widget.comments .widget-body .chat-footer {
+    width: calc(100% - 55px);
+  }
+}
+.hidden-menu .ams-widget.comments .widget-body,
+.hidden-menu .ams-widget.comments .widget-body .chat-footer {
+  width: calc(100% - 30px);
+}
+.pictograms-manager .pictogram {
+  border-bottom: 1px solid silver;
+}
+.pictograms-manager .pictogram:last-child {
+  border-bottom: none;
+}
+.sortable.gallery {
+  max-height: 550px;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/css/pyams_content.min.css	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,1 @@
+.ams-widget.comments .widget-body{position:fixed;height:calc(100% - 337px)}.ams-widget.comments .widget-body .chat-body{position:relative;height:100%}.ams-widget.comments .widget-body .chat-footer{position:fixed;bottom:10px}.ams-widget.comments .widget-body,.ams-widget.comments .widget-body .chat-footer{width:calc(100% - 240px)}@media (max-width:767px){.ams-widget.comments .widget-body,.ams-widget.comments .widget-body .chat-footer{width:calc(100% - 10px)}}@media (min-width:768px) and (max-width:979px){.ams-widget.comments .widget-body,.ams-widget.comments .widget-body .chat-footer{width:calc(100% - 20px)}}.minified .ams-widget.comments .widget-body,.minified .ams-widget.comments .widget-body .chat-footer{width:calc(100% - 65px)}@media (max-width:767px){.minified .ams-widget.comments .widget-body,.minified .ams-widget.comments .widget-body .chat-footer{width:calc(100% - 55px)}}.hidden-menu .ams-widget.comments .widget-body,.hidden-menu .ams-widget.comments .widget-body .chat-footer{width:calc(100% - 30px)}.pictograms-manager .pictogram{border-bottom:1px solid silver}.pictograms-manager .pictogram:last-child{border-bottom:none}.sortable.gallery{max-height:550px}
Binary file src/pyams_content/zmi/resources/img/internal-link.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/js/jquery-canvasAreaDraw.js	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,273 @@
+(function ($) {
+
+	$.fn.canvasAreaDraw = function (options) {
+
+		this.each(function (index, element) {
+			init.apply(element, [index, element, options]);
+		});
+
+	}
+
+	var init = function (index, input, options) {
+
+		var points, activePoint, settings;
+		var $reset, $canvas, ctx, image;
+		var draw, mousedown, stopdrag, move, moveall, resize, reset, rightclick, record;
+		var dragpoint;
+		var startpoint = false;
+
+		settings = $.extend({
+								imageUrl: $(this).attr('data-image-url')
+							}, options);
+
+		var v = $(input).val().replace(/[^0-9\,]/ig, '');
+		if (v.length) {
+			points = v.split(',').map(function (point) {
+				return parseInt(point, 10);
+			});
+		} else {
+			points = [];
+		}
+
+		// $reset = $('<button type="button" class="btn"><i class="icon-trash"></i>Очистить</button>');
+		$reset = $('<i class="fa fa-fw fa-trash"></i>');
+		$canvas = $('<canvas>');
+		ctx = $canvas[0].getContext('2d');
+
+		image = new Image();
+		resize = function () {
+			$canvas.attr('height', image.height).attr('width', image.width);
+			draw();
+		};
+		$(image).load(resize);
+		image.src = settings.imageUrl;
+		if (image.loaded) {
+			resize();
+		}
+		$canvas.css({background: 'url(' + image.src + ')'});
+
+		if (input.type !== 'hidden') {
+			$(input).after('<br />');
+		}
+		$(input).after($canvas, '<br />', $reset);
+
+		reset = function () {
+			points = [];
+			draw();
+		};
+
+		move = function (e) {
+			if (!e.offsetX) {
+				e.offsetX = (e.pageX - $(e.target).offset().left);
+				e.offsetY = (e.pageY - $(e.target).offset().top);
+			}
+			points[activePoint] = Math.round(e.offsetX);
+			points[activePoint + 1] = Math.round(e.offsetY);
+			draw();
+		};
+
+		moveall = function (e) {
+			if (!e.offsetX) {
+				e.offsetX = (e.pageX - $(e.target).offset().left);
+				e.offsetY = (e.pageY - $(e.target).offset().top);
+			}
+			if (!startpoint) {
+				startpoint = {x: Math.round(e.offsetX), y: Math.round(e.offsetY)};
+			}
+			var sdvpoint = {x: Math.round(e.offsetX), y: Math.round(e.offsetY)};
+			for (var i = 0; i < points.length; i++) {
+				points[i] = (sdvpoint.x - startpoint.x) + points[i];
+				points[++i] = (sdvpoint.y - startpoint.y) + points[i];
+			}
+			startpoint = sdvpoint;
+			draw();
+		};
+
+		stopdrag = function () {
+			$(this).off('mousemove');
+			record();
+			activePoint = null;
+		};
+
+		rightclick = function (e) {
+			e.preventDefault();
+			if (!e.offsetX) {
+				e.offsetX = (e.pageX - $(e.target).offset().left);
+				e.offsetY = (e.pageY - $(e.target).offset().top);
+			}
+			var x = e.offsetX, y = e.offsetY;
+			for (var i = 0; i < points.length; i += 2) {
+				dis = Math.sqrt(Math.pow(x - points[i], 2) + Math.pow(y - points[i + 1], 2));
+				if (dis < 6) {
+					points.splice(i, 2);
+					draw();
+					record();
+					return false;
+				}
+			}
+			return false;
+		};
+
+		mousedown = function (e) {
+			var x, y, dis, lineDis, insertAt = points.length;
+
+			if (e.which === 3) {
+				return false;
+			}
+
+			e.preventDefault();
+			if (!e.offsetX) {
+				e.offsetX = (e.pageX - $(e.target).offset().left);
+				e.offsetY = (e.pageY - $(e.target).offset().top);
+			}
+			x = e.offsetX;
+			y = e.offsetY;
+
+			if (points.length >= 6) {
+				var c = getCenter();
+				ctx.fillRect(c.x - 4, c.y - 4, 8, 8);
+				dis = Math.sqrt(Math.pow(x - c.x, 2) + Math.pow(y - c.y, 2));
+				if (dis < 6) {
+					startpoint = false;
+					$(this).on('mousemove', moveall);
+					return false;
+				}
+			}
+
+			for (var i = 0; i < points.length; i += 2) {
+				dis = Math.sqrt(Math.pow(x - points[i], 2) + Math.pow(y - points[i + 1], 2));
+				if (dis < 6) {
+					activePoint = i;
+					$(this).on('mousemove', move);
+					return false;
+				}
+			}
+
+			for (var i = 0; i < points.length; i += 2) {
+				if (i > 1) {
+					lineDis = dotLineLength(
+						x, y,
+						points[i], points[i + 1],
+						points[i - 2], points[i - 1],
+						true
+					);
+					if (lineDis < 6) {
+						insertAt = i;
+					}
+				}
+			}
+
+			points.splice(insertAt, 0, Math.round(x), Math.round(y));
+			activePoint = insertAt;
+			$(this).on('mousemove', move);
+
+			draw();
+			record();
+
+			return false;
+		};
+
+		draw = function () {
+			ctx.canvas.width = ctx.canvas.width;
+
+			record();
+			if (points.length < 2) {
+				return;
+			}
+			ctx.globalCompositeOperation = 'destination-over';
+			ctx.fillStyle = 'rgb(255,255,255)';
+			ctx.strokeStyle = 'rgb(255,20,20)';
+			ctx.lineWidth = 1;
+			if (points.length >= 6) {
+				var c = getCenter();
+				ctx.fillRect(c.x - 4, c.y - 4, 8, 8);
+			}
+			ctx.beginPath();
+			ctx.moveTo(points[0], points[1]);
+			for (var i = 0; i < points.length; i += 2) {
+				ctx.fillRect(points[i] - 2, points[i + 1] - 2, 4, 4);
+				ctx.strokeRect(points[i] - 2, points[i + 1] - 2, 4, 4);
+				if (points.length > 2 && i > 1) {
+					ctx.lineTo(points[i], points[i + 1]);
+				}
+			}
+			ctx.closePath();
+			ctx.fillStyle = 'rgba(255,0,0,0.3)';
+			ctx.fill();
+			ctx.stroke();
+
+		};
+
+		record = function () {
+			$(input).val(points.join(','));
+		};
+
+		getCenter = function () {
+			var ptc = [];
+			for (i = 0; i < points.length; i++) {
+				ptc.push({x: points[i], y: points[++i]});
+			}
+			var first = ptc[0], last = ptc[ptc.length - 1];
+			if (first.x != last.x || first.y != last.y) ptc.push(first);
+			var twicearea = 0,
+				x = 0, y = 0,
+				nptc = ptc.length,
+				p1, p2, f;
+			for (var i = 0, j = nptc - 1; i < nptc; j = i++) {
+				p1 = ptc[i];
+				p2 = ptc[j];
+				f = p1.x * p2.y - p2.x * p1.y;
+				twicearea += f;
+				x += ( p1.x + p2.x ) * f;
+				y += ( p1.y + p2.y ) * f;
+			}
+			f = twicearea * 3;
+			return {x: x / f, y: y / f};
+		};
+
+		$(input).on('change', function () {
+			var v = $(input).val().replace(/[^0-9\,]/ig, '');
+			if (v.length) {
+				points = v.split(',').map(function (point) {
+					return parseInt(point, 10);
+				});
+			} else {
+				points = [];
+			}
+			draw();
+		});
+
+		$(document).find($reset).click(reset);
+		$(document).find($canvas).on('mousedown', mousedown);
+		$(document).find($canvas).on('contextmenu', rightclick);
+		$(document).find($canvas).on('mouseup', stopdrag);
+
+	};
+
+	$(document).ready(function () {
+		$('.canvas-area[data-image-url]').canvasAreaDraw();
+	});
+
+	var dotLineLength = function (x, y, x0, y0, x1, y1, o) {
+		function lineLength(x, y, x0, y0) {
+			return Math.sqrt((x -= x0) * x + (y -= y0) * y);
+		}
+
+		if (o && !(o = function (x, y, x0, y0, x1, y1) {
+				if (!(x1 - x0)) return {x: x0, y: y};
+				else if (!(y1 - y0)) return {x: x, y: y0};
+				var left, tg = -1 / ((y1 - y0) / (x1 - x0));
+				return {
+					x: left = (x1 * (x * tg - y + y0) + x0 * (x * -tg + y - y1)) / (tg * (x1 - x0) + y0 - y1),
+					y: tg * left - tg * x + y
+				};
+			}(x, y, x0, y0, x1, y1), o.x >= Math.min(x0, x1) && o.x <= Math.max(x0, x1) && o.y >= Math.min(y0, y1) && o.y <= Math.max(y0, y1))) {
+			var l1 = lineLength(x, y, x0, y0), l2 = lineLength(x, y, x1, y1);
+			return l1 > l2 ? l2 : l1;
+		}
+		else {
+			var a = y0 - y1, b = x1 - x0, c = x0 * y1 - y0 * x1;
+			return Math.abs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
+		}
+	};
+})(jQuery);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/js/jquery-canvasAreaDraw.min.js	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,1 @@
+(function(b){b.fn.canvasAreaDraw=function(d){this.each(function(e,f){c.apply(f,[e,f,d])})};var c=function(i,o,h){var u,g,x;var p,j,s,q;var l,t,m,r,d,z,y,w,f;var e;var k=false;x=b.extend({imageUrl:b(this).attr("data-image-url")},h);var n=b(o).val().replace(/[^0-9\,]/ig,"");if(n.length){u=n.split(",").map(function(v){return parseInt(v,10)})}else{u=[]}p=b('<i class="fa fa-fw fa-trash"></i>');j=b("<canvas>");s=j[0].getContext("2d");q=new Image();z=function(){j.attr("height",q.height).attr("width",q.width);l()};b(q).load(z);q.src=x.imageUrl;if(q.loaded){z()}j.css({background:"url("+q.src+")"});if(o.type!=="hidden"){b(o).after("<br />")}b(o).after(j,"<br />",p);y=function(){u=[];l()};r=function(v){if(!v.offsetX){v.offsetX=(v.pageX-b(v.target).offset().left);v.offsetY=(v.pageY-b(v.target).offset().top)}u[g]=Math.round(v.offsetX);u[g+1]=Math.round(v.offsetY);l()};d=function(B){if(!B.offsetX){B.offsetX=(B.pageX-b(B.target).offset().left);B.offsetY=(B.pageY-b(B.target).offset().top)}if(!k){k={x:Math.round(B.offsetX),y:Math.round(B.offsetY)}}var v={x:Math.round(B.offsetX),y:Math.round(B.offsetY)};for(var A=0;A<u.length;A++){u[A]=(v.x-k.x)+u[A];u[++A]=(v.y-k.y)+u[A]}k=v;l()};m=function(){b(this).off("mousemove");f();g=null};w=function(B){B.preventDefault();if(!B.offsetX){B.offsetX=(B.pageX-b(B.target).offset().left);B.offsetY=(B.pageY-b(B.target).offset().top)}var v=B.offsetX,C=B.offsetY;for(var A=0;A<u.length;A+=2){dis=Math.sqrt(Math.pow(v-u[A],2)+Math.pow(C-u[A+1],2));if(dis<6){u.splice(A,2);l();f();return false}}return false};t=function(E){var v,G,A,D,C=u.length;if(E.which===3){return false}E.preventDefault();if(!E.offsetX){E.offsetX=(E.pageX-b(E.target).offset().left);E.offsetY=(E.pageY-b(E.target).offset().top)}v=E.offsetX;G=E.offsetY;if(u.length>=6){var F=getCenter();s.fillRect(F.x-4,F.y-4,8,8);A=Math.sqrt(Math.pow(v-F.x,2)+Math.pow(G-F.y,2));if(A<6){k=false;b(this).on("mousemove",d);return false}}for(var B=0;B<u.length;B+=2){A=Math.sqrt(Math.pow(v-u[B],2)+Math.pow(G-u[B+1],2));if(A<6){g=B;b(this).on("mousemove",r);return false}}for(var B=0;B<u.length;B+=2){if(B>1){D=a(v,G,u[B],u[B+1],u[B-2],u[B-1],true);if(D<6){C=B}}}u.splice(C,0,Math.round(v),Math.round(G));g=C;b(this).on("mousemove",r);l();f();return false};l=function(){s.canvas.width=s.canvas.width;f();if(u.length<2){return}s.globalCompositeOperation="destination-over";s.fillStyle="rgb(255,255,255)";s.strokeStyle="rgb(255,20,20)";s.lineWidth=1;if(u.length>=6){var A=getCenter();s.fillRect(A.x-4,A.y-4,8,8)}s.beginPath();s.moveTo(u[0],u[1]);for(var v=0;v<u.length;v+=2){s.fillRect(u[v]-2,u[v+1]-2,4,4);s.strokeRect(u[v]-2,u[v+1]-2,4,4);if(u.length>2&&v>1){s.lineTo(u[v],u[v+1])}}s.closePath();s.fillStyle="rgba(255,0,0,0.3)";s.fill();s.stroke()};f=function(){b(o).val(u.join(","))};getCenter=function(){var E=[];for(A=0;A<u.length;A++){E.push({x:u[A],y:u[++A]})}var C=E[0],I=E[E.length-1];if(C.x!=I.x||C.y!=I.y){E.push(C)}var B=0,G=0,F=0,K=E.length,J,H,D;for(var A=0,v=K-1;A<K;v=A++){J=E[A];H=E[v];D=J.x*H.y-H.x*J.y;B+=D;G+=(J.x+H.x)*D;F+=(J.y+H.y)*D}D=B*3;return{x:G/D,y:F/D}};b(o).on("change",function(){var A=b(o).val().replace(/[^0-9\,]/ig,"");if(A.length){u=A.split(",").map(function(v){return parseInt(v,10)})}else{u=[]}l()});b(document).find(p).click(y);b(document).find(j).on("mousedown",t);b(document).find(j).on("contextmenu",w);b(document).find(j).on("mouseup",m)};b(document).ready(function(){b(".canvas-area[data-image-url]").canvasAreaDraw()});var a=function(p,l,g,q,e,n,f){function d(o,t,r,s){return Math.sqrt((o-=r)*o+(t-=s)*t)}if(f&&!(f=function(o,z,s,u,r,t){if(!(r-s)){return{x:s,y:z}}else{if(!(t-u)){return{x:o,y:u}}}var w,v=-1/((t-u)/(r-s));return{x:w=(r*(o*v-z+u)+s*(o*-v+z-t))/(v*(r-s)+u-t),y:v*w-v*o+z}}(p,l,g,q,e,n),f.x>=Math.min(g,e)&&f.x<=Math.max(g,e)&&f.y>=Math.min(q,n)&&f.y<=Math.max(q,n))){var i=d(p,l,g,q),h=d(p,l,e,n);return i>h?h:i}else{var m=q-n,k=e-g,j=g*n-q*e;return Math.abs(m*p+k*l+j)/Math.sqrt(m*m+k*k)}}})(jQuery);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/js/jquery-imagemapster-1.2.10.js	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,4668 @@
+/* ImageMapster
+   Version: 1.2.10 (2/25/2013)
+
+Copyright 2011-2012 James Treworgy
+
+http://www.outsharked.com/imagemapster
+https://github.com/jamietre/ImageMapster
+
+A jQuery plugin to enhance image maps.
+
+*/
+
+;
+
+/// LICENSE (MIT License)
+///
+/// Permission is hereby granted, free of charge, to any person obtaining
+/// a copy of this software and associated documentation files (the
+/// "Software"), to deal in the Software without restriction, including
+/// without limitation the rights to use, copy, modify, merge, publish,
+/// distribute, sublicense, and/or sell copies of the Software, and to
+/// permit persons to whom the Software is furnished to do so, subject to
+/// the following conditions:
+///
+/// The above copyright notice and this permission notice shall be
+/// included in all copies or substantial portions of the Software.
+///
+/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+/// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+/// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+/// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+/// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+/// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+/// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+///
+/// January 19, 2011
+
+/** @license MIT License (c) copyright B Cavalier & J Hann */
+
+/**
+* when
+* A lightweight CommonJS Promises/A and when() implementation
+*
+* when is part of the cujo.js family of libraries (http://cujojs.com/)
+*
+* Licensed under the MIT License at:
+* http://www.opensource.org/licenses/mit-license.php
+*
+* @version 1.2.0
+*/
+
+/*lint-ignore-start*/
+
+(function (define) {
+    define(function () {
+        var freeze, reduceArray, slice, undef;
+
+        //
+        // Public API
+        //
+
+        when.defer = defer;
+        when.reject = reject;
+        when.isPromise = isPromise;
+
+        when.all = all;
+        when.some = some;
+        when.any = any;
+
+        when.map = map;
+        when.reduce = reduce;
+
+        when.chain = chain;
+
+        /** Object.freeze */
+        freeze = Object.freeze || function (o) { return o; };
+
+        /**
+        * Trusted Promise constructor.  A Promise created from this constructor is
+        * a trusted when.js promise.  Any other duck-typed promise is considered
+        * untrusted.
+        *
+        * @constructor
+        */
+        function Promise() { }
+
+        Promise.prototype = freeze({
+            always: function (alwaysback, progback) {
+                return this.then(alwaysback, alwaysback, progback);
+            },
+
+            otherwise: function (errback) {
+                return this.then(undef, errback);
+            }
+        });
+
+        /**
+        * Create an already-resolved promise for the supplied value
+        * @private
+        *
+        * @param value anything
+        * @return {Promise}
+        */
+        function resolved(value) {
+
+            var p = new Promise();
+
+            p.then = function (callback) {
+                var nextValue;
+                try {
+                    if (callback) nextValue = callback(value);
+                    return promise(nextValue === undef ? value : nextValue);
+                } catch (e) {
+                    return rejected(e);
+                }
+            };
+
+            return freeze(p);
+        }
+
+        /**
+        * Create an already-rejected {@link Promise} with the supplied
+        * rejection reason.
+        * @private
+        *
+        * @param reason rejection reason
+        * @return {Promise}
+        */
+        function rejected(reason) {
+
+            var p = new Promise();
+
+            p.then = function (callback, errback) {
+                var nextValue;
+                try {
+                    if (errback) {
+                        nextValue = errback(reason);
+                        return promise(nextValue === undef ? reason : nextValue)
+                    }
+
+                    return rejected(reason);
+
+                } catch (e) {
+                    return rejected(e);
+                }
+            };
+
+            return freeze(p);
+        }
+
+        /**
+        * Returns a rejected promise for the supplied promiseOrValue. If
+        * promiseOrValue is a value, it will be the rejection value of the
+        * returned promise.  If promiseOrValue is a promise, its
+        * completion value will be the rejected value of the returned promise
+        *
+        * @param promiseOrValue {*} the rejected value of the returned {@link Promise}
+        *
+        * @return {Promise} rejected {@link Promise}
+        */
+        function reject(promiseOrValue) {
+            return when(promiseOrValue, function (value) {
+                return rejected(value);
+            });
+        }
+
+        /**
+        * Creates a new, CommonJS compliant, Deferred with fully isolated
+        * resolver and promise parts, either or both of which may be given out
+        * safely to consumers.
+        * The Deferred itself has the full API: resolve, reject, progress, and
+        * then. The resolver has resolve, reject, and progress.  The promise
+        * only has then.
+        *
+        * @memberOf when
+        * @function
+        *
+        * @returns {Deferred}
+        */
+        function defer() {
+            var deferred, promise, listeners, progressHandlers, _then, _progress, complete;
+
+            listeners = [];
+            progressHandlers = [];
+
+            /**
+            * Pre-resolution then() that adds the supplied callback, errback, and progback
+            * functions to the registered listeners
+            *
+            * @private
+            *
+            * @param [callback] {Function} resolution handler
+            * @param [errback] {Function} rejection handler
+            * @param [progback] {Function} progress handler
+            *
+            * @throws {Error} if any argument is not null, undefined, or a Function
+            */
+            _then = function unresolvedThen(callback, errback, progback) {
+                var deferred = defer();
+
+                listeners.push(function (promise) {
+                    promise.then(callback, errback)
+					.then(deferred.resolve, deferred.reject, deferred.progress);
+                });
+
+                progback && progressHandlers.push(progback);
+
+                return deferred.promise;
+            };
+
+            /**
+            * Registers a handler for this {@link Deferred}'s {@link Promise}.  Even though all arguments
+            * are optional, each argument that *is* supplied must be null, undefined, or a Function.
+            * Any other value will cause an Error to be thrown.
+            *
+            * @memberOf Promise
+            *
+            * @param [callback] {Function} resolution handler
+            * @param [errback] {Function} rejection handler
+            * @param [progback] {Function} progress handler
+            *
+            * @throws {Error} if any argument is not null, undefined, or a Function
+            */
+            function then(callback, errback, progback) {
+                return _then(callback, errback, progback);
+            }
+
+            /**
+            * Resolves this {@link Deferred}'s {@link Promise} with val as the
+            * resolution value.
+            *
+            * @memberOf Resolver
+            *
+            * @param val anything
+            */
+            function resolve(val) {
+                complete(resolved(val));
+            }
+
+            /**
+            * Rejects this {@link Deferred}'s {@link Promise} with err as the
+            * reason.
+            *
+            * @memberOf Resolver
+            *
+            * @param err anything
+            */
+            function reject(err) {
+                complete(rejected(err));
+            }
+
+            /**
+            * @private
+            * @param update
+            */
+            _progress = function (update) {
+                var progress, i = 0;
+                while (progress = progressHandlers[i++]) progress(update);
+            };
+
+            /**
+            * Emits a progress update to all progress observers registered with
+            * this {@link Deferred}'s {@link Promise}
+            *
+            * @memberOf Resolver
+            *
+            * @param update anything
+            */
+            function progress(update) {
+                _progress(update);
+            }
+
+            /**
+            * Transition from pre-resolution state to post-resolution state, notifying
+            * all listeners of the resolution or rejection
+            *
+            * @private
+            *
+            * @param completed {Promise} the completed value of this deferred
+            */
+            complete = function (completed) {
+                var listener, i = 0;
+
+                // Replace _then with one that directly notifies with the result.
+                _then = completed.then;
+
+                // Replace complete so that this Deferred can only be completed
+                // once. Also Replace _progress, so that subsequent attempts to issue
+                // progress throw.
+                complete = _progress = function alreadyCompleted() {
+                    // TODO: Consider silently returning here so that parties who
+                    // have a reference to the resolver cannot tell that the promise
+                    // has been resolved using try/catch
+                    throw new Error("already completed");
+                };
+
+                // Free progressHandlers array since we'll never issue progress events
+                // for this promise again now that it's completed
+                progressHandlers = undef;
+
+                // Notify listeners
+                // Traverse all listeners registered directly with this Deferred
+
+                while (listener = listeners[i++]) {
+                    listener(completed);
+                }
+
+                listeners = [];
+            };
+
+            /**
+            * The full Deferred object, with both {@link Promise} and {@link Resolver}
+            * parts
+            * @class Deferred
+            * @name Deferred
+            */
+            deferred = {};
+
+            // Promise and Resolver parts
+            // Freeze Promise and Resolver APIs
+
+            promise = new Promise();
+            promise.then = deferred.then = then;
+
+            /**
+            * The {@link Promise} for this {@link Deferred}
+            * @memberOf Deferred
+            * @name promise
+            * @type {Promise}
+            */
+            deferred.promise = freeze(promise);
+
+            /**
+            * The {@link Resolver} for this {@link Deferred}
+            * @memberOf Deferred
+            * @name resolver
+            * @class Resolver
+            */
+            deferred.resolver = freeze({
+                resolve: (deferred.resolve = resolve),
+                reject: (deferred.reject = reject),
+                progress: (deferred.progress = progress)
+            });
+
+            return deferred;
+        }
+
+        /**
+        * Determines if promiseOrValue is a promise or not.  Uses the feature
+        * test from http://wiki.commonjs.org/wiki/Promises/A to determine if
+        * promiseOrValue is a promise.
+        *
+        * @param promiseOrValue anything
+        *
+        * @returns {Boolean} true if promiseOrValue is a {@link Promise}
+        */
+        function isPromise(promiseOrValue) {
+            return promiseOrValue && typeof promiseOrValue.then === 'function';
+        }
+
+        /**
+        * Register an observer for a promise or immediate value.
+        *
+        * @function
+        * @name when
+        * @namespace
+        *
+        * @param promiseOrValue anything
+        * @param {Function} [callback] callback to be called when promiseOrValue is
+        *   successfully resolved.  If promiseOrValue is an immediate value, callback
+        *   will be invoked immediately.
+        * @param {Function} [errback] callback to be called when promiseOrValue is
+        *   rejected.
+        * @param {Function} [progressHandler] callback to be called when progress updates
+        *   are issued for promiseOrValue.
+        *
+        * @returns {Promise} a new {@link Promise} that will complete with the return
+        *   value of callback or errback or the completion value of promiseOrValue if
+        *   callback and/or errback is not supplied.
+        */
+        function when(promiseOrValue, callback, errback, progressHandler) {
+            // Get a promise for the input promiseOrValue
+            // See promise()
+            var trustedPromise = promise(promiseOrValue);
+
+            // Register promise handlers
+            return trustedPromise.then(callback, errback, progressHandler);
+        }
+
+        /**
+        * Returns promiseOrValue if promiseOrValue is a {@link Promise}, a new Promise if
+        * promiseOrValue is a foreign promise, or a new, already-resolved {@link Promise}
+        * whose resolution value is promiseOrValue if promiseOrValue is an immediate value.
+        *
+        * Note that this function is not safe to export since it will return its
+        * input when promiseOrValue is a {@link Promise}
+        *
+        * @private
+        *
+        * @param promiseOrValue anything
+        *
+        * @returns Guaranteed to return a trusted Promise.  If promiseOrValue is a when.js {@link Promise}
+        *   returns promiseOrValue, otherwise, returns a new, already-resolved, when.js {@link Promise}
+        *   whose resolution value is:
+        *   * the resolution value of promiseOrValue if it's a foreign promise, or
+        *   * promiseOrValue if it's a value
+        */
+        function promise(promiseOrValue) {
+            var promise, deferred;
+
+            if (promiseOrValue instanceof Promise) {
+                // It's a when.js promise, so we trust it
+                promise = promiseOrValue;
+
+            } else {
+                // It's not a when.js promise.  Check to see if it's a foreign promise
+                // or a value.
+
+                deferred = defer();
+                if (isPromise(promiseOrValue)) {
+                    // It's a compliant promise, but we don't know where it came from,
+                    // so we don't trust its implementation entirely.  Introduce a trusted
+                    // middleman when.js promise
+
+                    // IMPORTANT: This is the only place when.js should ever call .then() on
+                    // an untrusted promise.
+                    promiseOrValue.then(deferred.resolve, deferred.reject, deferred.progress);
+                    promise = deferred.promise;
+
+                } else {
+                    // It's a value, not a promise.  Create an already-resolved promise
+                    // for it.
+                    deferred.resolve(promiseOrValue);
+                    promise = deferred.promise;
+                }
+            }
+
+            return promise;
+        }
+
+        /**
+        * Return a promise that will resolve when howMany of the supplied promisesOrValues
+        * have resolved. The resolution value of the returned promise will be an array of
+        * length howMany containing the resolutions values of the triggering promisesOrValues.
+        *
+        * @memberOf when
+        *
+        * @param promisesOrValues {Array} array of anything, may contain a mix
+        *      of {@link Promise}s and values
+        * @param howMany
+        * @param [callback]
+        * @param [errback]
+        * @param [progressHandler]
+        *
+        * @returns {Promise}
+        */
+        function some(promisesOrValues, howMany, callback, errback, progressHandler) {
+
+            checkCallbacks(2, arguments);
+
+            return when(promisesOrValues, function (promisesOrValues) {
+
+                var toResolve, results, ret, deferred, resolver, rejecter, handleProgress, len, i;
+
+                len = promisesOrValues.length >>> 0;
+
+                toResolve = Math.max(0, Math.min(howMany, len));
+                results = [];
+                deferred = defer();
+                ret = when(deferred, callback, errback, progressHandler);
+
+                // Wrapper so that resolver can be replaced
+                function resolve(val) {
+                    resolver(val);
+                }
+
+                // Wrapper so that rejecter can be replaced
+                function reject(err) {
+                    rejecter(err);
+                }
+
+                // Wrapper so that progress can be replaced
+                function progress(update) {
+                    handleProgress(update);
+                }
+
+                function complete() {
+                    resolver = rejecter = handleProgress = noop;
+                }
+
+                // No items in the input, resolve immediately
+                if (!toResolve) {
+                    deferred.resolve(results);
+
+                } else {
+                    // Resolver for promises.  Captures the value and resolves
+                    // the returned promise when toResolve reaches zero.
+                    // Overwrites resolver var with a noop once promise has
+                    // be resolved to cover case where n < promises.length
+                    resolver = function (val) {
+                        // This orders the values based on promise resolution order
+                        // Another strategy would be to use the original position of
+                        // the corresponding promise.
+                        results.push(val);
+
+                        if (! --toResolve) {
+                            complete();
+                            deferred.resolve(results);
+                        }
+                    };
+
+                    // Rejecter for promises.  Rejects returned promise
+                    // immediately, and overwrites rejecter var with a noop
+                    // once promise to cover case where n < promises.length.
+                    // TODO: Consider rejecting only when N (or promises.length - N?)
+                    // promises have been rejected instead of only one?
+                    rejecter = function (err) {
+                        complete();
+                        deferred.reject(err);
+                    };
+
+                    handleProgress = deferred.progress;
+
+                    // TODO: Replace while with forEach
+                    for (i = 0; i < len; ++i) {
+                        if (i in promisesOrValues) {
+                            when(promisesOrValues[i], resolve, reject, progress);
+                        }
+                    }
+                }
+
+                return ret;
+            });
+        }
+
+        /**
+        * Return a promise that will resolve only once all the supplied promisesOrValues
+        * have resolved. The resolution value of the returned promise will be an array
+        * containing the resolution values of each of the promisesOrValues.
+        *
+        * @memberOf when
+        *
+        * @param promisesOrValues {Array|Promise} array of anything, may contain a mix
+        *      of {@link Promise}s and values
+        * @param [callback] {Function}
+        * @param [errback] {Function}
+        * @param [progressHandler] {Function}
+        *
+        * @returns {Promise}
+        */
+        function all(promisesOrValues, callback, errback, progressHandler) {
+
+            checkCallbacks(1, arguments);
+
+            return when(promisesOrValues, function (promisesOrValues) {
+                return _reduce(promisesOrValues, reduceIntoArray, []);
+            }).then(callback, errback, progressHandler);
+        }
+
+        function reduceIntoArray(current, val, i) {
+            current[i] = val;
+            return current;
+        }
+
+        /**
+        * Return a promise that will resolve when any one of the supplied promisesOrValues
+        * has resolved. The resolution value of the returned promise will be the resolution
+        * value of the triggering promiseOrValue.
+        *
+        * @memberOf when
+        *
+        * @param promisesOrValues {Array|Promise} array of anything, may contain a mix
+        *      of {@link Promise}s and values
+        * @param [callback] {Function}
+        * @param [errback] {Function}
+        * @param [progressHandler] {Function}
+        *
+        * @returns {Promise}
+        */
+        function any(promisesOrValues, callback, errback, progressHandler) {
+
+            function unwrapSingleResult(val) {
+                return callback ? callback(val[0]) : val[0];
+            }
+
+            return some(promisesOrValues, 1, unwrapSingleResult, errback, progressHandler);
+        }
+
+        /**
+        * Traditional map function, similar to `Array.prototype.map()`, but allows
+        * input to contain {@link Promise}s and/or values, and mapFunc may return
+        * either a value or a {@link Promise}
+        *
+        * @memberOf when
+        *
+        * @param promise {Array|Promise} array of anything, may contain a mix
+        *      of {@link Promise}s and values
+        * @param mapFunc {Function} mapping function mapFunc(value) which may return
+        *      either a {@link Promise} or value
+        *
+        * @returns {Promise} a {@link Promise} that will resolve to an array containing
+        *      the mapped output values.
+        */
+        function map(promise, mapFunc) {
+            return when(promise, function (array) {
+                return _map(array, mapFunc);
+            });
+        }
+
+        /**
+        * Private map helper to map an array of promises
+        * @private
+        *
+        * @param promisesOrValues {Array}
+        * @param mapFunc {Function}
+        * @return {Promise}
+        */
+        function _map(promisesOrValues, mapFunc) {
+
+            var results, len, i;
+
+            // Since we know the resulting length, we can preallocate the results
+            // array to avoid array expansions.
+            len = promisesOrValues.length >>> 0;
+            results = new Array(len);
+
+            // Since mapFunc may be async, get all invocations of it into flight
+            // asap, and then use reduce() to collect all the results
+            for (i = 0; i < len; i++) {
+                if (i in promisesOrValues)
+                    results[i] = when(promisesOrValues[i], mapFunc);
+            }
+
+            // Could use all() here, but that would result in another array
+            // being allocated, i.e. map() would end up allocating 2 arrays
+            // of size len instead of just 1.  Since all() uses reduce()
+            // anyway, avoid the additional allocation by calling reduce
+            // directly.
+            return _reduce(results, reduceIntoArray, results);
+        }
+
+        /**
+        * Traditional reduce function, similar to `Array.prototype.reduce()`, but
+        * input may contain {@link Promise}s and/or values, and reduceFunc
+        * may return either a value or a {@link Promise}, *and* initialValue may
+        * be a {@link Promise} for the starting value.
+        *
+        * @memberOf when
+        *
+        * @param promise {Array|Promise} array of anything, may contain a mix
+        *      of {@link Promise}s and values.  May also be a {@link Promise} for
+        *      an array.
+        * @param reduceFunc {Function} reduce function reduce(currentValue, nextValue, index, total),
+        *      where total is the total number of items being reduced, and will be the same
+        *      in each call to reduceFunc.
+        * @param initialValue starting value, or a {@link Promise} for the starting value
+        *
+        * @returns {Promise} that will resolve to the final reduced value
+        */
+        function reduce(promise, reduceFunc, initialValue) {
+            var args = slice.call(arguments, 1);
+            return when(promise, function (array) {
+                return _reduce.apply(undef, [array].concat(args));
+            });
+        }
+
+        /**
+        * Private reduce to reduce an array of promises
+        * @private
+        *
+        * @param promisesOrValues {Array}
+        * @param reduceFunc {Function}
+        * @param initialValue {*}
+        * @return {Promise}
+        */
+        function _reduce(promisesOrValues, reduceFunc, initialValue) {
+
+            var total, args;
+
+            total = promisesOrValues.length;
+
+            // Skip promisesOrValues, since it will be used as 'this' in the call
+            // to the actual reduce engine below.
+
+            // Wrap the supplied reduceFunc with one that handles promises and then
+            // delegates to the supplied.
+
+            args = [
+			function (current, val, i) {
+			    return when(current, function (c) {
+			        return when(val, function (value) {
+			            return reduceFunc(c, value, i, total);
+			        });
+			    });
+			}
+		];
+
+            if (arguments.length > 2) args.push(initialValue);
+
+            return reduceArray.apply(promisesOrValues, args);
+        }
+
+        /**
+        * Ensure that resolution of promiseOrValue will complete resolver with the completion
+        * value of promiseOrValue, or instead with resolveValue if it is provided.
+        *
+        * @memberOf when
+        *
+        * @param promiseOrValue
+        * @param resolver {Resolver}
+        * @param [resolveValue] anything
+        *
+        * @returns {Promise}
+        */
+        function chain(promiseOrValue, resolver, resolveValue) {
+            var useResolveValue = arguments.length > 2;
+
+            return when(promiseOrValue,
+			function (val) {
+			    if (useResolveValue) val = resolveValue;
+			    resolver.resolve(val);
+			    return val;
+			},
+			function (e) {
+			    resolver.reject(e);
+			    return rejected(e);
+			},
+			resolver.progress
+		);
+        }
+
+        //
+        // Utility functions
+        //
+
+        /**
+        * Helper that checks arrayOfCallbacks to ensure that each element is either
+        * a function, or null or undefined.
+        *
+        * @private
+        *
+        * @param arrayOfCallbacks {Array} array to check
+        * @throws {Error} if any element of arrayOfCallbacks is something other than
+        * a Functions, null, or undefined.
+        */
+        function checkCallbacks(start, arrayOfCallbacks) {
+            var arg, i = arrayOfCallbacks.length;
+            while (i > start) {
+                arg = arrayOfCallbacks[--i];
+                if (arg != null && typeof arg != 'function') throw new Error('callback is not a function');
+            }
+        }
+
+        /**
+        * No-Op function used in method replacement
+        * @private
+        */
+        function noop() { }
+
+        slice = [].slice;
+
+        // ES5 reduce implementation if native not available
+        // See: http://es5.github.com/#x15.4.4.21 as there are many
+        // specifics and edge cases.
+        reduceArray = [].reduce ||
+		function (reduceFunc /*, initialValue */) {
+		    // ES5 dictates that reduce.length === 1
+
+		    // This implementation deviates from ES5 spec in the following ways:
+		    // 1. It does not check if reduceFunc is a Callable
+
+		    var arr, args, reduced, len, i;
+
+		    i = 0;
+		    arr = Object(this);
+		    len = arr.length >>> 0;
+		    args = arguments;
+
+		    // If no initialValue, use first item of array (we know length !== 0 here)
+		    // and adjust i to start at second item
+		    if (args.length <= 1) {
+		        // Skip to the first real element in the array
+		        for (; ; ) {
+		            if (i in arr) {
+		                reduced = arr[i++];
+		                break;
+		            }
+
+		            // If we reached the end of the array without finding any real
+		            // elements, it's a TypeError
+		            if (++i >= len) {
+		                throw new TypeError();
+		            }
+		        }
+		    } else {
+		        // If initialValue provided, use it
+		        reduced = args[1];
+		    }
+
+		    // Do the actual reduce
+		    for (; i < len; ++i) {
+		        // Skip holes
+		        if (i in arr)
+		            reduced = reduceFunc(reduced, arr[i], i, arr);
+		    }
+
+		    return reduced;
+		};
+
+        return when;
+    });
+})(typeof define == 'function'
+	? define
+	: function (factory) {
+	    typeof module != 'undefined'
+		? (module.exports = factory())
+		: (jQuery.mapster_when = factory());
+	}
+// Boilerplate for AMD, Node, and browser global
+);
+/*lint-ignore-end*/
+/* ImageMapster core */
+
+/*jslint laxbreak: true, evil: true, unparam: true */
+
+/*global jQuery: true, Zepto: true */
+
+
+(function ($) {
+    // all public functions in $.mapster.impl are methods
+    $.fn.mapster = function (method) {
+        var m = $.mapster.impl;
+        if ($.isFunction(m[method])) {
+            return m[method].apply(this, Array.prototype.slice.call(arguments, 1));
+        } else if (typeof method === 'object' || !method) {
+            return m.bind.apply(this, arguments);
+        } else {
+            $.error('Method ' + method + ' does not exist on jQuery.mapster');
+        }
+    };
+
+    $.mapster = {
+        version: "1.2.10",
+        render_defaults: {
+            isSelectable: true,
+            isDeselectable: true,
+            fade: false,
+            fadeDuration: 150,
+            fill: true,
+            fillColor: '000000',
+            fillColorMask: 'FFFFFF',
+            fillOpacity: 0.7,
+            highlight: true,
+            stroke: false,
+            strokeColor: 'ff0000',
+            strokeOpacity: 1,
+            strokeWidth: 1,
+            includeKeys: '',
+            altImage: null,
+            altImageId: null, // used internally            
+            altImages: {} 
+        },
+        defaults: {
+            clickNavigate: false,
+            wrapClass: null,
+            wrapCss: null,
+            onGetList: null,
+            sortList: false,
+            listenToList: false,
+            mapKey: '',
+            mapValue: '',
+            singleSelect: false,
+            listKey: 'value',
+            listSelectedAttribute: 'selected',
+            listSelectedClass: null,
+            onClick: null,
+            onMouseover: null,
+            onMouseout: null,
+            mouseoutDelay: 0,
+            onStateChange: null,
+            boundList: null,
+            onConfigured: null,
+            configTimeout: 30000,
+            noHrefIsMask: true,
+            scaleMap: true,
+            safeLoad: false,
+            areas: []
+        },
+        shared_defaults: {
+            render_highlight: { fade: true },
+            render_select: { fade: false },
+            staticState: null,
+            selected: null
+        },
+        area_defaults:
+        {
+            includeKeys: '',
+            isMask: false
+        },
+        canvas_style: {
+            position: 'absolute',
+            left: 0,
+            top: 0,
+            padding: 0,
+            border: 0
+        },
+        hasCanvas: null,
+        isTouch: null,
+        map_cache: [],
+        hooks: {},
+        addHook: function(name,callback) {
+            this.hooks[name]=(this.hooks[name]||[]).push(callback);
+        },
+        callHooks: function(name,context) {
+            $.each(this.hooks[name]||[],function(i,e) {
+                e.apply(context);
+            });
+        },
+        utils: {
+            when: $.mapster_when,
+            defer: $.mapster_when.defer,
+
+            // extends the constructor, returns a new object prototype. Does not refer to the
+            // original constructor so is protected if the original object is altered. This way you
+            // can "extend" an object by replacing it with its subclass.
+            subclass: function(BaseClass, constr) {
+                var Subclass=function() {
+                    var me=this, 
+                        args=Array.prototype.slice.call(arguments,0);
+                    me.base = BaseClass.prototype;
+                    me.base.init = function() {
+                        BaseClass.prototype.constructor.apply(me,args);
+                    };
+                    constr.apply(me,args);
+                };
+                Subclass.prototype = new BaseClass();
+                Subclass.prototype.constructor=Subclass;
+                return Subclass;
+            },
+            asArray: function (obj) {
+                return obj.constructor === Array ?
+                    obj : this.split(obj);
+            },
+            // clean split: no padding or empty elements
+            split: function (text,cb) {
+                var i,el, arr = text.split(',');
+                for (i = 0; i < arr.length; i++) {
+                    el = $.trim(arr[i]);
+                    if (el==='') {
+                        arr.splice(i,1);
+                    } else {
+                        arr[i] = cb ? cb(el):el;
+                    }
+                }
+                return arr;
+            },
+            // similar to $.extend but does not add properties (only updates), unless the
+            // first argument is an empty object, then all properties will be copied
+            updateProps: function (_target, _template) {
+                var onlyProps,
+                    target = _target || {},
+                    template = $.isEmptyObject(target) ? _template : _target;
+
+                //if (template) {
+                onlyProps = [];
+                $.each(template, function (prop) {
+                    onlyProps.push(prop);
+                });
+                //}
+
+                $.each(Array.prototype.slice.call(arguments, 1), function (i, src) {
+                    $.each(src || {}, function (prop) {
+                        if (!onlyProps || $.inArray(prop, onlyProps) >= 0) {
+                            var p = src[prop];
+
+                            if ($.isPlainObject(p)) {
+                                // not recursive - only copies 1 level of subobjects, and always merges
+                                target[prop] = $.extend(target[prop] || {}, p);
+                            } else if (p && p.constructor === Array) {
+                                target[prop] = p.slice(0);
+                            } else if (typeof p !== 'undefined') {
+                                target[prop] = src[prop];
+                            }
+
+                        }
+                    });
+                });
+                return target;
+            },
+            isElement: function (o) {
+                return (typeof HTMLElement === "object" ? o instanceof HTMLElement :
+                        o && typeof o === "object" && o.nodeType === 1 && typeof o.nodeName === "string");
+            },
+            // finds element of array or object with a property "prop" having value "val"
+            // if prop is not defined, then just looks for property with value "val"
+            indexOfProp: function (obj, prop, val) {
+                var result = obj.constructor === Array ? -1 : null;
+                $.each(obj, function (i, e) {
+                    if (e && (prop ? e[prop] : e) === val) {
+                        result = i;
+                        return false;
+                    }
+                });
+                return result;
+            },
+            // returns "obj" if true or false, or "def" if not true/false
+            boolOrDefault: function (obj, def) {
+                return this.isBool(obj) ?
+                        obj : def || false;
+            },
+            isBool: function (obj) {
+                return typeof obj === "boolean";
+            },
+            isUndef: function(obj) {
+                return typeof obj === "undefined";
+            },
+            // evaluates "obj", if function, calls it with args
+            // (todo - update this to handle variable lenght/more than one arg)
+            ifFunction: function (obj, that, args) {
+                if ($.isFunction(obj)) {
+                    obj.call(that, args);
+                }
+            },
+            size: function(image, raw) {
+                var u=$.mapster.utils;
+                return { 
+                    width: raw ? (image.width || image.naturalWidth) : u.imgWidth(image,true) ,
+                    height: raw ? (image.height || image.naturalHeight) : u.imgHeight(image,true),
+                    complete: function() { return !!this.height && !!this.width;}
+                };
+            },
+
+                
+            /**
+             * Set the opacity of the element. This is an IE<8 specific function for handling VML.
+             * When using VML we must override the "setOpacity" utility function (monkey patch ourselves).
+             * jQuery does not deal with opacity correctly for VML elements. This deals with that.
+             * 
+             * @param {Element} el The DOM element
+             * @param {double} opacity A value between 0 and 1 inclusive.
+             */
+
+            setOpacity: function (el, opacity) {
+                if ($.mapster.hasCanvas()) {
+                    el.style.opacity = opacity;
+                } else {
+                    $(el).each(function(i,e) {
+                        if (typeof e.opacity !=='undefined') {
+                           e.opacity=opacity;
+                        } else {
+                            $(e).css("opacity",opacity);
+                        }
+                    });
+                }
+            },
+
+
+            // fade "el" from opacity "op" to "endOp" over a period of time "duration"
+            
+            fader: (function () {
+                var elements = {},
+                        lastKey = 0,
+                        fade_func = function (el, op, endOp, duration) {
+                            var index, 
+                                cbIntervals = duration/15,
+                                obj, u = $.mapster.utils;
+
+                            if (typeof el === 'number') {
+                                obj = elements[el];
+                                if (!obj) {
+                                    return;
+                                }
+                            } else {
+                                index = u.indexOfProp(elements, null, el);
+                                if (index) {
+                                    delete elements[index];
+                                }
+                                elements[++lastKey] = obj = el;
+                                el = lastKey;
+                            }
+
+                            endOp = endOp || 1;
+
+                            op = (op + (endOp / cbIntervals) > endOp - 0.01) ? endOp : op + (endOp / cbIntervals);
+
+                            u.setOpacity(obj, op);
+                            if (op < endOp) {
+                                setTimeout(function () {
+                                    fade_func(el, op, endOp, duration);
+                                }, 15);
+                            }
+                        };
+                return fade_func;
+            } ())
+        },
+        getBoundList: function (opts, key_list) {
+            if (!opts.boundList) {
+                return null;
+            }
+            var index, key, result = $(), list = $.mapster.utils.split(key_list);
+            opts.boundList.each(function (i,e) {
+                for (index = 0; index < list.length; index++) {
+                    key = list[index];
+                    if ($(e).is('[' + opts.listKey + '="' + key + '"]')) {
+                        result = result.add(e);
+                    }
+                }
+            });
+            return result;
+        },
+        // Causes changes to the bound list based on the user action (select or deselect)
+        // area: the jQuery area object
+        // returns the matching elements from the bound list for the first area passed (normally only one should be passed, but
+        // a list can be passed
+        setBoundListProperties: function (opts, target, selected) {
+            target.each(function (i,e) {
+                if (opts.listSelectedClass) {
+                    if (selected) {
+                        $(e).addClass(opts.listSelectedClass);
+                    } else {
+                        $(e).removeClass(opts.listSelectedClass);
+                    }
+                }
+                if (opts.listSelectedAttribute) {
+                    $(e).attr(opts.listSelectedAttribute, selected);
+                }
+            });
+        },
+        getMapDataIndex: function (obj) {
+            var img, id;
+            switch (obj.tagName && obj.tagName.toLowerCase()) {
+                case 'area':
+                    id = $(obj).parent().attr('name');
+                    img = $("img[usemap='#" + id + "']")[0];
+                    break;
+                case 'img':
+                    img = obj;
+                    break;
+            }
+            return img ?
+                this.utils.indexOfProp(this.map_cache, 'image', img) : -1;
+        },
+        getMapData: function (obj) {
+            var index = this.getMapDataIndex(obj.length ? obj[0]:obj);
+            if (index >= 0) {
+                return index >= 0 ? this.map_cache[index] : null;
+            }
+        },
+        /**
+         * Queue a command to be run after the active async operation has finished
+         * @param  {MapData}  map_data    The target MapData object
+         * @param  {jQuery}   that        jQuery object on which the command was invoked
+         * @param  {string}   command     the ImageMapster method name
+         * @param  {object[]} args        arguments passed to the method
+         * @return {bool}                 true if the command was queued, false if not (e.g. there was no need to)
+         */
+        queueCommand: function (map_data, that, command, args) {
+            if (!map_data) {
+                return false;
+            }
+            if (!map_data.complete || map_data.currentAction) {
+                map_data.commands.push(
+                {
+                    that: that,
+                    command: command,
+                    args: args
+                });
+                return true;
+            }
+            return false;
+        },
+        unload: function () {
+            this.impl.unload();
+            this.utils = null;
+            this.impl = null;
+            $.fn.mapster = null;
+            $.mapster = null;
+            $('*').unbind();
+        }
+    };
+
+    // Config for object prototypes
+    // first: use only first object (for things that should not apply to lists)
+    /// calls back one of two fuinctions, depending on whether an area was obtained.
+    // opts: {
+    //    name: 'method name',
+    //    key: 'key,
+    //    args: 'args'
+    //
+    //}
+    // name: name of method (required)
+    // args: arguments to re-call with
+    // Iterates through all the objects passed, and determines whether it's an area or an image, and calls the appropriate
+    // callback for each. If anything is returned from that callback, the process is stopped and that data return. Otherwise,
+    // the object itself is returned.
+    
+    var m = $.mapster, 
+        u = m.utils,
+        ap = Array.prototype;
+
+
+    // jQuery's width() and height() are broken on IE9 in some situations. This tries everything. 
+    $.each(["width","height"],function(i,e) {
+        var capProp = e.substr(0,1).toUpperCase() + e.substr(1);
+        // when jqwidth parm is passed, it also checks the jQuery width()/height() property
+        // the issue is that jQUery width() can report a valid size before the image is loaded in some browsers
+        // without it, we can read zero even when image is loaded in other browsers if its not visible
+        // we must still check because stuff like adblock can temporarily block it
+        // what a goddamn headache
+        u["img"+capProp]=function(img,jqwidth) {
+                return (jqwidth ? $(img)[e]() : 0) || 
+                    img[e] || img["natural"+capProp] || img["client"+capProp] || img["offset"+capProp];
+        };
+     
+    });    
+
+    /**
+     * The Method object encapsulates the process of testing an ImageMapster method to see if it's being
+     * invoked on an image, or an area; then queues the command if the MapData is in an active state.
+     * 
+     * @param {[jQuery]}    that        The target of the invocation
+     * @param {[function]}  func_map    The callback if the target is an imagemap
+     * @param {[function]}  func_area   The callback if the target is an area
+     * @param {[object]}    opt         Options: { key: a map key if passed explicitly
+     *                                             name: the command name, if it can be queued,
+     *                                             args: arguments to the method
+     *                                            }
+     */
+    
+    m.Method = function (that, func_map, func_area, opts) {
+        var me = this;
+        me.name = opts.name;
+        me.output = that;
+        me.input = that;
+        me.first = opts.first || false;
+        me.args = opts.args ? ap.slice.call(opts.args, 0) : [];
+        me.key = opts.key;
+        me.func_map = func_map;
+        me.func_area = func_area;
+        //$.extend(me, opts);
+        me.name = opts.name;
+        me.allowAsync = opts.allowAsync || false;
+    };
+    m.Method.prototype = {
+        constructor: m.Method,
+        go: function () {
+            var i,  data, ar, len, result, src = this.input,
+                    area_list = [],
+                    me = this;
+
+            len = src.length;
+            for (i = 0; i < len; i++) {
+                data = $.mapster.getMapData(src[i]);
+                if (data) {
+                    if (!me.allowAsync && m.queueCommand(data, me.input, me.name, me.args)) {
+                        if (this.first) {
+                            result = '';
+                        }
+                        continue;
+                    }
+                    
+                    ar = data.getData(src[i].nodeName === 'AREA' ? src[i] : this.key);
+                    if (ar) {
+                        if ($.inArray(ar, area_list) < 0) {
+                            area_list.push(ar);
+                        }
+                    } else {
+                        result = this.func_map.apply(data, me.args);
+                    }
+                    if (this.first || typeof result !== 'undefined') {
+                        break;
+                    }
+                }
+            }
+            // if there were areas, call the area function for each unique group
+            $(area_list).each(function (i,e) {
+                result = me.func_area.apply(e, me.args);
+            });
+
+            if (typeof result !== 'undefined') {
+                return result;
+            } else {
+                return this.output;
+            }
+        }
+    };
+
+    $.mapster.impl = (function () {
+        var me = {},
+        addMap= function (map_data) {
+            return m.map_cache.push(map_data) - 1;
+        },
+        removeMap = function (map_data) {
+            m.map_cache.splice(map_data.index, 1);
+            for (var i = m.map_cache.length - 1; i >= this.index; i--) {
+                m.map_cache[i].index--;
+            }
+        };
+
+        
+        /**
+         * Test whether the browser supports VML. Credit: google.
+         * http://stackoverflow.com/questions/654112/how-do-you-detect-support-for-vml-or-svg-in-a-browser
+         * 
+         * @return {bool} true if vml is supported, false if not
+         */
+        
+        function hasVml() {
+            var a = $('<div />').appendTo('body');
+            a.html('<v:shape id="vml_flag1" adj="1" />');
+            
+            var b = a[0].firstChild;
+            b.style.behavior = "url(#default#VML)";
+            var has = b ? typeof b.adj === "object" : true;
+            a.remove();
+            return has;
+        }
+
+        /**
+         * Return a reference to the IE namespaces object, if available, or an empty object otherwise
+         * @return {obkect} The document.namespaces object.
+         */
+        function namespaces() {
+            return typeof(document.namespaces)==='object' ?
+                document.namespaces :
+                null;
+        }
+
+        /**
+         * Test for the presence of HTML5 Canvas support. This also checks to see if excanvas.js has been 
+         * loaded and is faking it; if so, we assume that canvas is not supported.
+         *
+         * @return {bool} true if HTML5 canvas support, false if not
+         */
+        
+        function hasCanvas() {
+            var d = namespaces();
+            // when g_vml_ is present, then we can be sure excanvas is active, meaning there's not a real canvas.
+            
+             return d && d.g_vml_ ? 
+                false :
+                $('<canvas />')[0].getContext ? 
+                    true : 
+                    false;
+        }
+
+        /**
+         * Merge new area data into existing area options on a MapData object. Used for rebinding.
+         * 
+         * @param  {[MapData]} map_data     The MapData object
+         * @param  {[object[]]} areas       areas array to merge
+         */
+        
+        function merge_areas(map_data, areas) {
+            var ar, index,
+                map_areas = map_data.options.areas;
+
+            if (areas) {
+                $.each(areas, function (i, e) {
+                    
+                    // Issue #68 - ignore invalid data in areas array
+                    
+                    if (!e || !e.key) { 
+                        return;
+                    }
+
+                    index = u.indexOfProp(map_areas, "key", e.key);
+
+                    if (index >= 0) {
+                        $.extend(map_areas[index], e);
+                    }
+                    else {
+                        map_areas.push(e);
+                    }
+                    ar = map_data.getDataForKey(e.key);
+                    if (ar) {
+                        $.extend(ar.options, e);
+                    }
+                });
+            }
+        }
+        function merge_options(map_data, options) {
+            var temp_opts = u.updateProps({}, options);
+            delete temp_opts.areas;
+
+            u.updateProps(map_data.options, temp_opts);
+
+            merge_areas(map_data, options.areas);
+            // refresh the area_option template
+            u.updateProps(map_data.area_options, map_data.options);
+        }
+
+        // Most methods use the "Method" object which handles figuring out whether it's an image or area called and
+        // parsing key parameters. The constructor wants:
+        // this, the jQuery object
+        // a function that is called when an image was passed (with a this context of the MapData)
+        // a function that is called when an area was passed (with a this context of the AreaData)
+        // options: first = true means only the first member of a jQuery object is handled
+        //          key = the key parameters passed
+        //          defaultReturn: a value to return other than the jQuery object (if its not chainable)
+        //          args: the arguments
+        // Returns a comma-separated list of user-selected areas. "staticState" areas are not considered selected for the purposes of this method.
+        
+        me.get = function (key) {
+            var md = m.getMapData(this);
+            if (!(md && md.complete)) {
+                throw("Can't access data until binding complete.");
+            }
+
+            return (new m.Method(this,
+                function () {
+                    // map_data return
+                    return this.getSelected();
+                },
+                function () {
+                    return this.isSelected();
+                },
+                { name: 'get',
+                    args: arguments,
+                    key: key,
+                    first: true,
+                    allowAsync: true,
+                    defaultReturn: ''
+                }
+            )).go();
+        };
+        me.data = function (key) {
+            return (new m.Method(this,
+                null,
+                function () {
+                    return this;
+                },
+                { name: 'data',
+                    args: arguments,
+                    key: key
+                }
+            )).go();
+        };
+
+
+        // Set or return highlight state.
+        //  $(img).mapster('highlight') -- return highlighted area key, or null if none
+        //  $(area).mapster('highlight') -- highlight an area
+        //  $(img).mapster('highlight','area_key') -- highlight an area
+        //  $(img).mapster('highlight',false) -- remove highlight
+        me.highlight = function (key) {
+            return (new m.Method(this,
+                function () {
+                    if (key === false) {
+                        this.ensureNoHighlight();
+                    } else {
+                        var id = this.highlightId;
+                        return id >= 0 ? this.data[id].key : null;
+                    }
+                },
+                function () {
+                    this.highlight();
+                },
+                { name: 'highlight',
+                    args: arguments,
+                    key: key,
+                    first: true
+                }
+            )).go();
+        };
+        // Return the primary keys for an area or group key.
+        // $(area).mapster('key')
+        // includes all keys (not just primary keys)
+        // $(area).mapster('key',true)
+        // $(img).mapster('key','group-key')
+
+        // $(img).mapster('key','group-key', true)
+        me.keys = function(key,all) {
+            var keyList=[], 
+                md = m.getMapData(this);
+
+            if (!(md && md.complete)) {
+                throw("Can't access data until binding complete.");
+            }
+
+
+            function addUniqueKeys(ad) {
+                var areas,keys=[];
+                if (!all) {
+                    keys.push(ad.key);
+                } else {
+                    areas=ad.areas();
+                    $.each(areas,function(i,e) {
+                        keys=keys.concat(e.keys);
+                    });
+                }
+                $.each(keys,function(i,e) {
+                    if ($.inArray(e,keyList)<0) {
+                        keyList.push(e);                         
+                    }
+                });
+            }
+
+            if (!(md  && md.complete)) {
+                return '';
+            }
+            if (typeof key === 'string') {
+                if (all) {
+                    addUniqueKeys(md.getDataForKey(key));
+                } else {
+                    keyList=[md.getKeysForGroup(key)];
+                }
+            } else {
+                all = key;
+                this.each(function(i,e) {
+                    if (e.nodeName==='AREA') {
+                        addUniqueKeys(md.getDataForArea(e));
+                    }
+                });
+            }
+            return keyList.join(',');
+        
+
+        };
+        me.select = function () {
+            me.set.call(this, true);
+        };
+        me.deselect = function () {
+            me.set.call(this, false);
+        };
+        
+        /**
+         * Select or unselect areas. Areas can be identified by a single string key, a comma-separated list of keys, 
+         * or an array of strings.
+         * 
+         * 
+         * @param {boolean} selected Determines whether areas are selected or deselected
+         * @param {string|string[]} key A string, comma-separated string, or array of strings indicating 
+         *                              the areas to select or deselect
+         * @param {object} options Rendering options to apply when selecting an area
+         */ 
+
+        me.set = function (selected, key, options) {
+            var lastMap, map_data, opts=options,
+                key_list, area_list; // array of unique areas passed
+
+            function setSelection(ar) {
+                if (ar) {
+                    switch (selected) {
+                        case true:
+                            ar.select(opts); break;
+                        case false:
+                            ar.deselect(true); break;
+                        default:
+                            ar.toggle(opts); break;
+                    }
+                }
+            }
+            function addArea(ar) {
+               if (ar && $.inArray(ar, area_list) < 0) {
+                    area_list.push(ar);
+                    key_list+=(key_list===''?'':',')+ar.key;
+                }
+            }
+            // Clean up after a group that applied to the same map
+            function finishSetForMap(map_data) {
+                $.each(area_list, function (i, el) {
+                    setSelection(el);
+                });
+                if (!selected) {
+                    map_data.removeSelectionFinish();
+                }
+                if (map_data.options.boundList) {
+                    m.setBoundListProperties(map_data.options, m.getBoundList(map_data.options, key_list), selected);
+                }            
+            }
+
+            this.filter('img,area').each(function (i,e) {
+                var keys;
+                map_data = m.getMapData(e);
+
+                if (map_data !== lastMap) {
+                    if (lastMap) {
+                       finishSetForMap(lastMap);
+                    }
+
+                    area_list = [];
+                    key_list='';
+                }
+                
+               if (map_data) {
+                    
+                    keys = '';
+                    if (e.nodeName.toUpperCase()==='IMG') {
+                        if (!m.queueCommand(map_data, $(e), 'set', [selected, key, opts])) {
+                            if (key instanceof Array) {
+                                if (key.length) {
+                                    keys = key.join(",");
+                                }
+                            }
+                            else {
+                                keys = key;
+                            }
+
+                            if (keys) {
+                                $.each(u.split(keys), function (i,key) {
+                                    addArea(map_data.getDataForKey(key.toString()));
+                                    lastMap = map_data;
+                                });
+                            }
+                        }
+                    } else {
+                        opts=key;
+                        if (!m.queueCommand(map_data, $(e), 'set', [selected, opts])) {
+                            addArea(map_data.getDataForArea(e));
+                            lastMap = map_data;
+                        }
+                    
+                    }
+                }
+            });
+            
+            if (map_data) {
+               finishSetForMap(map_data);
+            }
+
+           
+            return this;
+        };
+        me.unbind = function (preserveState) {
+            return (new m.Method(this,
+                function () {
+                    this.clearEvents();
+                    this.clearMapData(preserveState);
+                    removeMap(this);
+                },
+                null,
+                { name: 'unbind',
+                    args: arguments
+                }
+            )).go();
+        };
+
+
+        // refresh options and update selection information.
+        me.rebind = function (options) {
+            return (new m.Method(this,
+                function () {
+                    var me=this;
+
+                    me.complete=false;
+                    me.configureOptions(options);
+                    me.bindImages().then(function() {
+                        me.buildDataset(true);
+                        me.complete=true;
+                    });
+                    //this.redrawSelections();
+                },
+                null,
+                {
+                    name: 'rebind',
+                    args: arguments
+                }
+            )).go();
+        };
+        // get options. nothing or false to get, or "true" to get effective options (versus passed options)
+        me.get_options = function (key, effective) {
+            var eff = u.isBool(key) ? key : effective; // allow 2nd parm as "effective" when no key
+            return (new m.Method(this,
+                function () {
+                    var opts = $.extend({}, this.options);
+                    if (eff) {
+                        opts.render_select = u.updateProps(
+                            {},
+                            m.render_defaults,
+                            opts,
+                            opts.render_select);
+
+                        opts.render_highlight = u.updateProps(
+                            {},
+                            m.render_defaults,
+                            opts,
+                            opts.render_highlight);
+                    }
+                    return opts;
+                },
+                function () {
+                    return eff ? this.effectiveOptions() : this.options;
+                },
+                {
+                    name: 'get_options',
+                    args: arguments,
+                    first: true,
+                    allowAsync: true,
+                    key: key
+                }
+            )).go();
+        };
+
+        // set options - pass an object with options to set,
+        me.set_options = function (options) {
+            return (new m.Method(this,
+                function () {
+                    merge_options(this, options);
+                },
+                null,
+                {
+                    name: 'set_options',
+                    args: arguments
+                }
+            )).go();
+        };
+        me.unload = function () {
+            var i;
+            for (i = m.map_cache.length - 1; i >= 0; i--) {
+                if (m.map_cache[i]) {
+                    me.unbind.call($(m.map_cache[i].image));
+                }
+            }
+            me.graphics = null;
+        };
+
+        me.snapshot = function () {
+            return (new m.Method(this,
+                function () {
+                    $.each(this.data, function (i, e) {
+                        e.selected = false;
+                    });
+
+                    this.base_canvas = this.graphics.createVisibleCanvas(this);
+                    $(this.image).before(this.base_canvas);
+                },
+                null,
+                { name: 'snapshot' }
+            )).go();
+        };
+        
+        // do not queue this function
+        
+        me.state = function () {
+            var md, result = null;
+            $(this).each(function (i,e) {
+                if (e.nodeName === 'IMG') {
+                    md = m.getMapData(e);
+                    if (md) {
+                        result = md.state();
+                    }
+                    return false;
+                }
+            });
+            return result;
+        };
+
+        me.bind = function (options) {
+
+            return this.each(function (i,e) {
+                var img, map, usemap, md;
+
+                // save ref to this image even if we can't access it yet. commands will be queued
+                img = $(e);
+
+                md = m.getMapData(e);
+
+                // if already bound completely, do a total rebind
+                
+                if (md) {
+                    me.unbind.apply(img);
+                    if (!md.complete) {
+                        // will be queued
+                        img.bind();
+                        return true;
+                    }
+                    md = null;
+                }
+
+                // ensure it's a valid image
+                // jQuery bug with Opera, results in full-url#usemap being returned from jQuery's attr.
+                // So use raw getAttribute instead.
+                
+                usemap = this.getAttribute('usemap');
+                map = usemap && $('map[name="' + usemap.substr(1) + '"]');
+                if (!(img.is('img') && usemap && map.size() > 0)) {
+                    return true;
+                }
+
+                // sorry - your image must have border:0, things are too unpredictable otherwise.
+                img.css('border', 0);
+
+                if (!md) {
+                    md = new m.MapData(this, options);
+
+                    md.index = addMap(md);
+                    md.map = map;
+                    md.bindImages().then(function() {
+                        md.initialize();
+                    });
+                }
+            });
+        };
+
+        me.init = function (useCanvas) {
+            var style, shapes;
+
+            // for testing/debugging, use of canvas can be forced by initializing 
+            // manually with "true" or "false". But generally we test for it.
+            
+            m.hasCanvas = function() {
+                if (!u.isBool(m.hasCanvas.value)) {
+                    m.hasCanvas.value = u.isBool(useCanvas) ?
+                        useCanvas : 
+                        hasCanvas();
+                }
+                return m.hasCanvas.value;
+            };
+            m.hasVml = function() {
+                if (!u.isBool(m.hasVml.value)) {
+                    // initialize VML the first time we detect its presence.
+                    var d = namespaces();
+
+                    if (d && !d.v) {
+                        d.add("v", "urn:schemas-microsoft-com:vml");
+                        style = document.createStyleSheet();
+                        shapes = ['shape', 'rect', 'oval', 'circ', 'fill', 'stroke', 'imagedata', 'group', 'textbox'];
+                        $.each(shapes,
+                        function (i, el) {
+                            style.addRule('v\\:' + el, "behavior: url(#default#VML); antialias:true");
+                        });
+                    }
+                    m.hasVml.value = hasVml();
+                }
+
+                return m.hasVml.value;
+            };
+
+            m.isTouch = !!document.documentElement.ontouchstart;
+
+            $.extend(m.defaults, m.render_defaults,m.shared_defaults);
+            $.extend(m.area_defaults, m.render_defaults,m.shared_defaults);
+            
+        };
+        me.test = function (obj) {
+            return eval(obj);
+        };
+        return me;
+    } ());
+    
+    $.mapster.impl.init();
+    
+    
+} (jQuery));
+/* graphics.js
+   Graphics object handles all rendering.
+*/
+(function ($) {
+    var p, m=$.mapster,
+        u=m.utils,
+        canvasMethods,
+        vmlMethods;
+    
+    /**
+     * Implemenation to add each area in an AreaData object to the canvas
+     * @param {Graphics} graphics The target graphics object
+     * @param {AreaData} areaData The AreaData object (a collection of area elements and metadata)
+     * @param {object} options Rendering options to apply when rendering this group of areas
+     */
+    function addShapeGroupImpl(graphics, areaData, options) {
+        var me = graphics,
+            md = me.map_data,
+            isMask = options.isMask;
+
+        // first get area options. Then override fade for selecting, and finally merge in the 
+        // "select" effect options.
+
+        $.each(areaData.areas(), function (i,e) {
+            options.isMask = isMask || (e.nohref && md.options.noHrefIsMask);
+            me.addShape(e, options);
+        });
+
+        // it's faster just to manipulate the passed options isMask property and restore it, than to 
+        // copy the object each time
+        
+        options.isMask=isMask;
+
+    }
+
+     /**
+     * Convert a hex value to decimal
+     * @param  {string} hex A hexadecimal toString
+     * @return {int} Integer represenation of the hex string
+     */
+
+    function hex_to_decimal(hex) {
+        return Math.max(0, Math.min(parseInt(hex, 16), 255));
+    }
+    function css3color(color, opacity) {
+        return 'rgba(' + hex_to_decimal(color.substr(0, 2)) + ','
+                + hex_to_decimal(color.substr(2, 2)) + ','
+                + hex_to_decimal(color.substr(4, 2)) + ',' + opacity + ')';
+    }
+    /**
+     * An object associated with a particular map_data instance to manage renderin.
+     * @param {MapData} map_data The MapData object bound to this instance
+     */
+    
+    m.Graphics = function (map_data) {
+        //$(window).unload($.mapster.unload);
+        // create graphics functions for canvas and vml browsers. usage:
+        // 1) init with map_data, 2) call begin with canvas to be used (these are separate b/c may not require canvas to be specified
+        // 3) call add_shape_to for each shape or mask, 4) call render() to finish
+
+        var me = this;
+        me.active = false;
+        me.canvas = null;
+        me.width = 0;
+        me.height = 0;
+        me.shapes = [];
+        me.masks = [];
+        me.map_data = map_data;
+    };
+    
+    p = m.Graphics.prototype= {
+        constructor: m.Graphics,
+
+        /**
+         * Initiate a graphics request for a canvas
+         * @param  {Element} canvas The canvas element that is the target of this operation
+         * @param  {string} [elementName] The name to assign to the element (VML only)
+         */
+        
+        begin: function(canvas, elementName) {
+            var c = $(canvas);
+
+            this.elementName = elementName;
+            this.canvas = canvas;
+
+            this.width = c.width();
+            this.height = c.height();
+            this.shapes = [];
+            this.masks = [];
+            this.active = true;
+
+        },
+        
+        /**
+         * Add an area to be rendered to this canvas. 
+         * @param {MapArea} mapArea The MapArea object to render
+         * @param {object} options An object containing any rendering options that should override the
+         *                         defaults for the area
+         */
+        
+        addShape: function(mapArea, options) {
+            var addto = options.isMask ? this.masks : this.shapes;
+            addto.push({ mapArea: mapArea, options: options });
+        },
+
+        /**
+         * Create a canvas that is sized and styled for the MapData object
+         * @param  {MapData} mapData The MapData object that will receive this new canvas
+         * @return {Element} A canvas element
+         */
+        
+        createVisibleCanvas: function (mapData) {
+            return $(this.createCanvasFor(mapData))
+                .addClass('mapster_el')
+                .css(m.canvas_style)[0];
+        },
+
+        /**
+         * Add a group of shapes from an AreaData object to the canvas
+         * 
+         * @param {AreaData} areaData An AreaData object (a set of area elements)
+         * @param {string} mode     The rendering mode, "select" or "highlight". This determines the target 
+         *                          canvas and which default options to use.
+         * @param {striong} options  Rendering options
+         */
+        
+        addShapeGroup: function (areaData, mode,options) {
+            // render includeKeys first - because they could be masks
+            var me = this,
+                list, name, canvas,
+                map_data = this.map_data,
+                opts = areaData.effectiveRenderOptions(mode);
+
+            if (options) {
+                 $.extend(opts,options);
+            }
+
+            if (mode === 'select') {
+                name = "static_" + areaData.areaId.toString();
+                canvas = map_data.base_canvas;
+            } else {
+                canvas = map_data.overlay_canvas;
+            }
+
+            me.begin(canvas, name);
+
+            if (opts.includeKeys) {
+                list = u.split(opts.includeKeys);
+                $.each(list, function (i,e) {
+                    var areaData = map_data.getDataForKey(e.toString());
+                    addShapeGroupImpl(me,areaData, areaData.effectiveRenderOptions(mode));
+                });
+            }
+
+            addShapeGroupImpl(me,areaData, opts);
+            me.render();
+            if (opts.fade) {
+                
+                // fading requires special handling for IE. We must access the fill elements directly. The fader also has to deal with 
+                // the "opacity" attribute (not css)
+
+                u.fader(m.hasCanvas() ? 
+                    canvas : 
+                    $(canvas).find('._fill').not('.mapster_mask'),
+                0,
+                m.hasCanvas() ? 
+                    1 : 
+                    opts.fillOpacity,
+                opts.fadeDuration); 
+               
+            }
+
+        }
+
+        // These prototype methods are implementation dependent
+    };
+
+    function noop() {}
+
+  
+    // configure remaining prototype methods for ie or canvas-supporting browser
+
+    canvasMethods = {
+        renderShape: function (context, mapArea, offset) {
+            var i,
+                c = mapArea.coords(null,offset);
+
+            switch (mapArea.shape) {
+                case 'rect':
+                    context.rect(c[0], c[1], c[2] - c[0], c[3] - c[1]);
+                    break;
+                case 'poly':
+                    context.moveTo(c[0], c[1]);
+
+                    for (i = 2; i < mapArea.length; i += 2) {
+                        context.lineTo(c[i], c[i + 1]);
+                    }
+                    context.lineTo(c[0], c[1]);
+                    break;
+                case 'circ':
+                case 'circle':
+                    context.arc(c[0], c[1], c[2], 0, Math.PI * 2, false);
+                    break;
+            }
+        },
+        addAltImage: function (context, image, mapArea, options) {
+            context.beginPath();
+
+            this.renderShape(context, mapArea);
+            context.closePath();
+            context.clip();
+
+            context.globalAlpha = options.altImageOpacity || options.fillOpacity;
+
+            context.drawImage(image, 0, 0, mapArea.owner.scaleInfo.width, mapArea.owner.scaleInfo.height);
+        },
+        render: function () {
+            // firefox 6.0 context.save() seems to be broken. to work around,  we have to draw the contents on one temp canvas,
+            // the mask on another, and merge everything. ugh. fixed in 1.2.2. unfortunately this is a lot more code for masks,
+            // but no other way around it that i can see.
+
+            var maskCanvas, maskContext,
+                        me = this,
+                        md = me.map_data,
+                        hasMasks = me.masks.length,
+                        shapeCanvas = me.createCanvasFor(md),
+                        shapeContext = shapeCanvas.getContext('2d'),
+                        context = me.canvas.getContext('2d');
+
+            if (hasMasks) {
+                maskCanvas = me.createCanvasFor(md);
+                maskContext = maskCanvas.getContext('2d');
+                maskContext.clearRect(0, 0, maskCanvas.width, maskCanvas.height);
+
+                $.each(me.masks, function (i,e) {
+                    maskContext.save();
+                    maskContext.beginPath();
+                    me.renderShape(maskContext, e.mapArea);
+                    maskContext.closePath();
+                    maskContext.clip();
+                    maskContext.lineWidth = 0;
+                    maskContext.fillStyle = '#000';
+                    maskContext.fill();
+                    maskContext.restore();
+                });
+
+            }
+
+            $.each(me.shapes, function (i,s) {
+                shapeContext.save();
+                if (s.options.fill) {
+                    if (s.options.altImageId) {
+                        me.addAltImage(shapeContext, md.images[s.options.altImageId], s.mapArea, s.options);
+                    } else {
+                        shapeContext.beginPath();
+                        me.renderShape(shapeContext, s.mapArea);
+                        shapeContext.closePath();
+                        //shapeContext.clip();
+                        shapeContext.fillStyle = css3color(s.options.fillColor, s.options.fillOpacity);
+                        shapeContext.fill();
+                    }
+                }
+                shapeContext.restore();
+            });
+
+
+            // render strokes at end since masks get stroked too
+
+            $.each(me.shapes.concat(me.masks), function (i,s) {
+                var offset = s.options.strokeWidth === 1 ? 0.5 : 0;
+                // offset applies only when stroke width is 1 and stroke would render between pixels.
+
+                if (s.options.stroke) {
+                    shapeContext.save();
+                    shapeContext.strokeStyle = css3color(s.options.strokeColor, s.options.strokeOpacity);
+                    shapeContext.lineWidth = s.options.strokeWidth;
+
+                    shapeContext.beginPath();
+
+                    me.renderShape(shapeContext, s.mapArea, offset);
+                    shapeContext.closePath();
+                    shapeContext.stroke();
+                    shapeContext.restore();
+                }
+            });
+
+            if (hasMasks) {
+                // render the new shapes against the mask
+
+                maskContext.globalCompositeOperation = "source-out";
+                maskContext.drawImage(shapeCanvas, 0, 0);
+
+                // flatten into the main canvas
+                context.drawImage(maskCanvas, 0, 0);
+            } else {
+                context.drawImage(shapeCanvas, 0, 0);
+            }
+
+            me.active = false;
+            return me.canvas;
+        },
+
+        // create a canvas mimicing dimensions of an existing element
+        createCanvasFor: function (md) {
+            return $('<canvas width="' + md.scaleInfo.width + '" height="' +md.scaleInfo.height + '"></canvas>')[0];
+        },
+        clearHighlight: function () {
+            var c = this.map_data.overlay_canvas;
+            c.getContext('2d').clearRect(0, 0, c.width, c.height);
+        },
+        // Draw all items from selected_list to a new canvas, then swap with the old one. This is used to delete items when using canvases.
+        refreshSelections: function () {
+            var canvas_temp, map_data = this.map_data;
+            // draw new base canvas, then swap with the old one to avoid flickering
+            canvas_temp = map_data.base_canvas;
+
+            map_data.base_canvas = this.createVisibleCanvas(map_data);
+            $(map_data.base_canvas).hide();
+            $(canvas_temp).before(map_data.base_canvas);
+
+            map_data.redrawSelections();
+
+            $(map_data.base_canvas).show();
+            $(canvas_temp).remove();
+        }
+    };
+
+    vmlMethods = {
+
+        renderShape: function (mapArea, options, cssclass) {
+            var me = this, fill,stroke, e, t_fill, el_name, el_class, template, c = mapArea.coords();
+            el_name = me.elementName ? 'name="' + me.elementName + '" ' : '';
+            el_class = cssclass ? 'class="' + cssclass + '" ' : '';
+
+            t_fill = '<v:fill color="#' + options.fillColor + '" class="_fill" opacity="' + 
+                (options.fill ? 
+                    options.fillOpacity :
+                    0) + 
+                '" /><v:stroke class="_fill" opacity="' + 
+                options.strokeOpacity + '"/>';
+
+
+            stroke = options.stroke ?
+                ' strokeweight=' + options.strokeWidth + ' stroked="t" strokecolor="#' + 
+                    options.strokeColor + '"' :
+                ' stroked="f"';
+            
+            fill = options.fill ? 
+                ' filled="t"' :
+                ' filled="f"';
+
+            switch (mapArea.shape) {
+                case 'rect':
+                    template = '<v:rect ' + el_class + el_name + fill + stroke + 
+                        ' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + 
+                          c[0] + 'px;top:' + c[1]  + 'px;width:' + (c[2] - c[0]) + 
+                          'px;height:' + (c[3] - c[1]) + 'px;">' + t_fill + '</v:rect>';
+                    break;
+                case 'poly':
+                    template = '<v:shape ' + el_class + el_name + fill + stroke + ' coordorigin="0,0" coordsize="' + me.width + ',' + me.height
+                                + '" path="m ' + c[0] + ',' + c[1] + ' l ' + c.slice(2).join(',')
+                                + ' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:' + me.width + 'px;height:' + me.height + 'px;">' + t_fill + '</v:shape>';
+                    break;
+                case 'circ':
+                case 'circle':
+                    template = '<v:oval ' + el_class + el_name + fill + stroke
+                                + ' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + (c[0] - c[2]) + 'px;top:' + (c[1] - c[2])
+                                + 'px;width:' + (c[2] * 2) + 'px;height:' + (c[2] * 2) + 'px;">' + t_fill + '</v:oval>';
+                    break;
+            }
+            e = $(template);
+            $(me.canvas).append(e);
+
+            return e;
+        },
+        render: function () {
+            var opts, me = this;
+
+            $.each(this.shapes, function (i,e) {
+                me.renderShape(e.mapArea, e.options);
+            });
+
+            if (this.masks.length) {
+                $.each(this.masks, function (i,e) {
+                    opts = u.updateProps({},
+                        e.options, {
+                            fillOpacity: 1,
+                            fillColor: e.options.fillColorMask
+                        });
+                    me.renderShape(e.mapArea, opts, 'mapster_mask');
+                });
+            }
+
+            this.active = false;
+            return this.canvas;
+        },
+
+        createCanvasFor: function (md) {
+            var w = md.scaleInfo.width,
+                h = md.scaleInfo.height;
+            return $('<var width="' + w + '" height="' + h 
+                + '" style="zoom:1;overflow:hidden;display:block;width:' 
+                + w + 'px;height:' + h + 'px;"></var>')[0];
+        },
+
+        clearHighlight: function () {
+            $(this.map_data.overlay_canvas).children().remove();
+        },
+        // remove single or all selections
+        removeSelections: function (area_id) {
+            if (area_id >= 0) {
+                $(this.map_data.base_canvas).find('[name="static_' + area_id.toString() + '"]').remove();
+            }
+            else {
+                $(this.map_data.base_canvas).children().remove();
+            }
+        }
+
+    };
+
+    // for all methods with two implemenatations, add a function that will automatically replace itself with the correct
+    // method on first invocation
+    
+    $.each(['renderShape',
+           'addAltImage',
+           'render',
+           'createCanvasFor',
+           'clearHighlight',
+           'removeSelections',
+           'refreshSelections'],
+        function(i,e) {
+            p[e]=(function(method) {
+                return function() {
+                    p[method] = (m.hasCanvas() ?
+                        canvasMethods[method] : 
+                        vmlMethods[method]) || noop;
+                  
+                    return p[method].apply(this,arguments);
+                };
+            }(e));
+    });
+
+
+} (jQuery));
+/* mapimage.js
+   the MapImage object, repesents an instance of a single bound imagemap
+*/
+
+(function ($) {
+
+    var m = $.mapster, 
+        u = m.utils,
+        ap=[];
+    /**
+     * An object encapsulating all the images used by a MapData.
+     */
+    
+    m.MapImages = function(owner) {
+        this.owner = owner;
+        this.clear();
+    };
+
+    
+    m.MapImages.prototype = {
+        constructor: m.MapImages,
+
+        /* interface to make this array-like */
+
+        slice: function() {
+            return ap.slice.apply(this,arguments);
+        },
+        splice: function() {
+            ap.slice.apply(this.status,arguments);
+            var result= ap.slice.apply(this,arguments);
+            return result;
+        },
+     
+        /** 
+         * a boolean value indicates whether all images are done loading 
+         * @return {bool} true when all are done
+         */
+        complete: function() {
+            return $.inArray(false, this.status) < 0;
+        },
+        
+        /**
+         * Save an image in the images array and return its index 
+         * @param  {Image} image An Image object
+         * @return {int} the index of the image
+         */
+        
+        _add: function(image) {
+            var index = ap.push.call(this,image)-1;
+            this.status[index] = false;
+            return index;
+        },
+
+        /**
+         * Return the index of an Image within the images array
+         * @param  {Image} img An Image
+         * @return {int} the index within the array, or -1 if it was not found
+         */
+        
+        indexOf: function(image) {
+            return $.inArray(image, this);
+        },
+        
+        /**
+         * Clear this object and reset it to its initial state after binding.
+         */
+        
+        clear: function() {
+            var me=this;
+
+            if (me.ids && me.ids.length>0) {
+                $.each(me.ids,function(i,e) {
+                    delete me[e];
+                });
+            }
+            
+            /**
+             * A list of the cross-reference IDs bound to this object
+             * @type {string[]}
+             */
+            
+            me.ids=[];
+
+            /**
+             * Length property for array-like behavior, set to zero when initializing. Array prototype
+             * methods will update it after that.
+             * 
+             * @type {int}
+             */
+            
+            me.length=0;
+
+            /**
+             * the loaded status of the corresponding image
+             * @type {boolean[]}
+             */
+            
+            me.status=[];
+            
+            
+            // actually erase the images
+            
+            me.splice(0);
+            
+        },
+
+        /**
+         * Bind an image to the map and add it to the queue to be loaded; return an ID that
+         * can be used to reference the
+         * 
+         * @param {Image|string} image An Image object or a URL to an image
+         * @param {string} [id] An id to refer to this image
+         * @returns {int} an ID referencing the index of the image object in 
+         *                map_data.images
+         */
+     
+        add: function(image,id) {
+            var index,src,me = this;
+
+            if (!image) { return; }
+
+            if (typeof image === 'string') {
+                src = image;
+                image = me[src];
+                if (typeof image==='object') {
+                    return me.indexOf(image);
+                }
+
+                image = $('<img />')
+                    .addClass('mapster_el')
+                    .hide();
+
+                index=me._add(image[0]);
+                
+                image
+                    .bind('load',function(e) {
+                        me.imageLoaded.call(me,e);
+                    })
+                    .bind('error',function(e) {
+                        me.imageLoadError.call(me,e);
+                    });
+                
+                image.attr('src', src);
+            } else {
+
+                // use attr because we want the actual source, not the resolved path the browser will return directly calling image.src
+                
+                index=me._add($(image)[0]);
+            }
+            if (id) {
+                if (this[id]) {
+                    throw(id+" is already used or is not available as an altImage alias.");
+                }
+                me.ids.push(id);
+                me[id]=me[index];
+            }
+            return index;
+        },
+
+        /**
+         * Bind the images in this object, 
+         * @param  {boolean} retry when true, indicates that the function is calling itself after failure 
+         * @return {Promise} a promise that resolves when the images have finished loading
+         */
+        
+        bind: function(retry) {
+            var me = this,
+                promise,
+                triesLeft = me.owner.options.configTimeout / 200,
+
+            /* A recursive function to continue checking that the images have been 
+               loaded until a timeout has elapsed */
+
+            check=function() {
+                var i;
+
+                // refresh status of images
+                
+                i=me.length;
+
+                while (i-->0) {
+                    if (!me.isLoaded(i)) {
+                        break;
+                    }
+                }
+
+                // check to see if every image has already been loaded
+                
+                if (me.complete()) {
+                    me.resolve();
+                } else {
+                    // to account for failure of onLoad to fire in rare situations
+                    if (triesLeft-- > 0) {
+                        me.imgTimeout=window.setTimeout(function() {
+                            check.call(me,true);
+                        }, 50);
+                    } else {
+                        me.imageLoadError.call(me);
+                    }
+                }
+            
+            };
+
+            promise = me.deferred=u.defer();
+            
+            check();
+            return promise;
+        },
+   
+        resolve: function() {
+            var me=this,
+                resolver=me.deferred;
+                
+            if (resolver) {
+                // Make a copy of the resolver before calling & removing it to ensure
+                // it is not called twice
+                me.deferred=null;
+                resolver.resolve();
+            }
+        },
+
+        /**
+         * Event handler for image onload
+         * @param  {object} e jQuery event data
+         */
+        
+        imageLoaded: function(e) {
+            var me=this,
+                index = me.indexOf(e.target);
+
+            if (index>=0) {
+
+                me.status[index] = true;
+                if ($.inArray(false, me.status) < 0) {
+                    me.resolve();
+                }
+            }
+        },
+        
+        /**
+         * Event handler for onload error
+         * @param  {object} e jQuery event data
+         */
+        
+        imageLoadError: function(e) {
+            clearTimeout(this.imgTimeout);
+            this.triesLeft=0;
+            var err = e ? 'The image ' + e.target.src + ' failed to load.' : 
+                'The images never seemed to finish loading. You may just need to increase the configTimeout if images could take a long time to load.';
+            throw err;
+        },
+        /**
+         * Test if the image at specificed index has finished loading
+         * @param  {int}  index The image index
+         * @return {boolean} true if loaded, false if not
+         */
+        
+        isLoaded: function(index) {
+            var img,
+                me=this,
+                status=me.status;
+
+            if (status[index]) { return true; }
+            img = me[index];
+            
+            if (typeof img.complete !== 'undefined') {
+                status[index]=img.complete;
+            } else {
+                status[index]=!!u.imgWidth(img);
+            }
+            // if complete passes, the image is loaded, but may STILL not be available because of stuff like adblock.
+            // make sure it is.
+
+            return status[index];
+        }
+    };
+    } (jQuery));
+/* mapdata.js
+   the MapData object, repesents an instance of a single bound imagemap
+*/
+
+
+(function ($) {
+
+    var m = $.mapster, 
+        u = m.utils;
+   
+    /**
+     * Set default values for MapData object properties
+     * @param  {MapData} me The MapData object
+     */
+    
+    function initializeDefaults(me) {
+        $.extend(me,{
+            complete: false,         // (bool)    when configuration is complete       
+            map: null,                // ($)      the image map
+            base_canvas: null,       // (canvas|var)  where selections are rendered
+            overlay_canvas: null,    // (canvas|var)  where highlights are rendered
+            commands: [],            // {}        commands that were run before configuration was completed (b/c images weren't loaded)
+            data: [],                // MapData[] area groups
+            mapAreas: [],            // MapArea[] list. AreaData entities contain refs to this array, so options are stored with each.
+            _xref: {},               // (int)      xref of mapKeys to data[]
+            highlightId: -1,        // (int)      the currently highlighted element.
+            currentAreaId: -1,
+            _tooltip_events: [],     // {}         info on events we bound to a tooltip container, so we can properly unbind them
+            scaleInfo: null,         // {}         info about the image size, scaling, defaults
+            index: -1,                 // index of this in map_cache - so we have an ID to use for wraper div
+            activeAreaEvent: null
+        });
+    }
+
+    /**
+     * Return an array of all image-containing options from an options object; 
+     * that is, containers that may have an "altImage" property
+     * 
+     * @param  {object} obj     An options object
+     * @return {object[]}       An array of objects
+     */
+    function getOptionImages(obj) {
+        return [obj, obj.render_highlight, obj.render_select];
+    }
+
+    /**
+     * Parse all the altImage references, adding them to the library so they can be preloaded
+     * and aliased.
+     * 
+     * @param  {MapData} me The MapData object on which to operate
+     */
+    function configureAltImages(me)
+    {
+        var opts = me.options,
+            mi = me.images;
+
+        // add alt images
+        
+        if (m.hasCanvas()) {
+            // map altImage library first
+            
+            $.each(opts.altImages || {}, function(i,e) {
+                mi.add(e,i);
+            });
+            
+            // now find everything else
+
+            $.each([opts].concat(opts.areas),function(i,e) {
+                $.each(getOptionImages(e),function(i2,e2) {
+                    if (e2 && e2.altImage) {
+                        e2.altImageId=mi.add(e2.altImage);
+                    }
+                });
+            });
+        }
+
+        // set area_options
+        me.area_options = u.updateProps({}, // default options for any MapArea
+            m.area_defaults,
+            opts);
+    }
+
+    /**
+     * Queue a mouse move action based on current delay settings 
+     * (helper for mouseover/mouseout handlers)
+     * 
+     * @param  {MapData}    me       The MapData context
+     * @param  {number}     delay    The number of milliseconds to delay the action
+     * @param  {AreaData}   area     AreaData affected
+     * @param  {Deferred}   deferred A deferred object to return (instead of a new one)
+     * @return {Promise}    A promise that resolves when the action is completed
+     */
+    function queueMouseEvent(me,delay,area, deferred) {
+        
+        deferred = deferred || u.when.defer();
+
+        function cbFinal(areaId) {
+            if (me.currentAreaId!==areaId && me.highlightId>=0) {
+                deferred.resolve();
+            }
+        }
+        if (me.activeAreaEvent) {
+            window.clearTimeout(me.activeAreaEvent);
+            me.activeAreaEvent=0;
+        }
+        if (delay<0) {
+            return;
+        }
+
+        if (area.owner.currentAction || delay) {
+            me.activeAreaEvent = window.setTimeout((function() {
+                    return function() {
+                        queueMouseEvent(me,0,area,deferred);
+                    };
+                }(area)),
+                delay || 100);
+        } else {
+             cbFinal(area.areaId);
+        }
+        return deferred;
+    }
+
+     /**
+     * Mousedown event. This is captured only to prevent browser from drawing an outline around an
+     * area when it's clicked.
+     *
+     * @param  {EventData} e jQuery event data
+     */
+    
+    function mousedown(e) {
+        if (!m.hasCanvas()) {
+            this.blur();
+        }
+        e.preventDefault();
+    }
+
+    /**
+     * Mouseover event. Handle highlight rendering and client callback on mouseover
+     * 
+     * @param  {MapData} me The MapData context
+     * @param  {EventData} e jQuery event data
+     * @return {[type]}   [description]
+     */
+    
+    function mouseover(me,e) {
+        var arData = me.getAllDataForArea(this),
+            ar=arData.length ? arData[0] : null;
+
+        // mouseover events are ignored entirely while resizing, though we do care about mouseout events
+        // and must queue the action to keep things clean.
+
+        if (!ar || ar.isNotRendered() || ar.owner.currentAction) {
+            return;
+        }
+
+        if (me.currentAreaId === ar.areaId) {
+            return;
+        }
+        if (me.highlightId !== ar.areaId) {
+            me.clearEffects();
+
+            ar.highlight();
+
+            if (me.options.showToolTip) {
+                $.each(arData,function(i,e) {
+                    if (e.effectiveOptions().toolTip) {
+                        e.showToolTip();
+                    }
+                });
+            }
+        }
+
+        me.currentAreaId = ar.areaId;
+
+        if ($.isFunction(me.options.onMouseover)) {
+            me.options.onMouseover.call(this,
+            {
+                e: e,
+                options:ar.effectiveOptions(),
+                key: ar.key,
+                selected: ar.isSelected()
+            });
+        }
+    }
+
+    /**
+     * Mouseout event.
+     *
+     * @param  {MapData} me The MapData context
+     * @param  {EventData} e jQuery event data
+     * @return {[type]}   [description]
+     */
+    
+    function mouseout(me,e) {
+        var newArea,
+            ar = me.getDataForArea(this),
+            opts = me.options;
+
+
+        if (me.currentAreaId<0 || !ar) {
+            return;
+        }
+
+        newArea=me.getDataForArea(e.relatedTarget);
+        
+        if (newArea === ar) {
+            return;
+        }
+
+        me.currentAreaId = -1;
+        ar.area=null;
+
+        queueMouseEvent(me,opts.mouseoutDelay,ar)
+            .then(me.clearEffects);
+
+        if ($.isFunction(opts.onMouseout)) {
+            opts.onMouseout.call(this,
+            {
+                e: e,
+                options: opts,
+                key: ar.key,
+                selected: ar.isSelected()
+            });
+        }
+
+    }
+    
+    /**
+     * Clear any active tooltip or highlight
+     *
+     * @param  {MapData} me The MapData context
+     * @param  {EventData} e jQuery event data
+     * @return {[type]}   [description]
+     */
+    
+    function clearEffects(me) {
+        var opts = me.options;
+
+        me.ensureNoHighlight();
+
+        if (opts.toolTipClose 
+            && $.inArray('area-mouseout', opts.toolTipClose) >= 0 
+            && me.activeToolTip) 
+        {
+            me.clearToolTip();
+        }
+    }
+
+    /**
+     * Mouse click event handler
+     *
+     * @param  {MapData} me The MapData context
+     * @param  {EventData} e jQuery event data
+     * @return {[type]}   [description]
+     */
+    
+    function click(me,e) {
+        var selected, list, list_target, newSelectionState, canChangeState, cbResult,
+            that = this,
+            ar = me.getDataForArea(this),
+            opts = me.options;
+
+        function clickArea(ar) {
+            var areaOpts,target;
+            canChangeState = (ar.isSelectable() &&
+                (ar.isDeselectable() || !ar.isSelected()));
+            
+            if (canChangeState) {
+                newSelectionState = !ar.isSelected();
+            } else {
+                newSelectionState = ar.isSelected();
+            }
+
+            list_target = m.getBoundList(opts, ar.key);
+
+            if ($.isFunction(opts.onClick)) 
+            {
+                cbResult= opts.onClick.call(that,
+                {
+                    e: e,
+                    listTarget: list_target,
+                    key: ar.key,
+                    selected: newSelectionState
+                });
+
+                if (u.isBool(cbResult)) {
+                    if (!cbResult) {
+                        return false;
+                    }
+                    target = $(ar.area).attr('href');
+                    if (target!=='#') {
+                        window.location.href=target;
+                        return false;
+                    }
+                }
+            }
+
+            if (canChangeState) {
+                selected = ar.toggle();
+            }
+
+            if (opts.boundList && opts.boundList.length > 0) {
+                m.setBoundListProperties(opts, list_target, ar.isSelected());
+            }
+
+            areaOpts = ar.effectiveOptions();
+            if (areaOpts.includeKeys) {
+                list = u.split(areaOpts.includeKeys);
+                $.each(list, function (i, e) {
+                    var ar = me.getDataForKey(e.toString());
+                    if (!ar.options.isMask) {
+                        clickArea(ar);
+                    }
+                });
+            }
+        }
+
+        mousedown.call(this,e);
+
+        if (opts.clickNavigate && ar.href) {
+            window.location.href=ar.href;
+            return;
+        }
+
+        if (ar && !ar.owner.currentAction) {
+            opts = me.options;
+            clickArea(ar);
+        }
+    }
+
+    /**
+     * Prototype for a MapData object, representing an ImageMapster bound object
+     * @param {Element} image   an IMG element
+     * @param {object} options  ImageMapster binding options
+     */
+    m.MapData = function (image, options) 
+    {
+        var me = this;
+        
+        // (Image)  main map image
+        
+        me.image = image;              
+
+        me.images = new m.MapImages(me); 
+        me.graphics = new m.Graphics(me);
+
+        // save the initial style of the image for unbinding. This is problematic, chrome 
+        // duplicates styles when assigning, and cssText is apparently not universally supported.
+        // Need to do something more robust to make unbinding work universally.
+        
+        me.imgCssText = image.style.cssText || null;
+
+        initializeDefaults(me);
+
+        me.configureOptions(options);
+        
+        // create context-bound event handlers from our private functions
+        
+        me.mouseover = function(e) { mouseover.call(this,me,e); };
+        me.mouseout = function(e) { mouseout.call(this,me,e); };
+        me.click = function(e) { click.call(this,me,e); };
+        me.clearEffects = function(e) { clearEffects.call(this,me,e); };
+    };
+
+    m.MapData.prototype = {
+        constructor: m.MapData,
+
+         /**
+         * Set target.options from defaults + options
+         * @param  {[type]} target      The target
+         * @param  {[type]} options     The options to merge
+         */
+        
+        configureOptions: function(options) {
+            this.options= u.updateProps({}, m.defaults, options);
+        },
+
+        /**
+         * Ensure all images are loaded
+         * @return {Promise} A promise that resolves when the images have finished loading (or fail)
+         */
+    
+        bindImages: function() {
+            var me=this,
+                mi = me.images;
+
+            // reset the images if this is a rebind
+            
+            if (mi.length>2) {
+                mi.splice(2);
+            } else if (mi.length===0) {
+
+                // add the actual main image
+                mi.add(me.image);
+                // will create a duplicate of the main image, we need this to get raw size info
+                mi.add(me.image.src);
+            }
+            
+            configureAltImages(me);
+
+            return me.images.bind();
+        },
+
+        /**
+         * Test whether an async action is currently in progress
+         * @return {Boolean} true or false indicating state
+         */
+        
+        isActive: function() {
+            return !this.complete || this.currentAction;
+        },
+
+        /**
+         * Return an object indicating the various states. This isn't really used by 
+         * production code.
+         * 
+         * @return {object} An object with properties for various states
+         */
+        
+        state: function () {
+            return {
+                complete: this.complete,
+                resizing: this.currentAction==='resizing',
+                zoomed: this.zoomed,
+                zoomedArea: this.zoomedArea,
+                scaleInfo: this.scaleInfo
+            };
+        },   
+
+        /**
+         * Get a unique ID for the wrapper of this imagemapster
+         * @return {string} A string that is unique to this image
+         */
+        
+        wrapId: function () {
+            return 'mapster_wrap_' + this.index;
+        },
+        _idFromKey: function (key) {
+            return typeof key === "string" && this._xref.hasOwnProperty(key) ?
+                        this._xref[key] : -1;
+        },
+
+        /**
+         * Return a comma-separated string of all selected keys
+         * @return {string} CSV of all keys that are currently selected
+         */
+        
+        getSelected: function () {
+            var result = '';
+            $.each(this.data, function (i,e) {
+                if (e.isSelected()) {
+                    result += (result ? ',' : '') + this.key;
+                }
+            });
+            return result;
+        },
+
+        /**
+         * Get an array of MapAreas associated with a specific AREA based on the keys for that area
+         * @param  {Element} area   An HTML AREA
+         * @param  {number} atMost  A number limiting the number of areas to be returned (typically 1 or 0 for no limit)
+         * @return {MapArea[]}      Array of MapArea objects
+         */
+        
+        getAllDataForArea:function (area,atMost) {
+            var i,ar, result,
+                me=this,
+                key = $(area).filter('area').attr(me.options.mapKey);
+
+            if (key) {
+                result=[];
+                key = u.split(key);
+
+                for (i=0;i<(atMost || key.length);i++) {
+                    ar = me.data[me._idFromKey(key[i])];
+                    ar.area=area.length ? area[0]:area;
+                    // set the actual area moused over/selected
+                    // TODO: this is a brittle model for capturing which specific area - if this method was not used,
+                    // ar.area could have old data. fix this.
+                    result.push(ar);
+                }
+            }
+
+            return result;
+        },
+        getDataForArea: function(area) {
+            var ar=this.getAllDataForArea(area,1);
+            return ar ? ar[0] || null : null;
+        },
+        getDataForKey: function (key) {
+            return this.data[this._idFromKey(key)];
+        },
+        
+        /**
+         * Get the primary keys associated with an area group.
+         * If this is a primary key, it will be returned.
+         * 
+         * @param  {string key An area key
+         * @return {string} A CSV of area keys
+         */
+        
+        getKeysForGroup: function(key) {
+            var ar=this.getDataForKey(key);
+            
+            return !ar ? '':
+                ar.isPrimary ? 
+                    ar.key :
+                    this.getPrimaryKeysForMapAreas(ar.areas()).join(',');
+        },
+        
+        /**
+         * given an array of MapArea object, return an array of its unique primary keys
+         * @param  {MapArea[]} areas The areas to analyze
+         * @return {string[]} An array of unique primary keys
+         */
+        
+        getPrimaryKeysForMapAreas: function(areas)
+        {
+            var keys=[];
+            $.each(areas,function(i,e) {
+                if ($.inArray(e.keys[0],keys)<0) {
+                    keys.push(e.keys[0]);
+                }
+            });
+            return keys;
+        },
+        getData: function (obj) {
+            if (typeof obj === 'string') {
+                return this.getDataForKey(obj);
+            } else if (obj && obj.mapster || u.isElement(obj)) {
+                return this.getDataForArea(obj);
+            } else {
+                return null;
+            }
+        },
+        // remove highlight if present, raise event
+        ensureNoHighlight: function () {
+            var ar;
+            if (this.highlightId >= 0) {
+                this.graphics.clearHighlight();
+                ar = this.data[this.highlightId];
+                ar.changeState('highlight', false);
+                this.setHighlightId(-1);
+            }
+        },
+        setHighlightId: function(id) {
+            this.highlightId = id;
+        },
+        
+        /**
+         * Clear all active selections on this map
+         */
+        
+        clearSelections: function () {
+            $.each(this.data, function (i,e) {
+                if (e.selected) {
+                    e.deselect(true);
+                 }
+            });
+            this.removeSelectionFinish();
+            
+        },
+
+        /**
+         * Set area options from an array of option data.
+         * 
+         * @param {object[]} areas An array of objects containing area-specific options
+         */
+        
+        setAreaOptions: function (areas) {
+            var i, area_options, ar;
+            areas = areas || [];
+
+            // refer by: map_data.options[map_data.data[x].area_option_id]
+            
+            for (i = areas.length - 1; i >= 0; i--) {
+                area_options = areas[i];
+                if (area_options) {
+                    ar = this.getDataForKey(area_options.key);
+                    if (ar) {
+                        u.updateProps(ar.options, area_options);
+                        
+                        // TODO: will not deselect areas that were previously selected, so this only works
+                        // for an initial bind.
+                        
+                        if (u.isBool(area_options.selected)) {
+                            ar.selected = area_options.selected;
+                        }
+                    }
+                }
+            }
+        },
+        // keys: a comma-separated list
+        drawSelections: function (keys) {
+            var i, key_arr = u.asArray(keys);
+
+            for (i = key_arr.length - 1; i >= 0; i--) {
+                this.data[key_arr[i]].drawSelection();
+            }
+        },
+        redrawSelections: function () {
+            $.each(this.data, function (i, e) {
+                if (e.isSelectedOrStatic()) {
+                    e.drawSelection();
+                }
+            });
+
+        },
+        ///called when images are done loading
+        initialize: function () {
+            var imgCopy, base_canvas, overlay_canvas, wrap, parentId, css, i,size,
+                img,sort_func, sorted_list,  scale,  
+                        me = this,
+                        opts = me.options;
+
+            if (me.complete) {
+                return;
+            }
+
+            img = $(me.image);
+            
+            parentId = img.parent().attr('id');
+
+            // create a div wrapper only if there's not already a wrapper, otherwise, own it
+            
+            if (parentId && parentId.length >= 12 && parentId.substring(0, 12) === "mapster_wrap") {
+                wrap = img.parent();
+                wrap.attr('id', me.wrapId());
+            } else {
+                wrap = $('<div id="' + me.wrapId() + '"></div>');
+
+                if (opts.wrapClass) {
+                    if (opts.wrapClass === true) {
+                        wrap.addClass(img[0].className);
+                    }
+                    else {
+                        wrap.addClass(opts.wrapClass);
+                    }
+                }
+            }
+            me.wrapper = wrap;
+            
+            // me.images[1] is the copy of the original image. It should be loaded & at its native size now so we can obtain the true
+            // width & height. This is needed to scale the imagemap if not being shown at its native size. It is also needed purely
+            // to finish binding in case the original image was not visible. It can be impossible in some browsers to obtain the
+            // native size of a hidden image.
+
+            me.scaleInfo = scale = u.scaleMap(me.images[0],me.images[1], opts.scaleMap);
+            
+            me.base_canvas = base_canvas = me.graphics.createVisibleCanvas(me);
+            me.overlay_canvas = overlay_canvas = me.graphics.createVisibleCanvas(me);
+
+            // Now we got what we needed from the copy -clone from the original image again to make sure any other attributes are copied
+            imgCopy = $(me.images[1])
+                .addClass('mapster_el '+ me.images[0].className)
+                .attr({id:null, usemap: null});
+                
+            size=u.size(me.images[0]);
+            
+            if (size.complete) {
+                imgCopy.css({
+                    width: size.width,
+                    height: size.height
+                });
+            }
+     
+            me.buildDataset();
+
+            // now that we have processed all the areas, set css for wrapper, scale map if needed
+
+            css = {
+                display: 'block',
+                position: 'relative',
+                padding: 0,
+                width: scale.width,
+                height: scale.height
+            };
+
+            if (opts.wrapCss) {
+                $.extend(css, opts.wrapCss);
+            }
+            // if we were rebinding with an existing wrapper, the image will aready be in it
+            if (img.parent()[0] !== me.wrapper[0]) {
+
+                img.before(me.wrapper);
+            }
+
+            wrap.css(css);
+
+            // move all generated images into the wrapper for easy removal later
+
+            $(me.images.slice(2)).hide();
+            for (i = 1; i < me.images.length; i++) {
+                wrap.append(me.images[i]);
+            }
+
+            //me.images[1].style.cssText = me.image.style.cssText;
+
+            wrap.append(base_canvas)
+                        .append(overlay_canvas)
+                        .append(img.css(m.canvas_style));
+
+            // images[0] is the original image with map, images[1] is the copy/background that is visible
+
+            u.setOpacity(me.images[0], 0);
+            $(me.images[1]).show();
+
+            u.setOpacity(me.images[1],1);
+
+            if (opts.isSelectable && opts.onGetList) {
+                sorted_list = me.data.slice(0);
+                if (opts.sortList) {
+                    if (opts.sortList === "desc") {
+                        sort_func = function (a, b) {
+                            return a === b ? 0 : (a > b ? -1 : 1);
+                        };
+                    }
+                    else {
+                        sort_func = function (a, b) {
+                            return a === b ? 0 : (a < b ? -1 : 1);
+                        };
+                    }
+
+                    sorted_list.sort(function (a, b) {
+                        a = a.value;
+                        b = b.value;
+                        return sort_func(a, b);
+                    });
+                }
+
+                me.options.boundList = opts.onGetList.call(me.image, sorted_list);
+            }
+            
+            me.complete=true;
+            me.processCommandQueue();
+            
+            if (opts.onConfigured && typeof opts.onConfigured === 'function') {
+                opts.onConfigured.call(img, true);
+            }
+        },
+
+        // when rebind is true, the MapArea data will not be rebuilt.
+        buildDataset: function(rebind) {
+            var sel,areas,j,area_id,$area,area,curKey,mapArea,key,keys,mapAreaId,group_value,dataItem,href,
+                me=this,
+                opts=me.options,
+                default_group;
+
+            function addAreaData(key, value) {
+                var dataItem = new m.AreaData(me, key, value);
+                dataItem.areaId = me._xref[key] = me.data.push(dataItem) - 1;
+                return dataItem.areaId;
+            }
+
+            me._xref = {};
+            me.data = [];
+            if (!rebind) {
+                me.mapAreas=[];
+            }
+
+            default_group = !opts.mapKey;
+            if (default_group) {
+                opts.mapKey = 'data-mapster-key';
+            }
+
+            // the [attribute] selector is broken on old IE with jQuery. hasVml() is a quick and dirty
+            // way to test for that
+            
+            sel = m.hasVml() ? 'area' :
+                        (default_group ? 
+                            'area[coords]' : 
+                            'area[' + opts.mapKey + ']');
+
+            areas = $(me.map).find(sel).unbind('.mapster');
+                        
+            for (mapAreaId = 0;mapAreaId<areas.length; mapAreaId++) {
+                area_id = 0;
+                area = areas[mapAreaId];
+                $area = $(area);
+
+                // skip areas with no coords - selector broken for older ie
+                if (!area.coords) {
+                    continue;
+                }
+                // Create a key if none was assigned by the user
+
+                if (default_group) {
+                     curKey=String(mapAreaId);
+                    $area.attr('data-mapster-key', curKey);
+                   
+                } else {
+                    curKey = area.getAttribute(opts.mapKey);
+                }
+
+                // conditions for which the area will be bound to mouse events
+                // only bind to areas that don't have nohref. ie 6&7 cannot detect the presence of nohref, so we have to also not bind if href is missing.
+
+                if (rebind) {
+                    mapArea = me.mapAreas[$area.data('mapster')-1];
+                    mapArea.configure(curKey);
+                } else {
+                    mapArea = new m.MapArea(me, area,curKey);
+                    me.mapAreas.push(mapArea);
+                }
+
+                keys = mapArea.keys; // converted to an array by mapArea
+
+
+                // Iterate through each mapKey assigned to this area
+                for (j = keys.length - 1; j >= 0; j--) {
+                    key = keys[j];
+
+                    if (opts.mapValue) {
+                        group_value = $area.attr(opts.mapValue);
+                    }
+                    if (default_group) {
+                        // set an attribute so we can refer to the area by index from the DOM object if no key
+                        area_id = addAreaData(me.data.length, group_value);
+                        dataItem = me.data[area_id];
+                        dataItem.key = key = area_id.toString();
+                    }
+                    else {
+                        area_id = me._xref[key];
+                        if (area_id >= 0) {
+                            dataItem = me.data[area_id];
+                            if (group_value && !me.data[area_id].value) {
+                                dataItem.value = group_value;
+                            }
+                        }
+                        else {
+                            area_id = addAreaData(key, group_value);
+                            dataItem = me.data[area_id];
+                            dataItem.isPrimary=j===0;
+                        }
+                    }
+                    mapArea.areaDataXref.push(area_id);
+                    dataItem.areasXref.push(mapAreaId);
+                }
+
+                href=$area.attr('href');
+                if (href && href!=='#' && !dataItem.href)
+                {
+                    dataItem.href=href;
+                }
+
+                if (!mapArea.nohref) {
+                    $area.bind('click.mapster', me.click);
+                       
+                    if (!m.isTouch) {
+                        $area.bind('mouseover.mapster', me.mouseover)
+                            .bind('mouseout.mapster', me.mouseout)
+                            .bind('mousedown.mapster', me.mousedown);
+                        
+                    }
+                        
+                }
+
+                // store an ID with each area. 
+                $area.data("mapster", mapAreaId+1);
+            }
+           
+            // TODO listenToList
+            //            if (opts.listenToList && opts.nitG) {
+            //                opts.nitG.bind('click.mapster', event_hooks[map_data.hooks_index].listclick_hook);
+            //            }
+
+            // populate areas from config options
+            me.setAreaOptions(opts.areas);
+            me.redrawSelections();
+
+        },
+        processCommandQueue: function() {
+            
+            var cur,me=this;
+            while (!me.currentAction && me.commands.length) {
+                cur = me.commands[0];
+                me.commands.splice(0,1);
+                m.impl[cur.command].apply(cur.that, cur.args);
+            }
+        },
+        clearEvents: function () {
+            $(this.map).find('area')
+                        .unbind('.mapster');
+            $(this.images)
+                        .unbind('.mapster');
+        },
+        _clearCanvases: function (preserveState) {
+            // remove the canvas elements created
+            if (!preserveState) {
+                $(this.base_canvas).remove();
+            }
+            $(this.overlay_canvas).remove();
+        },
+        clearMapData: function (preserveState) {
+            var me = this;
+            this._clearCanvases(preserveState);
+
+            // release refs to DOM elements
+            $.each(this.data, function (i, e) {
+                e.reset();
+            });
+            this.data = null;
+            if (!preserveState) {
+                // get rid of everything except the original image
+                this.image.style.cssText = this.imgCssText;
+                $(this.wrapper).before(this.image).remove();
+            }
+
+            me.images.clear();
+
+            this.image = null;
+            u.ifFunction(this.clearTooltip, this);
+        },
+
+        // Compelete cleanup process for deslecting items. Called after a batch operation, or by AreaData for single
+        // operations not flagged as "partial"
+        
+        removeSelectionFinish: function () {
+            var g = this.graphics;
+
+            g.refreshSelections();
+            // do not call ensure_no_highlight- we don't really want to unhilight it, just remove the effect
+            g.clearHighlight();
+        }
+    };
+} (jQuery));
+/* areadata.js
+   AreaData and MapArea protoypes
+*/
+
+(function ($) {
+    var m = $.mapster, u = m.utils;
+    
+    /**
+     * Select this area
+     * 
+     * @param {AreaData} me  AreaData context
+     * @param {object} options Options for rendering the selection
+     */
+    function select(options) {
+        // need to add the new one first so that the double-opacity effect leaves the current one highlighted for singleSelect
+        
+        var me=this, o = me.owner;
+        if (o.options.singleSelect) {
+            o.clearSelections();
+        }
+
+        // because areas can overlap - we can't depend on the selection state to tell us anything about the inner areas.
+        // don't check if it's already selected
+        if (!me.isSelected()) {
+            if (options) {
+                
+                // cache the current options, and map the altImageId if an altimage 
+                // was passed
+
+                me.optsCache = $.extend(me.effectiveRenderOptions('select'),
+                    options,
+                    { 
+                        altImageId: o.images.add(options.altImage)
+                    });
+            }
+
+            me.drawSelection();
+
+            me.selected = true;
+            me.changeState('select', true);
+        }
+
+        if (o.options.singleSelect) {
+            o.graphics.refreshSelections();
+        }
+    }
+
+    /**
+     * Deselect this area, optionally deferring finalization so additional areas can be deselected
+     * in a single operation
+     * 
+     * @param  {boolean} partial when true, the caller must invoke "finishRemoveSelection" to render 
+     */
+    
+    function deselect(partial) {
+        var me=this;
+        me.selected = false;
+        me.changeState('select', false);
+
+        // release information about last area options when deselecting.
+        
+        me.optsCache=null;
+        me.owner.graphics.removeSelections(me.areaId);
+
+        // Complete selection removal process. This is separated because it's very inefficient to perform the whole
+        // process for multiple removals, as the canvas must be totally redrawn at the end of the process.ar.remove
+        
+        if (!partial) {
+            me.owner.removeSelectionFinish();
+        }
+    }
+
+    /**
+     * Toggle the selection state of this area
+     * @param  {object} options Rendering options, if toggling on
+     * @return {bool} The new selection state
+     */
+    function toggle(options) {
+        var me=this;
+        if (!me.isSelected()) {
+            me.select(options);
+        }
+        else {
+            me.deselect();
+        }
+        return me.isSelected();
+    }
+
+    /**
+     * An AreaData object; represents a conceptual area that can be composed of 
+     * one or more MapArea objects
+     * 
+     * @param {MapData} owner The MapData object to which this belongs
+     * @param {string} key   The key for this area
+     * @param {string} value The mapValue string for this area
+     */
+    
+    m.AreaData = function (owner, key, value) {
+        $.extend(this,{
+            owner: owner, 
+            key: key || '',
+            // means this represents the first key in a list of keys (it's the area group that gets highlighted on mouseover)
+            isPrimary: true,
+            areaId: -1,
+            href: '',
+            value: value || '',
+            options:{},
+            // "null" means unchanged. Use "isSelected" method to just test true/false 
+            selected: null,       
+            // xref to MapArea objects
+            areasXref: [],
+            // (temporary storage) - the actual area moused over
+            area: null,
+            // the last options used to render this. Cache so when re-drawing after a remove, changes in options won't
+            // break already selected things. 
+            optsCache: null
+         });
+    };
+
+    /**
+     * The public API for AreaData object
+     */
+
+    m.AreaData.prototype = {
+        constuctor: m.AreaData,
+        select: select,
+        deselect: deselect,
+        toggle: toggle,
+        areas: function() {
+            var i,result=[];
+            for (i=0;i<this.areasXref.length;i++) {
+                result.push(this.owner.mapAreas[this.areasXref[i]]);
+            }
+            return result;
+        },
+        // return all coordinates for all areas
+        coords: function(offset) {
+            var coords = [];
+            $.each(this.areas(), function (i, el) {
+                coords = coords.concat(el.coords(offset));
+            });
+            return coords;
+        },
+        reset: function () {
+            $.each(this.areas(), function (i, e) {
+                e.reset();
+            });
+            this.areasXref = [];
+            this.options = null;
+        },
+        // Return the effective selected state of an area, incorporating staticState
+        isSelectedOrStatic: function () {
+
+            var o = this.effectiveOptions();
+            return u.isBool(o.staticState) ? o.staticState :
+                        this.isSelected();
+        },
+        isSelected: function () {
+            return u.isBool(this.selected) ? this.selected :
+                u.isBool(this.owner.area_options.selected) ? this.owner.area_options.selected : false;
+        },
+        isSelectable: function () {
+            return u.isBool(this.effectiveOptions().staticState) ? false :
+                        (u.isBool(this.owner.options.staticState) ? false : u.boolOrDefault(this.effectiveOptions().isSelectable,true));
+        },
+        isDeselectable: function () {
+            return u.isBool(this.effectiveOptions().staticState) ? false :
+                        (u.isBool(this.owner.options.staticState) ? false : u.boolOrDefault(this.effectiveOptions().isDeselectable,true));
+        },
+        isNotRendered: function() {
+            var area = $(this.area);
+            return area.attr('nohref') ||
+                !area.attr('href') ||
+                this.effectiveOptions().isMask;
+
+        },
+
+        
+         /**
+         * Return the overall options effective for this area. 
+         * This should get the default options, and merge in area-specific options, finally
+         * overlaying options passed by parameter
+         * 
+         * @param  {[type]} options  options which will supercede all other options for this area
+         * @return {[type]}          the combined options
+         */
+        
+        effectiveOptions: function (options) {
+            
+            var opts = u.updateProps({},
+                    this.owner.area_options,
+                    this.options,
+                    options || {},
+                    {
+                        id: this.areaId 
+                    }
+                );
+
+            opts.selected = this.isSelected();
+            
+            return opts;
+        },
+
+        /**
+         * Return the options effective for this area for a "render" or "highlight" mode. 
+         * This should get the default options, merge in the areas-specific options, 
+         * and then the mode-specific options.
+         * @param  {string} mode    'render' or 'highlight'
+         * @param  {[type]} options  options which will supercede all other options for this area
+         * @return {[type]}          the combined options
+         */
+        
+        effectiveRenderOptions: function (mode, options) {
+            var allOpts,opts=this.optsCache;
+            
+            if (!opts || mode==='highlight') {
+                allOpts = this.effectiveOptions(options);
+                opts = u.updateProps({},
+                    allOpts,
+                    allOpts["render_" + mode]
+                );
+                    
+                if (mode!=='highlight') {
+                    this.optsCache=opts;
+                }
+            }
+            return $.extend({},opts);
+        },
+
+        // Fire callback on area state change
+        changeState: function (state_type, state) {
+            if ($.isFunction(this.owner.options.onStateChange)) {
+                this.owner.options.onStateChange.call(this.owner.image,
+                    {
+                        key: this.key,
+                        state: state_type,
+                        selected: state
+                    }
+                );
+            }
+        },
+
+        // highlight this area
+         
+        highlight: function (options) {
+            var o = this.owner;
+            if (this.effectiveOptions().highlight) {
+                o.graphics.addShapeGroup(this, "highlight",options);
+            }
+            o.setHighlightId(this.areaId);
+            this.changeState('highlight', true);
+        },
+
+        // select this area. if "callEvent" is true then the state change event will be called. (This method can be used
+        // during config operations, in which case no event is indicated)
+        
+        drawSelection: function () {
+        
+
+            this.owner.graphics.addShapeGroup(this, "select");
+        
+        }
+
+
+    };
+    // represents an HTML area
+    m.MapArea = function (owner,areaEl,keys) {
+        if (!owner) {
+            return;
+        }
+        var me = this;
+        me.owner = owner;   // a MapData object
+        me.area = areaEl;
+        me.areaDataXref=[]; // a list of map_data.data[] id's for each areaData object containing this
+        me.originalCoords = [];
+        $.each(u.split(areaEl.coords), function (i, el) {
+            me.originalCoords.push(parseFloat(el));
+        });
+        me.length = me.originalCoords.length;
+        me.shape = areaEl.shape.toLowerCase();
+        me.nohref = areaEl.nohref || !areaEl.href;
+        me.configure(keys);
+    };
+    m.MapArea.prototype= {
+        constructor: m.MapArea,
+        configure: function(keys) {
+            this.keys = u.split(keys);
+        },
+        reset: function() {
+            this.area=null;
+        },
+        coords: function (offset) {
+            return $.map(this.originalCoords,function(e) {
+                return offset ? e : e+offset;
+            });
+        }
+    };
+} (jQuery));
+/* areacorners.js
+   determine the best place to put a box of dimensions (width,height) given a circle, rect or poly
+*/
+
+(function ($) {
+    var u=$.mapster.utils;
+
+
+    /**
+     * Compute positions that will place a target with dimensions [width,height] outside 
+     * but near the boundaries of the elements "elements". When an imagemap is passed, the 
+     *
+     * @param  {Element|Element[]} elements An element or an array of elements (such as a jQuery object)
+     * @param  {Element} image The image to which area elements are bound, if this is an image map.
+     * @param  {Element} container The contianer in which the target must be constrained (or document, if missing)
+     * @param  {int} width The width of the target object
+     * @return {object} a structure with the x and y positions
+     */
+    u.areaCorners = function (elements, image, container, width, height) {
+        var pos,found, minX, minY, maxX, maxY, bestMinX, bestMaxX, bestMinY, bestMaxY, curX, curY, nest, j,
+           offsetx=0, 
+           offsety=0,
+           rootx,
+           rooty,
+           iCoords,radius,angle,el,
+           coords=[];
+
+        // if a single element was passed, map it to an array
+        
+        elements = elements.length ? 
+            elements:
+            [elements];
+
+        container = container ? 
+            $(container):
+            $(document.body);
+
+        // get the relative root of calculation
+
+        pos = container.offset();
+        rootx = pos.left;
+        rooty = pos.top;
+
+        // with areas, all we know about is relative to the top-left corner of the image. We need to add an offset compared to
+        // the actual container. After this calculation, offsetx/offsety can be added to either the area coords, or the target's
+        // absolute position to get the correct top/left boundaries of the container.
+
+        if (image) {
+            pos = $(image).offset();
+            offsetx = pos.left;
+            offsety = pos.top;
+        }
+
+        // map the coordinates of any type of shape to a poly and use the logic. simpler than using three different
+        // calculation methods. Circles use a 20 degree increment for this estimation.
+
+        for (j=0;j<elements.length;j++) 
+        {
+            el=elements[j];
+            if (el.nodeName==='AREA') {
+                iCoords = u.split(el.coords,parseInt);
+
+                switch(el.shape) {
+                    case 'circle':
+                        curX=iCoords[0];
+                        curY=iCoords[1];
+                        radius=iCoords[2];
+                        coords=[];
+                        for (j=0;j<360;j+=20) {
+                             angle=j*Math.PI/180;
+                             coords.push(curX+radius*Math.cos(angle),curY+radius*Math.sin(angle));
+                        }
+                        break;
+                      case 'rect':
+                          coords.push(iCoords[0],iCoords[1],iCoords[2],iCoords[1],iCoords[2],iCoords[3],iCoords[0],iCoords[3]);
+                          break;
+                      default:
+                          coords=coords.concat(iCoords);
+                         break;
+                }
+
+                // map area positions to it's real position in the container
+
+                for (j=0;j<coords.length;j+=2)
+                {
+                    coords[j]=parseInt(coords[j],10)+offsetx;
+                    coords[j+1]=parseInt(coords[j+1],10)+offsety;
+                }
+            } else {
+                el=$(el);
+                pos = el.position();
+                coords.push(pos.left,pos.top,
+                            pos.left+el.width(),pos.top,
+                            pos.left+el.width(),pos.top+el.height(),
+                            pos.left,pos.top+el.height());
+
+            }
+        }
+        
+        minX = minY = bestMinX = bestMinY = 999999;
+        maxX = maxY = bestMaxX = bestMaxY = -1;
+
+        for (j = coords.length - 2; j >= 0; j -= 2) {
+            curX = coords[j];
+            curY = coords[j + 1];
+            
+            if (curX < minX) {
+                minX = curX;
+                bestMaxY = curY;
+            }
+            if (curX > maxX) {
+                maxX = curX;
+                bestMinY = curY;
+            }
+            if (curY < minY) {
+                minY = curY;
+                bestMaxX = curX;
+            }
+            if (curY > maxY) {
+                maxY = curY;
+                bestMinX = curX;
+            }
+
+        }
+
+        // try to figure out the best place for the tooltip
+        
+        if (width && height) {
+            found=false;
+            $.each([[bestMaxX - width, minY - height], [bestMinX, minY - height],
+                             [minX - width, bestMaxY - height], [minX - width, bestMinY],
+                             [maxX,bestMaxY - height], [ maxX,bestMinY],
+                             [bestMaxX - width, maxY], [bestMinX, maxY]
+                      ],function (i, e) {
+                          if (!found && (e[0] > rootx && e[1] > rooty)) {
+                              nest = e;
+                              found=true;
+                              return false;
+                  }
+             });
+             
+             // default to lower-right corner if nothing fit inside the boundaries of the image
+             
+             if (!found) {
+                 nest=[maxX,maxY];
+             }
+        }
+        return nest;
+    };
+} (jQuery));
+/* scale.js: resize and zoom functionality
+   requires areacorners.js, when.js
+*/
+
+
+(function ($) {
+    var m = $.mapster, u = m.utils, p = m.MapArea.prototype;
+
+    m.utils.getScaleInfo = function (eff, actual) {
+        var pct;
+        if (!actual) {
+            pct = 1;
+            actual=eff;
+        } else {
+            pct = eff.width / actual.width || eff.height / actual.height;
+            // make sure a float error doesn't muck us up
+            if (pct > 0.98 && pct < 1.02) { pct = 1; }
+        }
+        return {
+            scale: (pct !== 1),
+            scalePct: pct,
+            realWidth: actual.width,
+            realHeight: actual.height,
+            width: eff.width,
+            height: eff.height,
+            ratio: eff.width / eff.height
+        };
+    };
+    // Scale a set of AREAs, return old data as an array of objects
+    m.utils.scaleMap = function (image, imageRaw, scale) {
+        
+        // stunningly, jQuery width can return zero even as width does not, seems to happen only
+        // with adBlock or maybe other plugins. These must interfere with onload events somehow.
+
+
+        var vis=u.size(image),
+            raw=u.size(imageRaw,true);
+
+        if (!raw.complete()) {
+            throw("Another script, such as an extension, appears to be interfering with image loading. Please let us know about this.");
+        }
+        if (!vis.complete()) {
+            vis=raw;
+        }
+        return this.getScaleInfo(vis, scale ? raw : null);
+    };
+    
+    /**
+     * Resize the image map. Only one of newWidth and newHeight should be passed to preserve scale
+     * 
+     * @param  {int}   width       The new width OR an object containing named parameters matching this function sig
+     * @param  {int}   height      The new height
+     * @param  {int}   effectDuration Time in ms for the resize animation, or zero for no animation
+     * @param  {function} callback    A function to invoke when the operation finishes
+     * @return {promise}              NOT YET IMPLEMENTED
+     */
+    
+    m.MapData.prototype.resize = function (width, height, duration, callback) {
+        var p,promises,newsize,els, highlightId, ratio, 
+            me = this;
+        
+        // allow omitting duration
+        callback = callback || duration;
+
+        function sizeCanvas(canvas, w, h) {
+            if (m.hasCanvas()) {
+                canvas.width = w;
+                canvas.height = h;
+            } else {
+                $(canvas).width(w);
+                $(canvas).height(h);
+            }
+        }
+
+        // Finalize resize action, do callback, pass control to command queue
+
+        function cleanupAndNotify() {
+
+            me.currentAction = '';
+            
+            if ($.isFunction(callback)) {
+                callback();
+            }
+            
+            me.processCommandQueue();
+        }
+
+        // handle cleanup after the inner elements are resized
+        
+        function finishResize() {
+            sizeCanvas(me.overlay_canvas, width, height);
+
+            // restore highlight state if it was highlighted before
+            if (highlightId >= 0) {
+                var areaData = me.data[highlightId];
+                areaData.tempOptions = { fade: false };
+                me.getDataForKey(areaData.key).highlight();
+                areaData.tempOptions = null;
+            }
+            sizeCanvas(me.base_canvas, width, height);
+            me.redrawSelections();
+            cleanupAndNotify();
+        }
+
+        function resizeMapData() {
+            $(me.image).css(newsize);
+            // start calculation at the same time as effect
+            me.scaleInfo = u.getScaleInfo({
+                    width: width,
+                    height: height
+                },
+                { 
+                    width: me.scaleInfo.realWidth,
+                    height: me.scaleInfo.realHeight
+                });
+            $.each(me.data, function (i, e) {
+                $.each(e.areas(), function (i, e) {
+                    e.resize();
+                });
+            });
+        }
+
+        if (me.scaleInfo.width === width && me.scaleInfo.height === height) {
+            return;
+        }
+
+        highlightId = me.highlightId;
+
+        
+        if (!width) {
+            ratio = height / me.scaleInfo.realHeight;
+            width = Math.round(me.scaleInfo.realWidth * ratio);
+        }
+        if (!height) {
+            ratio = width / me.scaleInfo.realWidth;
+            height = Math.round(me.scaleInfo.realHeight * ratio);
+        }
+
+        newsize = { 'width': String(width) + 'px', 'height': String(height) + 'px' };
+        if (!m.hasCanvas()) {
+            $(me.base_canvas).children().remove();
+        }
+
+        // resize all the elements that are part of the map except the image itself (which is not visible)
+        // but including the div wrapper
+        els = $(me.wrapper).find('.mapster_el').add(me.wrapper);
+
+        if (duration) {
+            promises = [];
+            me.currentAction = 'resizing';
+            els.each(function (i, e) {
+                p = u.defer();
+                promises.push(p);
+
+                $(e).animate(newsize, {
+                    duration: duration,
+                    complete: p.resolve,
+                    easing: "linear"
+                });
+            });
+
+            p = u.defer();
+            promises.push(p);
+
+            // though resizeMapData is not async, it needs to be finished just the same as the animations,
+            // so add it to the "to do" list.
+            
+            u.when.all(promises).then(finishResize);
+            resizeMapData();
+            p.resolve();
+        } else {
+            els.css(newsize);
+            resizeMapData();
+            finishResize();
+            
+        }
+    };
+
+
+    m.MapArea = u.subclass(m.MapArea, function () {
+        //change the area tag data if needed
+        this.base.init();
+        if (this.owner.scaleInfo.scale) {
+            this.resize();
+        }
+    });
+
+    p.coords = function (percent, coordOffset) {
+        var j, newCoords = [],
+                    pct = percent || this.owner.scaleInfo.scalePct,
+                    offset = coordOffset || 0;
+
+        if (pct === 1 && coordOffset === 0) {
+            return this.originalCoords;
+        }
+
+        for (j = 0; j < this.length; j++) {
+            //amount = j % 2 === 0 ? xPct : yPct;
+            newCoords.push(Math.round(this.originalCoords[j] * pct) + offset);
+        }
+        return newCoords;
+    };
+    p.resize = function () {
+        this.area.coords = this.coords().join(',');
+    };
+
+    p.reset = function () {
+        this.area.coords = this.coords(1).join(',');
+    };
+    
+    m.impl.resize = function (width, height, duration, callback) {
+        if (!width && !height) {
+            return false;
+        }
+        var x= (new m.Method(this,
+                function () {
+                    this.resize(width, height, duration, callback);
+                },
+                null,
+                {
+                    name: 'resize',
+                    args: arguments
+                }
+            )).go();
+        return x;
+    };
+
+/*
+    m.impl.zoom = function (key, opts) {
+        var options = opts || {};
+
+        function zoom(areaData) {
+            // this will be MapData object returned by Method
+
+            var scroll, corners, height, width, ratio,
+                    diffX, diffY, ratioX, ratioY, offsetX, offsetY, newWidth, newHeight, scrollLeft, scrollTop,
+                    padding = options.padding || 0,
+                    scrollBarSize = areaData ? 20 : 0,
+                    me = this,
+                    zoomOut = false;
+
+            if (areaData) {
+                // save original state on first zoom operation
+                if (!me.zoomed) {
+                    me.zoomed = true;
+                    me.preZoomWidth = me.scaleInfo.width;
+                    me.preZoomHeight = me.scaleInfo.height;
+                    me.zoomedArea = areaData;
+                    if (options.scroll) {
+                        me.wrapper.css({ overflow: 'auto' });
+                    }
+                }
+                corners = $.mapster.utils.areaCorners(areaData.coords(1, 0));
+                width = me.wrapper.innerWidth() - scrollBarSize - padding * 2;
+                height = me.wrapper.innerHeight() - scrollBarSize - padding * 2;
+                diffX = corners.maxX - corners.minX;
+                diffY = corners.maxY - corners.minY;
+                ratioX = width / diffX;
+                ratioY = height / diffY;
+                ratio = Math.min(ratioX, ratioY);
+                offsetX = (width - diffX * ratio) / 2;
+                offsetY = (height - diffY * ratio) / 2;
+
+                newWidth = me.scaleInfo.realWidth * ratio;
+                newHeight = me.scaleInfo.realHeight * ratio;
+                scrollLeft = (corners.minX) * ratio - padding - offsetX;
+                scrollTop = (corners.minY) * ratio - padding - offsetY;
+            } else {
+                if (!me.zoomed) {
+                    return;
+                }
+                zoomOut = true;
+                newWidth = me.preZoomWidth;
+                newHeight = me.preZoomHeight;
+                scrollLeft = null;
+                scrollTop = null;
+            }
+
+            this.resize({
+                width: newWidth,
+                height: newHeight,
+                duration: options.duration,
+                scroll: scroll,
+                scrollLeft: scrollLeft,
+                scrollTop: scrollTop,
+                // closure so we can be sure values are correct
+                callback: (function () {
+                    var isZoomOut = zoomOut,
+                            scroll = options.scroll,
+                            areaD = areaData;
+                    return function () {
+                        if (isZoomOut) {
+                            me.preZoomWidth = null;
+                            me.preZoomHeight = null;
+                            me.zoomed = false;
+                            me.zoomedArea = false;
+                            if (scroll) {
+                                me.wrapper.css({ overflow: 'inherit' });
+                            }
+                        } else {
+                            // just to be sure it wasn't canceled & restarted
+                            me.zoomedArea = areaD;
+                        }
+                    };
+                } ())
+            });
+        }
+        return (new m.Method(this,
+                function (opts) {
+                    zoom.call(this);
+                },
+                function () {
+                    zoom.call(this.owner, this);
+                },
+                {
+                    name: 'zoom',
+                    args: arguments,
+                    first: true,
+                    key: key
+                }
+                )).go();
+
+
+    };
+    */
+} (jQuery));
+/* tooltip.js - tooltip functionality
+   requires areacorners.js
+*/
+
+(function ($) {
+
+    var m = $.mapster, u = m.utils;
+    
+    $.extend(m.defaults, {
+        toolTipContainer: '<div style="border: 2px solid black; background: #EEEEEE; width:160px; padding:4px; margin: 4px; -moz-box-shadow: 3px 3px 5px #535353; ' +
+        '-webkit-box-shadow: 3px 3px 5px #535353; box-shadow: 3px 3px 5px #535353; -moz-border-radius: 6px 6px 6px 6px; -webkit-border-radius: 6px; ' +
+        'border-radius: 6px 6px 6px 6px; opacity: 0.9;"></dteniv>',
+        showToolTip: false,
+        toolTipFade: true,
+        toolTipClose: ['area-mouseout','image-mouseout'],
+        onShowToolTip: null,
+        onHideToolTip: null
+    });
+    
+    $.extend(m.area_defaults, {
+        toolTip: null,
+        toolTipClose: null
+    });
+    
+
+    /**
+     * Show a tooltip positioned near this area.
+     * 
+     * @param {string|jquery} html A string of html or a jQuery object containing the tooltip content.
+     * @param {string|jquery} [template] The html template in which to wrap the content
+     * @param {string|object} [css] CSS to apply to the outermost element of the tooltip 
+     * @return {jquery} The tooltip that was created
+     */
+    
+    function createToolTip(html, template, css) {
+        var tooltip;
+
+        // wrap the template in a jQuery object, or clone the template if it's already one.
+        // This assumes that anything other than a string is a jQuery object; if it's not jQuery will
+        // probably throw an error.
+        
+        if (template) {
+            tooltip = typeof template === 'string' ?
+                $(template) : 
+                $(template).clone();
+
+            tooltip.append(html);
+        } else {
+            tooltip=$(html);
+        }
+
+        // always set display to block, or the positioning css won't work if the end user happened to
+        // use a non-block type element.
+
+        tooltip.css($.extend((css || {}),{
+                display:"block",
+                position:"absolute"
+            })).hide();
+        
+        $('body').append(tooltip);
+
+        // we must actually add the tooltip to the DOM and "show" it in order to figure out how much space it
+        // consumes, and then reposition it with that knowledge.
+        // We also cache the actual opacity setting to restore finally.
+        
+        tooltip.attr("data-opacity",tooltip.css("opacity"))
+            .css("opacity",0);
+        
+        // doesn't really show it because opacity=0
+        
+        return tooltip.show();
+    }
+
+
+    /**
+     * Show a tooltip positioned near this area.
+     * 
+     * @param {jquery} tooltip The tooltip
+     * @param {object} [options] options for displaying the tooltip.
+     *  @config {int} [left] The 0-based absolute x position for the tooltip
+     *  @config {int} [top] The 0-based absolute y position for the tooltip
+     *  @config {string|object} [css] CSS to apply to the outermost element of the tooltip 
+     *  @config {bool} [fadeDuration] When non-zero, the duration in milliseconds of a fade-in effect for the tooltip.
+     */
+    
+    function showToolTipImpl(tooltip,options)
+    {
+        var tooltipCss = { 
+                "left":  options.left + "px",
+                "top": options.top + "px"
+            }, 
+            actalOpacity=tooltip.attr("data-opacity") || 0,
+            zindex = tooltip.css("z-index");
+        
+        if (parseInt(zindex,10)===0 
+            || zindex === "auto") {
+            tooltipCss["z-index"] = 9999;
+        }
+
+        tooltip.css(tooltipCss)
+            .addClass('mapster_tooltip');
+
+        
+        if (options.fadeDuration && options.fadeDuration>0) {
+            u.fader(tooltip[0], 0, actalOpacity, options.fadeDuration);
+        } else {
+            u.setOpacity(tooltip[0], actalOpacity);
+        }
+    }
+      
+    /**
+     * Hide and remove active tooltips
+     * 
+     * @param  {MapData} this The mapdata object to which the tooltips belong
+     */
+    
+    m.MapData.prototype.clearToolTip = function() {
+        if (this.activeToolTip) {
+            this.activeToolTip.stop().remove();
+            this.activeToolTip = null;
+            this.activeToolTipID = null;
+            u.ifFunction(this.options.onHideToolTip, this);
+        }
+    };
+
+    /**
+     * Configure the binding between a named tooltip closing option, and a mouse event.
+     *
+     * If a callback is passed, it will be called when the activating event occurs, and the tooltip will
+     * only closed if it returns true.
+     *
+     * @param  {MapData}  [this]     The MapData object to which this tooltip belongs.
+     * @param  {String}   option     The name of the tooltip closing option
+     * @param  {String}   event      UI event to bind to this option
+     * @param  {Element}  target     The DOM element that is the target of the event
+     * @param  {Function} [beforeClose] Callback when the tooltip is closed
+     * @param  {Function} [onClose]  Callback when the tooltip is closed
+     */
+    function bindToolTipClose(options, bindOption, event, target, beforeClose, onClose) {
+        var event_name = event + '.mapster-tooltip';
+        
+        if ($.inArray(bindOption, options) >= 0) {
+            target.unbind(event_name)
+                .bind(event_name, function (e) {
+                    if (!beforeClose || beforeClose.call(this,e)) {
+                        target.unbind('.mapster-tooltip');
+                        if (onClose) {
+                            onClose.call(this);
+                        }
+                    }
+                });
+            
+            return {
+                object: target, 
+                event: event_name
+            };
+        }
+    }
+    
+    /**
+     * Show a tooltip.
+     *
+     * @param {string|jquery}   [tooltip]       A string of html or a jQuery object containing the tooltip content.
+     * 
+     * @param {string|jquery}   [target]        The target of the tooltip, to be used to determine positioning. If null,
+     *                                          absolute position values must be passed with left and top.
+     *
+     * @param {string|jquery}   [image]         If target is an [area] the image that owns it
+     * 
+     * @param {string|jquery}   [container]     An element within which the tooltip must be bounded
+     *
+     *
+     * 
+     * @param {object|string|jQuery} [options]  options to apply when creating this tooltip - OR -
+     *                                          The markup, or a jquery object, containing the data for the tooltip 
+     *                                         
+     *  @config {string}        [closeEvents]   A string with one or more comma-separated values that determine when the tooltip
+     *                                          closes: 'area-click','tooltip-click','image-mouseout' are valid values
+     *                                          then no template will be used.
+     *  @config {int}           [offsetx]       the horizontal amount to offset the tooltip 
+     *  @config {int}           [offsety]       the vertical amount to offset the tooltip 
+     *  @config {string|object} [css]           CSS to apply to the outermost element of the tooltip 
+     */
+    
+    function showToolTip(tooltip,target,image,container,options) {
+        var corners,
+            ttopts = {};
+    
+        options = options || {};
+
+
+        if (target) {
+
+            corners = u.areaCorners(target,image,container,
+                                    tooltip.outerWidth(true),
+                                    tooltip.outerHeight(true));
+
+            // Try to upper-left align it first, if that doesn't work, change the parameters
+
+            ttopts.left = corners[0];
+            ttopts.top = corners[1];
+
+        } else {
+            
+            ttopts.left = options.left;
+            ttopts.top = options.top;
+        }
+
+        ttopts.left += (options.offsetx || 0);
+        ttopts.top +=(options.offsety || 0);
+
+        ttopts.css= options.css;
+        ttopts.fadeDuration = options.fadeDuration;
+
+        showToolTipImpl(tooltip,ttopts);
+
+        return tooltip;
+    }
+    
+    /**
+     * Show a tooltip positioned near this area.
+      *
+     * @param {string|jquery}   [content]       A string of html or a jQuery object containing the tooltip content.
+     
+     * @param {object|string|jQuery} [options]  options to apply when creating this tooltip - OR -
+     *                                          The markup, or a jquery object, containing the data for the tooltip 
+     *  @config {string|jquery}   [container]     An element within which the tooltip must be bounded
+     *  @config {bool}          [template]      a template to use instead of the default. If this property exists and is null,
+     *                                          then no template will be used.
+     *  @config {string}        [closeEvents]   A string with one or more comma-separated values that determine when the tooltip
+     *                                          closes: 'area-click','tooltip-click','image-mouseout' are valid values
+     *                                          then no template will be used.
+     *  @config {int}           [offsetx]       the horizontal amount to offset the tooltip 
+     *  @config {int}           [offsety]       the vertical amount to offset the tooltip 
+     *  @config {string|object} [css]           CSS to apply to the outermost element of the tooltip 
+     */
+    m.AreaData.prototype.showToolTip= function(content,options) {
+        var tooltip, closeOpts, target, tipClosed, template,
+            ttopts = {},
+            ad=this,
+            md=ad.owner,
+            areaOpts = ad.effectiveOptions();
+    
+        // copy the options object so we can update it
+        options = options ? $.extend({},options) : {};
+
+        content = content || areaOpts.toolTip;
+        closeOpts = options.closeEvents || areaOpts.toolTipClose || md.options.toolTipClose || 'tooltip-click';
+        
+        template = typeof options.template !== 'undefined' ? 
+                options.template :
+                md.options.toolTipContainer;
+
+        options.closeEvents = typeof closeOpts === 'string' ?
+            closeOpts = u.split(closeOpts) :
+            closeOpts;
+
+        options.fadeDuration = options.fadeDuration ||
+                 (md.options.toolTipFade ? 
+                    (md.options.fadeDuration || areaOpts.fadeDuration) : 0);
+
+        target = ad.area ? 
+            ad.area :
+            $.map(ad.areas(),
+                function(e) {
+                    return e.area;
+                });
+
+        if (md.activeToolTipID===ad.areaId) {
+            return;
+        }
+
+        md.clearToolTip();
+
+        md.activeToolTip = tooltip = createToolTip(content,
+            template,
+            options.css);
+
+        md.activeToolTipID = ad.areaId;
+
+        tipClosed = function() {
+            md.clearToolTip();
+        };
+
+        bindToolTipClose(closeOpts,'area-click', 'click', $(md.map), null, tipClosed);
+        bindToolTipClose(closeOpts,'tooltip-click', 'click', tooltip,null, tipClosed);
+        bindToolTipClose(closeOpts,'image-mouseout', 'mouseout', $(md.image), function(e) {
+            return (e.relatedTarget && e.relatedTarget.nodeName!=='AREA' && e.relatedTarget!==ad.area);
+        }, tipClosed);
+
+
+        showToolTip(tooltip,
+                    target,
+                    md.image,
+                    options.container,
+                    template,
+                    options);
+
+        u.ifFunction(md.options.onShowToolTip, ad.area,
+        {
+            toolTip: tooltip,
+            options: ttopts,
+            areaOptions: areaOpts,
+            key: ad.key,
+            selected: ad.isSelected()
+        });
+
+        return tooltip;
+    };
+    
+
+    /**
+     * Parse an object that could be a string, a jquery object, or an object with a "contents" property
+     * containing html or a jQuery object.
+     * 
+     * @param  {object|string|jQuery} options The parameter to parse
+     * @return {string|jquery} A string or jquery object
+     */
+    function getHtmlFromOptions(options) {
+
+            // see if any html was passed as either the options object itself, or the content property
+
+            return (options ?
+                ((typeof options === 'string' || options.jquery) ?
+                    options :
+                    options.content) :
+                null);
+    }
+
+    /**
+     * Activate or remove a tooltip for an area. When this method is called on an area, the
+     * key parameter doesn't apply and "options" is the first parameter.
+     *
+     * When called with no parameters, or "key" is a falsy value, any active tooltip is cleared.
+     * 
+     * When only a key is provided, the default tooltip for the area is used. 
+     * 
+     * When html is provided, this is used instead of the default tooltip.
+     * 
+     * When "noTemplate" is true, the default tooltip template will not be used either, meaning only
+     * the actual html passed will be used.
+     *  
+     * @param  {string|AreaElement} key The area for which to activate a tooltip, or a DOM element.
+     * 
+     * @param {object|string|jquery} [options] options to apply when creating this tooltip - OR -
+     *                                         The markup, or a jquery object, containing the data for the tooltip 
+     *  @config {string|jQuery} [content]   the inner content of the tooltip; the tooltip text or HTML
+     *  @config {Element|jQuery} [container]   the inner content of the tooltip; the tooltip text or HTML
+     *  @config {bool}          [template]  a template to use instead of the default. If this property exists and is null,
+     *                                      then no template will be used.
+     *  @config {int}           [offsetx]   the horizontal amount to offset the tooltip.
+     *  @config {int}           [offsety]   the vertical amount to offset the tooltip.
+     *  @config {string|object} [css]       CSS to apply to the outermost element of the tooltip 
+     *  @config {string|object} [css] CSS to apply to the outermost element of the tooltip 
+     *  @config {bool}          [fadeDuration] When non-zero, the duration in milliseconds of a fade-in effect for the tooltip.
+     * @return {jQuery} The jQuery object
+     */
+    
+    m.impl.tooltip = function (key,options) {
+        return (new m.Method(this,
+        function mapData() {
+            var tooltip, target, md=this;
+            if (!key) {
+                md.clearToolTip();
+            } else {
+                target=$(key);
+                if (md.activeToolTipID ===target[0]) {
+                    return;
+                }
+                md.clearToolTip();
+
+                md.activeToolTip = tooltip = createToolTip(getHtmlFromOptions(options),
+                            options.template || md.options.toolTipContainer,
+                            options.css);
+                md.activeToolTipID = target[0];
+
+                bindToolTipClose(['tooltip-click'],'tooltip-click', 'click', tooltip, null, function() {
+                    md.clearToolTip();
+                });
+
+                md.activeToolTip = tooltip = showToolTip(tooltip,
+                    target,
+                    md.image,
+                    options.container,
+                    options);
+            }
+        },
+        function areaData() {
+            if ($.isPlainObject(key) && !options) {
+                options = key;
+            }
+
+            this.showToolTip(getHtmlFromOptions(options),options);
+        },
+        { 
+            name: 'tooltip',
+            args: arguments,
+            key: key
+        }
+    )).go();
+    };
+} (jQuery));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/js/jquery-imagemapster-1.2.10.min.js	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,1 @@
+(function(a){a(function(){var d,j,u,c;k.defer=f;k.reject=i;k.isPromise=q;k.all=e;k.some=o;k.any=p;k.map=x;k.reduce=n;k.chain=s;d=Object.freeze||function(y){return y};function g(){}g.prototype=d({always:function(y,z){return this.then(y,y,z)},otherwise:function(y){return this.then(c,y)}});function t(y){var z=new g();z.then=function(C){var A;try{if(C){A=C(y)}return r(A===c?y:A)}catch(B){return w(B)}};return d(z)}function w(z){var y=new g();y.then=function(D,A){var B;try{if(A){B=A(z);return r(B===c?z:B)}return w(z)}catch(C){return w(C)}};return d(y)}function i(y){return k(y,function(z){return w(z)})}function f(){var H,J,F,D,B,z,A;F=[];D=[];B=function E(N,L,M){var K=f();F.push(function(O){O.then(N,L).then(K.resolve,K.reject,K.progress)});M&&D.push(M);return K.promise};function C(M,K,L){return B(M,K,L)}function G(K){A(t(K))}function I(K){A(w(K))}z=function(M){var K,L=0;while(K=D[L++]){K(M)}};function y(K){z(K)}A=function(L){var N,K=0;B=L.then;A=z=function M(){throw new Error("already completed")};D=c;while(N=F[K++]){N(L)}F=[]};H={};J=new g();J.then=H.then=C;H.promise=d(J);H.resolver=d({resolve:(H.resolve=G),reject:(H.reject=I),progress:(H.progress=y)});return H}function q(y){return y&&typeof y.then==="function"}function k(A,C,B,z){var y=r(A);return y.then(C,B,z)}function r(y){var A,z;if(y instanceof g){A=y}else{z=f();if(q(y)){y.then(z.resolve,z.reject,z.progress);A=z.promise}else{z.resolve(y);A=z.promise}}return A}function o(B,A,C,z,y){m(2,arguments);return k(B,function(H){var M,J,L,P,F,G,O,K,I;K=H.length>>>0;M=Math.max(0,Math.min(A,K));J=[];P=f();L=k(P,C,z,y);function N(R){F(R)}function Q(R){G(R)}function D(R){O(R)}function E(){F=G=O=h}if(!M){P.resolve(J)}else{F=function(R){J.push(R);if(!--M){E();P.resolve(J)}};G=function(R){E();P.reject(R)};O=P.progress;for(I=0;I<K;++I){if(I in H){k(H[I],N,Q,D)}}}return L})}function e(A,B,z,y){m(1,arguments);return k(A,function(C){return v(C,l,[])}).then(B,z,y)}function l(z,A,y){z[y]=A;return z}function p(A,C,z,y){function B(D){return C?C(D[0]):D[0]}return o(A,1,B,z,y)}function x(z,y){return k(z,function(A){return b(A,y)})}function b(B,C){var A,y,z;y=B.length>>>0;A=new Array(y);for(z=0;z<y;z++){if(z in B){A[z]=k(B[z],C)}}return v(A,l,A)}function n(B,A,y){var z=u.call(arguments,1);return k(B,function(C){return v.apply(c,[C].concat(z))})}function v(C,A,y){var B,z;B=C.length;z=[function(E,F,D){return k(E,function(G){return k(F,function(H){return A(G,H,D,B)})})}];if(arguments.length>2){z.push(y)}return j.apply(C,z)}function s(y,B,A){var z=arguments.length>2;return k(y,function(C){if(z){C=A}B.resolve(C);return C},function(C){B.reject(C);return w(C)},B.progress)}function m(B,A){var y,z=A.length;while(z>B){y=A[--z];if(y!=null&&typeof y!="function"){throw new Error("callback is not a function")}}}function h(){}u=[].slice;j=[].reduce||function(D){var z,B,A,y,C;C=0;z=Object(this);y=z.length>>>0;B=arguments;if(B.length<=1){for(;;){if(C in z){A=z[C++];break}if(++C>=y){throw new TypeError()}}}else{A=B[1]}for(;C<y;++C){if(C in z){A=D(A,z[C],C,z)}}return A};return k})})(typeof define=="function"?define:function(a){typeof module!="undefined"?(module.exports=a()):(jQuery.mapster_when=a())});(function($){$.fn.mapster=function(method){var m=$.mapster.impl;if($.isFunction(m[method])){return m[method].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof method==="object"||!method){return m.bind.apply(this,arguments)}else{$.error("Method "+method+" does not exist on jQuery.mapster")}}};$.mapster={version:"1.2.10",render_defaults:{isSelectable:true,isDeselectable:true,fade:false,fadeDuration:150,fill:true,fillColor:"000000",fillColorMask:"FFFFFF",fillOpacity:0.7,highlight:true,stroke:false,strokeColor:"ff0000",strokeOpacity:1,strokeWidth:1,includeKeys:"",altImage:null,altImageId:null,altImages:{}},defaults:{clickNavigate:false,wrapClass:null,wrapCss:null,onGetList:null,sortList:false,listenToList:false,mapKey:"",mapValue:"",singleSelect:false,listKey:"value",listSelectedAttribute:"selected",listSelectedClass:null,onClick:null,onMouseover:null,onMouseout:null,mouseoutDelay:0,onStateChange:null,boundList:null,onConfigured:null,configTimeout:30000,noHrefIsMask:true,scaleMap:true,safeLoad:false,areas:[]},shared_defaults:{render_highlight:{fade:true},render_select:{fade:false},staticState:null,selected:null},area_defaults:{includeKeys:"",isMask:false},canvas_style:{position:"absolute",left:0,top:0,padding:0,border:0},hasCanvas:null,isTouch:null,map_cache:[],hooks:{},addHook:function(name,callback){this.hooks[name]=(this.hooks[name]||[]).push(callback)},callHooks:function(name,context){$.each(this.hooks[name]||[],function(i,e){e.apply(context)})},utils:{when:$.mapster_when,defer:$.mapster_when.defer,subclass:function(BaseClass,constr){var Subclass=function(){var me=this,args=Array.prototype.slice.call(arguments,0);me.base=BaseClass.prototype;me.base.init=function(){BaseClass.prototype.constructor.apply(me,args)};constr.apply(me,args)};Subclass.prototype=new BaseClass();Subclass.prototype.constructor=Subclass;return Subclass},asArray:function(obj){return obj.constructor===Array?obj:this.split(obj)},split:function(text,cb){var i,el,arr=text.split(",");for(i=0;i<arr.length;i++){el=$.trim(arr[i]);if(el===""){arr.splice(i,1)}else{arr[i]=cb?cb(el):el}}return arr},updateProps:function(_target,_template){var onlyProps,target=_target||{},template=$.isEmptyObject(target)?_template:_target;onlyProps=[];$.each(template,function(prop){onlyProps.push(prop)});$.each(Array.prototype.slice.call(arguments,1),function(i,src){$.each(src||{},function(prop){if(!onlyProps||$.inArray(prop,onlyProps)>=0){var p=src[prop];if($.isPlainObject(p)){target[prop]=$.extend(target[prop]||{},p)}else{if(p&&p.constructor===Array){target[prop]=p.slice(0)}else{if(typeof p!=="undefined"){target[prop]=src[prop]}}}}})});return target},isElement:function(o){return(typeof HTMLElement==="object"?o instanceof HTMLElement:o&&typeof o==="object"&&o.nodeType===1&&typeof o.nodeName==="string")},indexOfProp:function(obj,prop,val){var result=obj.constructor===Array?-1:null;$.each(obj,function(i,e){if(e&&(prop?e[prop]:e)===val){result=i;return false}});return result},boolOrDefault:function(obj,def){return this.isBool(obj)?obj:def||false},isBool:function(obj){return typeof obj==="boolean"},isUndef:function(obj){return typeof obj==="undefined"},ifFunction:function(obj,that,args){if($.isFunction(obj)){obj.call(that,args)}},size:function(image,raw){var u=$.mapster.utils;return{width:raw?(image.width||image.naturalWidth):u.imgWidth(image,true),height:raw?(image.height||image.naturalHeight):u.imgHeight(image,true),complete:function(){return !!this.height&&!!this.width}}},setOpacity:function(el,opacity){if($.mapster.hasCanvas()){el.style.opacity=opacity}else{$(el).each(function(i,e){if(typeof e.opacity!=="undefined"){e.opacity=opacity}else{$(e).css("opacity",opacity)}})}},fader:(function(){var elements={},lastKey=0,fade_func=function(el,op,endOp,duration){var index,cbIntervals=duration/15,obj,u=$.mapster.utils;if(typeof el==="number"){obj=elements[el];if(!obj){return}}else{index=u.indexOfProp(elements,null,el);if(index){delete elements[index]}elements[++lastKey]=obj=el;el=lastKey}endOp=endOp||1;op=(op+(endOp/cbIntervals)>endOp-0.01)?endOp:op+(endOp/cbIntervals);u.setOpacity(obj,op);if(op<endOp){setTimeout(function(){fade_func(el,op,endOp,duration)},15)}};return fade_func}())},getBoundList:function(opts,key_list){if(!opts.boundList){return null}var index,key,result=$(),list=$.mapster.utils.split(key_list);opts.boundList.each(function(i,e){for(index=0;index<list.length;index++){key=list[index];if($(e).is("["+opts.listKey+'="'+key+'"]')){result=result.add(e)}}});return result},setBoundListProperties:function(opts,target,selected){target.each(function(i,e){if(opts.listSelectedClass){if(selected){$(e).addClass(opts.listSelectedClass)}else{$(e).removeClass(opts.listSelectedClass)}}if(opts.listSelectedAttribute){$(e).attr(opts.listSelectedAttribute,selected)}})},getMapDataIndex:function(obj){var img,id;switch(obj.tagName&&obj.tagName.toLowerCase()){case"area":id=$(obj).parent().attr("name");img=$("img[usemap='#"+id+"']")[0];break;case"img":img=obj;break}return img?this.utils.indexOfProp(this.map_cache,"image",img):-1},getMapData:function(obj){var index=this.getMapDataIndex(obj.length?obj[0]:obj);if(index>=0){return index>=0?this.map_cache[index]:null}},queueCommand:function(map_data,that,command,args){if(!map_data){return false}if(!map_data.complete||map_data.currentAction){map_data.commands.push({that:that,command:command,args:args});return true}return false},unload:function(){this.impl.unload();this.utils=null;this.impl=null;$.fn.mapster=null;$.mapster=null;$("*").unbind()}};var m=$.mapster,u=m.utils,ap=Array.prototype;$.each(["width","height"],function(i,e){var capProp=e.substr(0,1).toUpperCase()+e.substr(1);u["img"+capProp]=function(img,jqwidth){return(jqwidth?$(img)[e]():0)||img[e]||img["natural"+capProp]||img["client"+capProp]||img["offset"+capProp]}});m.Method=function(that,func_map,func_area,opts){var me=this;me.name=opts.name;me.output=that;me.input=that;me.first=opts.first||false;me.args=opts.args?ap.slice.call(opts.args,0):[];me.key=opts.key;me.func_map=func_map;me.func_area=func_area;me.name=opts.name;me.allowAsync=opts.allowAsync||false};m.Method.prototype={constructor:m.Method,go:function(){var i,data,ar,len,result,src=this.input,area_list=[],me=this;len=src.length;for(i=0;i<len;i++){data=$.mapster.getMapData(src[i]);if(data){if(!me.allowAsync&&m.queueCommand(data,me.input,me.name,me.args)){if(this.first){result=""}continue}ar=data.getData(src[i].nodeName==="AREA"?src[i]:this.key);if(ar){if($.inArray(ar,area_list)<0){area_list.push(ar)}}else{result=this.func_map.apply(data,me.args)}if(this.first||typeof result!=="undefined"){break}}}$(area_list).each(function(i,e){result=me.func_area.apply(e,me.args)});if(typeof result!=="undefined"){return result}else{return this.output}}};$.mapster.impl=(function(){var me={},addMap=function(map_data){return m.map_cache.push(map_data)-1},removeMap=function(map_data){m.map_cache.splice(map_data.index,1);for(var i=m.map_cache.length-1;i>=this.index;i--){m.map_cache[i].index--}};function hasVml(){var a=$("<div />").appendTo("body");a.html('<v:shape id="vml_flag1" adj="1" />');var b=a[0].firstChild;b.style.behavior="url(#default#VML)";var has=b?typeof b.adj==="object":true;a.remove();return has}function namespaces(){return typeof(document.namespaces)==="object"?document.namespaces:null}function hasCanvas(){var d=namespaces();return d&&d.g_vml_?false:$("<canvas />")[0].getContext?true:false}function merge_areas(map_data,areas){var ar,index,map_areas=map_data.options.areas;if(areas){$.each(areas,function(i,e){if(!e||!e.key){return}index=u.indexOfProp(map_areas,"key",e.key);if(index>=0){$.extend(map_areas[index],e)}else{map_areas.push(e)}ar=map_data.getDataForKey(e.key);if(ar){$.extend(ar.options,e)}})}}function merge_options(map_data,options){var temp_opts=u.updateProps({},options);delete temp_opts.areas;u.updateProps(map_data.options,temp_opts);merge_areas(map_data,options.areas);u.updateProps(map_data.area_options,map_data.options)}me.get=function(key){var md=m.getMapData(this);if(!(md&&md.complete)){throw ("Can't access data until binding complete.")}return(new m.Method(this,function(){return this.getSelected()},function(){return this.isSelected()},{name:"get",args:arguments,key:key,first:true,allowAsync:true,defaultReturn:""})).go()};me.data=function(key){return(new m.Method(this,null,function(){return this},{name:"data",args:arguments,key:key})).go()};me.highlight=function(key){return(new m.Method(this,function(){if(key===false){this.ensureNoHighlight()}else{var id=this.highlightId;return id>=0?this.data[id].key:null}},function(){this.highlight()},{name:"highlight",args:arguments,key:key,first:true})).go()};me.keys=function(key,all){var keyList=[],md=m.getMapData(this);if(!(md&&md.complete)){throw ("Can't access data until binding complete.")}function addUniqueKeys(ad){var areas,keys=[];if(!all){keys.push(ad.key)}else{areas=ad.areas();$.each(areas,function(i,e){keys=keys.concat(e.keys)})}$.each(keys,function(i,e){if($.inArray(e,keyList)<0){keyList.push(e)}})}if(!(md&&md.complete)){return""}if(typeof key==="string"){if(all){addUniqueKeys(md.getDataForKey(key))}else{keyList=[md.getKeysForGroup(key)]}}else{all=key;this.each(function(i,e){if(e.nodeName==="AREA"){addUniqueKeys(md.getDataForArea(e))}})}return keyList.join(",")};me.select=function(){me.set.call(this,true)};me.deselect=function(){me.set.call(this,false)};me.set=function(selected,key,options){var lastMap,map_data,opts=options,key_list,area_list;function setSelection(ar){if(ar){switch(selected){case true:ar.select(opts);break;case false:ar.deselect(true);break;default:ar.toggle(opts);break}}}function addArea(ar){if(ar&&$.inArray(ar,area_list)<0){area_list.push(ar);key_list+=(key_list===""?"":",")+ar.key}}function finishSetForMap(map_data){$.each(area_list,function(i,el){setSelection(el)});if(!selected){map_data.removeSelectionFinish()}if(map_data.options.boundList){m.setBoundListProperties(map_data.options,m.getBoundList(map_data.options,key_list),selected)}}this.filter("img,area").each(function(i,e){var keys;map_data=m.getMapData(e);if(map_data!==lastMap){if(lastMap){finishSetForMap(lastMap)}area_list=[];key_list=""}if(map_data){keys="";if(e.nodeName.toUpperCase()==="IMG"){if(!m.queueCommand(map_data,$(e),"set",[selected,key,opts])){if(key instanceof Array){if(key.length){keys=key.join(",")}}else{keys=key}if(keys){$.each(u.split(keys),function(i,key){addArea(map_data.getDataForKey(key.toString()));lastMap=map_data})}}}else{opts=key;if(!m.queueCommand(map_data,$(e),"set",[selected,opts])){addArea(map_data.getDataForArea(e));lastMap=map_data}}}});if(map_data){finishSetForMap(map_data)}return this};me.unbind=function(preserveState){return(new m.Method(this,function(){this.clearEvents();this.clearMapData(preserveState);removeMap(this)},null,{name:"unbind",args:arguments})).go()};me.rebind=function(options){return(new m.Method(this,function(){var me=this;me.complete=false;me.configureOptions(options);me.bindImages().then(function(){me.buildDataset(true);me.complete=true})},null,{name:"rebind",args:arguments})).go()};me.get_options=function(key,effective){var eff=u.isBool(key)?key:effective;return(new m.Method(this,function(){var opts=$.extend({},this.options);if(eff){opts.render_select=u.updateProps({},m.render_defaults,opts,opts.render_select);opts.render_highlight=u.updateProps({},m.render_defaults,opts,opts.render_highlight)}return opts},function(){return eff?this.effectiveOptions():this.options},{name:"get_options",args:arguments,first:true,allowAsync:true,key:key})).go()};me.set_options=function(options){return(new m.Method(this,function(){merge_options(this,options)},null,{name:"set_options",args:arguments})).go()};me.unload=function(){var i;for(i=m.map_cache.length-1;i>=0;i--){if(m.map_cache[i]){me.unbind.call($(m.map_cache[i].image))}}me.graphics=null};me.snapshot=function(){return(new m.Method(this,function(){$.each(this.data,function(i,e){e.selected=false});this.base_canvas=this.graphics.createVisibleCanvas(this);$(this.image).before(this.base_canvas)},null,{name:"snapshot"})).go()};me.state=function(){var md,result=null;$(this).each(function(i,e){if(e.nodeName==="IMG"){md=m.getMapData(e);if(md){result=md.state()}return false}});return result};me.bind=function(options){return this.each(function(i,e){var img,map,usemap,md;img=$(e);md=m.getMapData(e);if(md){me.unbind.apply(img);if(!md.complete){img.bind();return true}md=null}usemap=this.getAttribute("usemap");map=usemap&&$('map[name="'+usemap.substr(1)+'"]');if(!(img.is("img")&&usemap&&map.size()>0)){return true}img.css("border",0);if(!md){md=new m.MapData(this,options);md.index=addMap(md);md.map=map;md.bindImages().then(function(){md.initialize()})}})};me.init=function(useCanvas){var style,shapes;m.hasCanvas=function(){if(!u.isBool(m.hasCanvas.value)){m.hasCanvas.value=u.isBool(useCanvas)?useCanvas:hasCanvas()}return m.hasCanvas.value};m.hasVml=function(){if(!u.isBool(m.hasVml.value)){var d=namespaces();if(d&&!d.v){d.add("v","urn:schemas-microsoft-com:vml");style=document.createStyleSheet();shapes=["shape","rect","oval","circ","fill","stroke","imagedata","group","textbox"];$.each(shapes,function(i,el){style.addRule("v\\:"+el,"behavior: url(#default#VML); antialias:true")})}m.hasVml.value=hasVml()}return m.hasVml.value};m.isTouch=!!document.documentElement.ontouchstart;$.extend(m.defaults,m.render_defaults,m.shared_defaults);$.extend(m.area_defaults,m.render_defaults,m.shared_defaults)};me.test=function(obj){return eval(obj)};return me}());$.mapster.impl.init()}(jQuery));(function(e){var a,d=e.mapster,i=d.utils,g,b;function h(l,n,m){var o=l,p=o.map_data,k=m.isMask;e.each(n.areas(),function(q,r){m.isMask=k||(r.nohref&&p.options.noHrefIsMask);o.addShape(r,m)});m.isMask=k}function c(k){return Math.max(0,Math.min(parseInt(k,16),255))}function f(k,l){return"rgba("+c(k.substr(0,2))+","+c(k.substr(2,2))+","+c(k.substr(4,2))+","+l+")"}d.Graphics=function(l){var k=this;k.active=false;k.canvas=null;k.width=0;k.height=0;k.shapes=[];k.masks=[];k.map_data=l};a=d.Graphics.prototype={constructor:d.Graphics,begin:function(l,k){var m=e(l);this.elementName=k;this.canvas=l;this.width=m.width();this.height=m.height();this.shapes=[];this.masks=[];this.active=true},addShape:function(m,l){var k=l.isMask?this.masks:this.shapes;k.push({mapArea:m,options:l})},createVisibleCanvas:function(k){return e(this.createCanvasFor(k)).addClass("mapster_el").css(d.canvas_style)[0]},addShapeGroup:function(r,n,s){var q=this,o,l,m,p=this.map_data,k=r.effectiveRenderOptions(n);if(s){e.extend(k,s)}if(n==="select"){l="static_"+r.areaId.toString();m=p.base_canvas}else{m=p.overlay_canvas}q.begin(m,l);if(k.includeKeys){o=i.split(k.includeKeys);e.each(o,function(u,v){var t=p.getDataForKey(v.toString());h(q,t,t.effectiveRenderOptions(n))})}h(q,r,k);q.render();if(k.fade){i.fader(d.hasCanvas()?m:e(m).find("._fill").not(".mapster_mask"),0,d.hasCanvas()?1:k.fillOpacity,k.fadeDuration)}}};function j(){}g={renderShape:function(l,m,n){var k,o=m.coords(null,n);switch(m.shape){case"rect":l.rect(o[0],o[1],o[2]-o[0],o[3]-o[1]);break;case"poly":l.moveTo(o[0],o[1]);for(k=2;k<m.length;k+=2){l.lineTo(o[k],o[k+1])}l.lineTo(o[0],o[1]);break;case"circ":case"circle":l.arc(o[0],o[1],o[2],0,Math.PI*2,false);break}},addAltImage:function(l,n,m,k){l.beginPath();this.renderShape(l,m);l.closePath();l.clip();l.globalAlpha=k.altImageOpacity||k.fillOpacity;l.drawImage(n,0,0,m.owner.scaleInfo.width,m.owner.scaleInfo.height)},render:function(){var p,n,m=this,o=m.map_data,r=m.masks.length,q=m.createCanvasFor(o),l=q.getContext("2d"),k=m.canvas.getContext("2d");if(r){p=m.createCanvasFor(o);n=p.getContext("2d");n.clearRect(0,0,p.width,p.height);e.each(m.masks,function(s,t){n.save();n.beginPath();m.renderShape(n,t.mapArea);n.closePath();n.clip();n.lineWidth=0;n.fillStyle="#000";n.fill();n.restore()})}e.each(m.shapes,function(t,u){l.save();if(u.options.fill){if(u.options.altImageId){m.addAltImage(l,o.images[u.options.altImageId],u.mapArea,u.options)}else{l.beginPath();m.renderShape(l,u.mapArea);l.closePath();l.fillStyle=f(u.options.fillColor,u.options.fillOpacity);l.fill()}}l.restore()});e.each(m.shapes.concat(m.masks),function(t,u){var v=u.options.strokeWidth===1?0.5:0;if(u.options.stroke){l.save();l.strokeStyle=f(u.options.strokeColor,u.options.strokeOpacity);l.lineWidth=u.options.strokeWidth;l.beginPath();m.renderShape(l,u.mapArea,v);l.closePath();l.stroke();l.restore()}});if(r){n.globalCompositeOperation="source-out";n.drawImage(q,0,0);k.drawImage(p,0,0)}else{k.drawImage(q,0,0)}m.active=false;return m.canvas},createCanvasFor:function(k){return e('<canvas width="'+k.scaleInfo.width+'" height="'+k.scaleInfo.height+'"></canvas>')[0]},clearHighlight:function(){var k=this.map_data.overlay_canvas;k.getContext("2d").clearRect(0,0,k.width,k.height)},refreshSelections:function(){var k,l=this.map_data;k=l.base_canvas;l.base_canvas=this.createVisibleCanvas(l);e(l.base_canvas).hide();e(k).before(l.base_canvas);l.redrawSelections();e(l.base_canvas).show();e(k).remove()}};b={renderShape:function(n,v,k){var p=this,t,u,m,l,r,q,s,o=n.coords();r=p.elementName?'name="'+p.elementName+'" ':"";q=k?'class="'+k+'" ':"";l='<v:fill color="#'+v.fillColor+'" class="_fill" opacity="'+(v.fill?v.fillOpacity:0)+'" /><v:stroke class="_fill" opacity="'+v.strokeOpacity+'"/>';u=v.stroke?" strokeweight="+v.strokeWidth+' stroked="t" strokecolor="#'+v.strokeColor+'"':' stroked="f"';t=v.fill?' filled="t"':' filled="f"';switch(n.shape){case"rect":s="<v:rect "+q+r+t+u+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+o[0]+"px;top:"+o[1]+"px;width:"+(o[2]-o[0])+"px;height:"+(o[3]-o[1])+'px;">'+l+"</v:rect>";break;case"poly":s="<v:shape "+q+r+t+u+' coordorigin="0,0" coordsize="'+p.width+","+p.height+'" path="m '+o[0]+","+o[1]+" l "+o.slice(2).join(",")+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+p.width+"px;height:"+p.height+'px;">'+l+"</v:shape>";break;case"circ":case"circle":s="<v:oval "+q+r+t+u+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(o[0]-o[2])+"px;top:"+(o[1]-o[2])+"px;width:"+(o[2]*2)+"px;height:"+(o[2]*2)+'px;">'+l+"</v:oval>";break}m=e(s);e(p.canvas).append(m);return m},render:function(){var l,k=this;e.each(this.shapes,function(m,n){k.renderShape(n.mapArea,n.options)});if(this.masks.length){e.each(this.masks,function(m,n){l=i.updateProps({},n.options,{fillOpacity:1,fillColor:n.options.fillColorMask});k.renderShape(n.mapArea,l,"mapster_mask")})}this.active=false;return this.canvas},createCanvasFor:function(m){var k=m.scaleInfo.width,l=m.scaleInfo.height;return e('<var width="'+k+'" height="'+l+'" style="zoom:1;overflow:hidden;display:block;width:'+k+"px;height:"+l+'px;"></var>')[0]},clearHighlight:function(){e(this.map_data.overlay_canvas).children().remove()},removeSelections:function(k){if(k>=0){e(this.map_data.base_canvas).find('[name="static_'+k.toString()+'"]').remove()}else{e(this.map_data.base_canvas).children().remove()}}};e.each(["renderShape","addAltImage","render","createCanvasFor","clearHighlight","removeSelections","refreshSelections"],function(k,l){a[l]=(function(m){return function(){a[m]=(d.hasCanvas()?g[m]:b[m])||j;return a[m].apply(this,arguments)}}(l))})}(jQuery));(function(d){var a=d.mapster,b=a.utils,c=[];a.MapImages=function(e){this.owner=e;this.clear()};a.MapImages.prototype={constructor:a.MapImages,slice:function(){return c.slice.apply(this,arguments)},splice:function(){c.slice.apply(this.status,arguments);var e=c.slice.apply(this,arguments);return e},complete:function(){return d.inArray(false,this.status)<0},_add:function(f){var e=c.push.call(this,f)-1;this.status[e]=false;return e},indexOf:function(e){return d.inArray(e,this)},clear:function(){var e=this;if(e.ids&&e.ids.length>0){d.each(e.ids,function(f,g){delete e[g]})}e.ids=[];e.length=0;e.status=[];e.splice(0)},add:function(g,i){var e,h,f=this;if(!g){return}if(typeof g==="string"){h=g;g=f[h];if(typeof g==="object"){return f.indexOf(g)}g=d("<img />").addClass("mapster_el").hide();e=f._add(g[0]);g.bind("load",function(j){f.imageLoaded.call(f,j)}).bind("error",function(j){f.imageLoadError.call(f,j)});g.attr("src",h)}else{e=f._add(d(g)[0])}if(i){if(this[i]){throw (i+" is already used or is not available as an altImage alias.")}f.ids.push(i);f[i]=f[e]}return e},bind:function(g){var h=this,i,e=h.owner.options.configTimeout/200,f=function(){var j;j=h.length;while(j-->0){if(!h.isLoaded(j)){break}}if(h.complete()){h.resolve()}else{if(e-->0){h.imgTimeout=window.setTimeout(function(){f.call(h,true)},50)}else{h.imageLoadError.call(h)}}};i=h.deferred=b.defer();f();return i},resolve:function(){var e=this,f=e.deferred;if(f){e.deferred=null;f.resolve()}},imageLoaded:function(h){var g=this,f=g.indexOf(h.target);if(f>=0){g.status[f]=true;if(d.inArray(false,g.status)<0){g.resolve()}}},imageLoadError:function(g){clearTimeout(this.imgTimeout);this.triesLeft=0;var f=g?"The image "+g.target.src+" failed to load.":"The images never seemed to finish loading. You may just need to increase the configTimeout if images could take a long time to load.";throw f},isLoaded:function(g){var f,h=this,e=h.status;if(e[g]){return true}f=h[g];if(typeof f.complete!=="undefined"){e[g]=f.complete}else{e[g]=!!b.imgWidth(f)}return e[g]}}}(jQuery));(function(h){var d=h.mapster,k=d.utils;function a(m){h.extend(m,{complete:false,map:null,base_canvas:null,overlay_canvas:null,commands:[],data:[],mapAreas:[],_xref:{},highlightId:-1,currentAreaId:-1,_tooltip_events:[],scaleInfo:null,index:-1,activeAreaEvent:null})}function e(m){return[m,m.render_highlight,m.render_select]}function g(o){var n=o.options,m=o.images;if(d.hasCanvas()){h.each(n.altImages||{},function(p,q){m.add(q,p)});h.each([n].concat(n.areas),function(p,q){h.each(e(q),function(r,s){if(s&&s.altImage){s.altImageId=m.add(s.altImage)}})})}o.area_options=k.updateProps({},d.area_defaults,n)}function f(q,o,p,n){n=n||k.when.defer();function m(r){if(q.currentAreaId!==r&&q.highlightId>=0){n.resolve()}}if(q.activeAreaEvent){window.clearTimeout(q.activeAreaEvent);q.activeAreaEvent=0}if(o<0){return}if(p.owner.currentAction||o){q.activeAreaEvent=window.setTimeout((function(){return function(){f(q,0,p,n)}}(p)),o||100)}else{m(p.areaId)}return n}function c(m){if(!d.hasCanvas()){this.blur()}m.preventDefault()}function j(n,o){var p=n.getAllDataForArea(this),m=p.length?p[0]:null;if(!m||m.isNotRendered()||m.owner.currentAction){return}if(n.currentAreaId===m.areaId){return}if(n.highlightId!==m.areaId){n.clearEffects();m.highlight();if(n.options.showToolTip){h.each(p,function(q,r){if(r.effectiveOptions().toolTip){r.showToolTip()}})}}n.currentAreaId=m.areaId;if(h.isFunction(n.options.onMouseover)){n.options.onMouseover.call(this,{e:o,options:m.effectiveOptions(),key:m.key,selected:m.isSelected()})}}function i(p,q){var n,m=p.getDataForArea(this),o=p.options;if(p.currentAreaId<0||!m){return}n=p.getDataForArea(q.relatedTarget);if(n===m){return}p.currentAreaId=-1;m.area=null;f(p,o.mouseoutDelay,m).then(p.clearEffects);if(h.isFunction(o.onMouseout)){o.onMouseout.call(this,{e:q,options:o,key:m.key,selected:m.isSelected()})}}function b(n){var m=n.options;n.ensureNoHighlight();if(m.toolTipClose&&h.inArray("area-mouseout",m.toolTipClose)>=0&&n.activeToolTip){n.clearToolTip()}}function l(w,u){var r,v,o,q,x,s,t=this,p=w.getDataForArea(this),n=w.options;function m(z){var y,A;x=(z.isSelectable()&&(z.isDeselectable()||!z.isSelected()));if(x){q=!z.isSelected()}else{q=z.isSelected()}o=d.getBoundList(n,z.key);if(h.isFunction(n.onClick)){s=n.onClick.call(t,{e:u,listTarget:o,key:z.key,selected:q});if(k.isBool(s)){if(!s){return false}A=h(z.area).attr("href");if(A!=="#"){window.location.href=A;return false}}}if(x){r=z.toggle()}if(n.boundList&&n.boundList.length>0){d.setBoundListProperties(n,o,z.isSelected())}y=z.effectiveOptions();if(y.includeKeys){v=k.split(y.includeKeys);h.each(v,function(C,D){var B=w.getDataForKey(D.toString());if(!B.options.isMask){m(B)}})}}c.call(this,u);if(n.clickNavigate&&p.href){window.location.href=p.href;return}if(p&&!p.owner.currentAction){n=w.options;m(p)}}d.MapData=function(o,m){var n=this;n.image=o;n.images=new d.MapImages(n);n.graphics=new d.Graphics(n);n.imgCssText=o.style.cssText||null;a(n);n.configureOptions(m);n.mouseover=function(p){j.call(this,n,p)};n.mouseout=function(p){i.call(this,n,p)};n.click=function(p){l.call(this,n,p)};n.clearEffects=function(p){b.call(this,n,p)}};d.MapData.prototype={constructor:d.MapData,configureOptions:function(m){this.options=k.updateProps({},d.defaults,m)},bindImages:function(){var n=this,m=n.images;if(m.length>2){m.splice(2)}else{if(m.length===0){m.add(n.image);m.add(n.image.src)}}g(n);return n.images.bind()},isActive:function(){return !this.complete||this.currentAction},state:function(){return{complete:this.complete,resizing:this.currentAction==="resizing",zoomed:this.zoomed,zoomedArea:this.zoomedArea,scaleInfo:this.scaleInfo}},wrapId:function(){return"mapster_wrap_"+this.index},_idFromKey:function(m){return typeof m==="string"&&this._xref.hasOwnProperty(m)?this._xref[m]:-1},getSelected:function(){var m="";h.each(this.data,function(n,o){if(o.isSelected()){m+=(m?",":"")+this.key}});return m},getAllDataForArea:function(s,r){var p,n,m,q=this,o=h(s).filter("area").attr(q.options.mapKey);if(o){m=[];o=k.split(o);for(p=0;p<(r||o.length);p++){n=q.data[q._idFromKey(o[p])];n.area=s.length?s[0]:s;m.push(n)}}return m},getDataForArea:function(n){var m=this.getAllDataForArea(n,1);return m?m[0]||null:null},getDataForKey:function(m){return this.data[this._idFromKey(m)]},getKeysForGroup:function(n){var m=this.getDataForKey(n);return !m?"":m.isPrimary?m.key:this.getPrimaryKeysForMapAreas(m.areas()).join(",")},getPrimaryKeysForMapAreas:function(m){var n=[];h.each(m,function(o,p){if(h.inArray(p.keys[0],n)<0){n.push(p.keys[0])}});return n},getData:function(m){if(typeof m==="string"){return this.getDataForKey(m)}else{if(m&&m.mapster||k.isElement(m)){return this.getDataForArea(m)}else{return null}}},ensureNoHighlight:function(){var m;if(this.highlightId>=0){this.graphics.clearHighlight();m=this.data[this.highlightId];m.changeState("highlight",false);this.setHighlightId(-1)}},setHighlightId:function(m){this.highlightId=m},clearSelections:function(){h.each(this.data,function(m,n){if(n.selected){n.deselect(true)}});this.removeSelectionFinish()},setAreaOptions:function(n){var p,o,m;n=n||[];for(p=n.length-1;p>=0;p--){o=n[p];if(o){m=this.getDataForKey(o.key);if(m){k.updateProps(m.options,o);if(k.isBool(o.selected)){m.selected=o.selected}}}}},drawSelections:function(o){var m,n=k.asArray(o);for(m=n.length-1;m>=0;m--){this.data[n[m]].drawSelection()}},redrawSelections:function(){h.each(this.data,function(m,n){if(n.isSelectedOrStatic()){n.drawSelection()}})},initialize:function(){var y,r,n,p,u,v,t,z,s,o,x,q,w=this,m=w.options;if(w.complete){return}s=h(w.image);u=s.parent().attr("id");if(u&&u.length>=12&&u.substring(0,12)==="mapster_wrap"){p=s.parent();p.attr("id",w.wrapId())}else{p=h('<div id="'+w.wrapId()+'"></div>');if(m.wrapClass){if(m.wrapClass===true){p.addClass(s[0].className)}else{p.addClass(m.wrapClass)}}}w.wrapper=p;w.scaleInfo=q=k.scaleMap(w.images[0],w.images[1],m.scaleMap);w.base_canvas=r=w.graphics.createVisibleCanvas(w);w.overlay_canvas=n=w.graphics.createVisibleCanvas(w);y=h(w.images[1]).addClass("mapster_el "+w.images[0].className).attr({id:null,usemap:null});z=k.size(w.images[0]);if(z.complete){y.css({width:z.width,height:z.height})}w.buildDataset();v={display:"block",position:"relative",padding:0,width:q.width,height:q.height};if(m.wrapCss){h.extend(v,m.wrapCss)}if(s.parent()[0]!==w.wrapper[0]){s.before(w.wrapper)}p.css(v);h(w.images.slice(2)).hide();for(t=1;t<w.images.length;t++){p.append(w.images[t])}p.append(r).append(n).append(s.css(d.canvas_style));k.setOpacity(w.images[0],0);h(w.images[1]).show();k.setOpacity(w.images[1],1);if(m.isSelectable&&m.onGetList){x=w.data.slice(0);if(m.sortList){if(m.sortList==="desc"){o=function(B,A){return B===A?0:(B>A?-1:1)}}else{o=function(B,A){return B===A?0:(B<A?-1:1)}}x.sort(function(B,A){B=B.value;A=A.value;return o(B,A)})}w.options.boundList=m.onGetList.call(w.image,x)}w.complete=true;w.processCommandQueue();if(m.onConfigured&&typeof m.onConfigured==="function"){m.onConfigured.call(s,true)}},buildDataset:function(o){var y,n,z,x,m,C,u,r,E,t,w,p,q,B,D=this,s=D.options,v;function A(G,H){var F=new d.AreaData(D,G,H);F.areaId=D._xref[G]=D.data.push(F)-1;return F.areaId}D._xref={};D.data=[];if(!o){D.mapAreas=[]}v=!s.mapKey;if(v){s.mapKey="data-mapster-key"}y=d.hasVml()?"area":(v?"area[coords]":"area["+s.mapKey+"]");n=h(D.map).find(y).unbind(".mapster");for(w=0;w<n.length;w++){x=0;C=n[w];m=h(C);if(!C.coords){continue}if(v){u=String(w);m.attr("data-mapster-key",u)}else{u=C.getAttribute(s.mapKey)}if(o){r=D.mapAreas[m.data("mapster")-1];r.configure(u)}else{r=new d.MapArea(D,C,u);D.mapAreas.push(r)}t=r.keys;for(z=t.length-1;z>=0;z--){E=t[z];if(s.mapValue){p=m.attr(s.mapValue)}if(v){x=A(D.data.length,p);q=D.data[x];q.key=E=x.toString()}else{x=D._xref[E];if(x>=0){q=D.data[x];if(p&&!D.data[x].value){q.value=p}}else{x=A(E,p);q=D.data[x];q.isPrimary=z===0}}r.areaDataXref.push(x);q.areasXref.push(w)}B=m.attr("href");if(B&&B!=="#"&&!q.href){q.href=B}if(!r.nohref){m.bind("click.mapster",D.click);if(!d.isTouch){m.bind("mouseover.mapster",D.mouseover).bind("mouseout.mapster",D.mouseout).bind("mousedown.mapster",D.mousedown)}}m.data("mapster",w+1)}D.setAreaOptions(s.areas);D.redrawSelections()},processCommandQueue:function(){var n,m=this;while(!m.currentAction&&m.commands.length){n=m.commands[0];m.commands.splice(0,1);d.impl[n.command].apply(n.that,n.args)}},clearEvents:function(){h(this.map).find("area").unbind(".mapster");h(this.images).unbind(".mapster")},_clearCanvases:function(m){if(!m){h(this.base_canvas).remove()}h(this.overlay_canvas).remove()},clearMapData:function(n){var m=this;this._clearCanvases(n);h.each(this.data,function(o,p){p.reset()});this.data=null;if(!n){this.image.style.cssText=this.imgCssText;h(this.wrapper).before(this.image).remove()}m.images.clear();this.image=null;k.ifFunction(this.clearTooltip,this)},removeSelectionFinish:function(){var m=this.graphics;m.refreshSelections();m.clearHighlight()}}}(jQuery));(function(f){var c=f.mapster,d=c.utils;function b(g){var h=this,i=h.owner;if(i.options.singleSelect){i.clearSelections()}if(!h.isSelected()){if(g){h.optsCache=f.extend(h.effectiveRenderOptions("select"),g,{altImageId:i.images.add(g.altImage)})}h.drawSelection();h.selected=true;h.changeState("select",true)}if(i.options.singleSelect){i.graphics.refreshSelections()}}function e(g){var h=this;h.selected=false;h.changeState("select",false);h.optsCache=null;h.owner.graphics.removeSelections(h.areaId);if(!g){h.owner.removeSelectionFinish()}}function a(g){var h=this;if(!h.isSelected()){h.select(g)}else{h.deselect()}return h.isSelected()}c.AreaData=function(g,h,i){f.extend(this,{owner:g,key:h||"",isPrimary:true,areaId:-1,href:"",value:i||"",options:{},selected:null,areasXref:[],area:null,optsCache:null})};c.AreaData.prototype={constuctor:c.AreaData,select:b,deselect:e,toggle:a,areas:function(){var h,g=[];for(h=0;h<this.areasXref.length;h++){g.push(this.owner.mapAreas[this.areasXref[h]])}return g},coords:function(h){var g=[];f.each(this.areas(),function(j,k){g=g.concat(k.coords(h))});return g},reset:function(){f.each(this.areas(),function(g,h){h.reset()});this.areasXref=[];this.options=null},isSelectedOrStatic:function(){var g=this.effectiveOptions();return d.isBool(g.staticState)?g.staticState:this.isSelected()},isSelected:function(){return d.isBool(this.selected)?this.selected:d.isBool(this.owner.area_options.selected)?this.owner.area_options.selected:false},isSelectable:function(){return d.isBool(this.effectiveOptions().staticState)?false:(d.isBool(this.owner.options.staticState)?false:d.boolOrDefault(this.effectiveOptions().isSelectable,true))},isDeselectable:function(){return d.isBool(this.effectiveOptions().staticState)?false:(d.isBool(this.owner.options.staticState)?false:d.boolOrDefault(this.effectiveOptions().isDeselectable,true))},isNotRendered:function(){var g=f(this.area);return g.attr("nohref")||!g.attr("href")||this.effectiveOptions().isMask},effectiveOptions:function(g){var h=d.updateProps({},this.owner.area_options,this.options,g||{},{id:this.areaId});h.selected=this.isSelected();return h},effectiveRenderOptions:function(j,g){var h,i=this.optsCache;if(!i||j==="highlight"){h=this.effectiveOptions(g);i=d.updateProps({},h,h["render_"+j]);if(j!=="highlight"){this.optsCache=i}}return f.extend({},i)},changeState:function(g,h){if(f.isFunction(this.owner.options.onStateChange)){this.owner.options.onStateChange.call(this.owner.image,{key:this.key,state:g,selected:h})}},highlight:function(g){var h=this.owner;if(this.effectiveOptions().highlight){h.graphics.addShapeGroup(this,"highlight",g)}h.setHighlightId(this.areaId);this.changeState("highlight",true)},drawSelection:function(){this.owner.graphics.addShapeGroup(this,"select")}};c.MapArea=function(g,h,j){if(!g){return}var i=this;i.owner=g;i.area=h;i.areaDataXref=[];i.originalCoords=[];f.each(d.split(h.coords),function(k,l){i.originalCoords.push(parseFloat(l))});i.length=i.originalCoords.length;i.shape=h.shape.toLowerCase();i.nohref=h.nohref||!h.href;i.configure(j)};c.MapArea.prototype={constructor:c.MapArea,configure:function(g){this.keys=d.split(g)},reset:function(){this.area=null},coords:function(g){return f.map(this.originalCoords,function(h){return g?h:h+g})}}}(jQuery));(function(b){var a=b.mapster.utils;a.areaCorners=function(p,r,o,s,q){var i,n,D,B,C,A,y,w,v,t,l,k,E,u,e=0,d=0,h,f,m,g,z,c,x=[];p=p.length?p:[p];o=o?b(o):b(document.body);i=o.offset();h=i.left;f=i.top;if(r){i=b(r).offset();e=i.left;d=i.top}for(u=0;u<p.length;u++){c=p[u];if(c.nodeName==="AREA"){m=a.split(c.coords,parseInt);switch(c.shape){case"circle":l=m[0];k=m[1];g=m[2];x=[];for(u=0;u<360;u+=20){z=u*Math.PI/180;x.push(l+g*Math.cos(z),k+g*Math.sin(z))}break;case"rect":x.push(m[0],m[1],m[2],m[1],m[2],m[3],m[0],m[3]);break;default:x=x.concat(m);break}for(u=0;u<x.length;u+=2){x[u]=parseInt(x[u],10)+e;x[u+1]=parseInt(x[u+1],10)+d}}else{c=b(c);i=c.position();x.push(i.left,i.top,i.left+c.width(),i.top,i.left+c.width(),i.top+c.height(),i.left,i.top+c.height())}}D=B=y=v=999999;C=A=w=t=-1;for(u=x.length-2;u>=0;u-=2){l=x[u];k=x[u+1];if(l<D){D=l;t=k}if(l>C){C=l;v=k}if(k<B){B=k;w=l}if(k>A){A=k;y=l}}if(s&&q){n=false;b.each([[w-s,B-q],[y,B-q],[D-s,t-q],[D-s,v],[C,t-q],[C,v],[w-s,A],[y,A]],function(j,F){if(!n&&(F[0]>h&&F[1]>f)){E=F;n=true;return false}});if(!n){E=[C,A]}}return E}}(jQuery));(function(c){var a=c.mapster,b=a.utils,d=a.MapArea.prototype;a.utils.getScaleInfo=function(e,g){var f;if(!g){f=1;g=e}else{f=e.width/g.width||e.height/g.height;if(f>0.98&&f<1.02){f=1}}return{scale:(f!==1),scalePct:f,realWidth:g.width,realHeight:g.height,width:e.width,height:e.height,ratio:e.width/e.height}};a.utils.scaleMap=function(h,f,i){var g=b.size(h),e=b.size(f,true);if(!e.complete()){throw ("Another script, such as an extension, appears to be interfering with image loading. Please let us know about this.")}if(!g.complete()){g=e}return this.getScaleInfo(g,i?e:null)};a.MapData.prototype.resize=function(g,t,j,s){var f,r,i,k,e,n,o=this;s=s||j;function q(u,p,v){if(a.hasCanvas()){u.width=p;u.height=v}else{c(u).width(p);c(u).height(v)}}function l(){o.currentAction="";if(c.isFunction(s)){s()}o.processCommandQueue()}function m(){q(o.overlay_canvas,g,t);if(e>=0){var p=o.data[e];p.tempOptions={fade:false};o.getDataForKey(p.key).highlight();p.tempOptions=null}q(o.base_canvas,g,t);o.redrawSelections();l()}function h(){c(o.image).css(i);o.scaleInfo=b.getScaleInfo({width:g,height:t},{width:o.scaleInfo.realWidth,height:o.scaleInfo.realHeight});c.each(o.data,function(p,u){c.each(u.areas(),function(v,w){w.resize()})})}if(o.scaleInfo.width===g&&o.scaleInfo.height===t){return}e=o.highlightId;if(!g){n=t/o.scaleInfo.realHeight;g=Math.round(o.scaleInfo.realWidth*n)}if(!t){n=g/o.scaleInfo.realWidth;t=Math.round(o.scaleInfo.realHeight*n)}i={width:String(g)+"px",height:String(t)+"px"};if(!a.hasCanvas()){c(o.base_canvas).children().remove()}k=c(o.wrapper).find(".mapster_el").add(o.wrapper);if(j){r=[];o.currentAction="resizing";k.each(function(p,u){f=b.defer();r.push(f);c(u).animate(i,{duration:j,complete:f.resolve,easing:"linear"})});f=b.defer();r.push(f);b.when.all(r).then(m);h();f.resolve()}else{k.css(i);h();m()}};a.MapArea=b.subclass(a.MapArea,function(){this.base.init();if(this.owner.scaleInfo.scale){this.resize()}});d.coords=function(f,i){var e,h=[],g=f||this.owner.scaleInfo.scalePct,k=i||0;if(g===1&&i===0){return this.originalCoords}for(e=0;e<this.length;e++){h.push(Math.round(this.originalCoords[e]*g)+k)}return h};d.resize=function(){this.area.coords=this.coords().join(",")};d.reset=function(){this.area.coords=this.coords(1).join(",")};a.impl.resize=function(g,f,h,i){if(!g&&!f){return false}var e=(new a.Method(this,function(){this.resize(g,f,h,i)},null,{name:"resize",args:arguments})).go();return e}}(jQuery));(function(g){var a=g.mapster,d=a.utils;g.extend(a.defaults,{toolTipContainer:'<div style="border: 2px solid black; background: #EEEEEE; width:160px; padding:4px; margin: 4px; -moz-box-shadow: 3px 3px 5px #535353; -webkit-box-shadow: 3px 3px 5px #535353; box-shadow: 3px 3px 5px #535353; -moz-border-radius: 6px 6px 6px 6px; -webkit-border-radius: 6px; border-radius: 6px 6px 6px 6px; opacity: 0.9;"></dteniv>',showToolTip:false,toolTipFade:true,toolTipClose:["area-mouseout","image-mouseout"],onShowToolTip:null,onHideToolTip:null});g.extend(a.area_defaults,{toolTip:null,toolTipClose:null});function e(j,k,i){var l;if(k){l=typeof k==="string"?g(k):g(k).clone();l.append(j)}else{l=g(j)}l.css(g.extend((i||{}),{display:"block",position:"absolute"})).hide();g("body").append(l);l.attr("data-opacity",l.css("opacity")).css("opacity",0);return l.show()}function h(m,k){var i={left:k.left+"px",top:k.top+"px"},j=m.attr("data-opacity")||0,l=m.css("z-index");if(parseInt(l,10)===0||l==="auto"){i["z-index"]=9999}m.css(i).addClass("mapster_tooltip");if(k.fadeDuration&&k.fadeDuration>0){d.fader(m[0],0,j,k.fadeDuration)}else{d.setOpacity(m[0],j)}}a.MapData.prototype.clearToolTip=function(){if(this.activeToolTip){this.activeToolTip.stop().remove();this.activeToolTip=null;this.activeToolTipID=null;d.ifFunction(this.options.onHideToolTip,this)}};function b(k,i,l,o,m,j){var n=l+".mapster-tooltip";if(g.inArray(i,k)>=0){o.unbind(n).bind(n,function(p){if(!m||m.call(this,p)){o.unbind(".mapster-tooltip");if(j){j.call(this)}}});return{object:o,event:n}}}function f(m,o,n,i,k){var j,l={};k=k||{};if(o){j=d.areaCorners(o,n,i,m.outerWidth(true),m.outerHeight(true));l.left=j[0];l.top=j[1]}else{l.left=k.left;l.top=k.top}l.left+=(k.offsetx||0);l.top+=(k.offsety||0);l.css=k.css;l.fadeDuration=k.fadeDuration;h(m,l);return m}a.AreaData.prototype.showToolTip=function(m,s){var r,j,l,n,p,k={},q=this,o=q.owner,i=q.effectiveOptions();s=s?g.extend({},s):{};m=m||i.toolTip;j=s.closeEvents||i.toolTipClose||o.options.toolTipClose||"tooltip-click";p=typeof s.template!=="undefined"?s.template:o.options.toolTipContainer;s.closeEvents=typeof j==="string"?j=d.split(j):j;s.fadeDuration=s.fadeDuration||(o.options.toolTipFade?(o.options.fadeDuration||i.fadeDuration):0);l=q.area?q.area:g.map(q.areas(),function(t){return t.area});if(o.activeToolTipID===q.areaId){return}o.clearToolTip();o.activeToolTip=r=e(m,p,s.css);o.activeToolTipID=q.areaId;n=function(){o.clearToolTip()};b(j,"area-click","click",g(o.map),null,n);b(j,"tooltip-click","click",r,null,n);b(j,"image-mouseout","mouseout",g(o.image),function(t){return(t.relatedTarget&&t.relatedTarget.nodeName!=="AREA"&&t.relatedTarget!==q.area)},n);f(r,l,o.image,s.container,p,s);d.ifFunction(o.options.onShowToolTip,q.area,{toolTip:r,options:k,areaOptions:i,key:q.key,selected:q.isSelected()});return r};function c(i){return(i?((typeof i==="string"||i.jquery)?i:i.content):null)}a.impl.tooltip=function(k,j){return(new a.Method(this,function l(){var n,o,m=this;if(!k){m.clearToolTip()}else{o=g(k);if(m.activeToolTipID===o[0]){return}m.clearToolTip();m.activeToolTip=n=e(c(j),j.template||m.options.toolTipContainer,j.css);m.activeToolTipID=o[0];b(["tooltip-click"],"tooltip-click","click",n,null,function(){m.clearToolTip()});m.activeToolTip=n=f(n,o,m.image,j.container,j)}},function i(){if(g.isPlainObject(k)&&!j){j=k}this.showToolTip(c(j),j)},{name:"tooltip",args:arguments,key:k})).go()}}(jQuery));
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/js/pyams_content.js	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,665 @@
+(function($, globals) {
+
+	"use strict";
+
+	var MyAMS = globals.MyAMS;
+
+	var PyAMS_content = {
+
+		/**
+		 * Custom widgets management
+		 */
+		widget: {
+
+			/** Treeview widget */
+			treeview: {
+
+				selectFolder: function(event, node) {
+					var target = $(event.target);
+					target.siblings('input[type="hidden"]').val(node.id);
+				},
+
+				unselectFolder: function(event, node) {
+					var target = $(event.target);
+					target.siblings('input[type="hidden"]').val(null);
+				}
+			}
+		},
+
+		/**
+		 * TinyMCE editor configuration
+		 */
+		TinyMCE: {
+
+			initEditor: function(settings) {
+
+				// Update TinyMCE translations
+				tinyMCE.addI18n('fr', {
+					"Link list": "Liste de liens",
+					"Toggle h3 header": "En-tête H3",
+					"Toggle h4 header": "En-tête H4",
+					"Insert internal link": "Insérer un lien interne",
+					"Link title": "Texte à afficher",
+					"Internal number": "N° interne"
+				});
+
+				// Declare internal link input plug-in
+				tinymce.PluginManager.add('internal_links', function(editor, url) {
+					editor.addButton('internal_links', {
+						icon: 'cloud-check',
+						tooltip: "Insert internal link",
+						image: '/--static--/pyams_content/img/internal-link.png',
+						onclick: function() {
+							editor.windowManager.open({
+								title: "Insert internal link",
+								body: [
+									{
+										type: 'textbox',
+										name: 'oid',
+										label:'Internal number'
+									}, {
+										type: 'textbox',
+										name: 'title',
+										label: 'Link title',
+										value: editor.selection.getContent()
+									}
+								],
+								onsubmit: function(e) {
+									editor.insertContent('<a href="oid://' + e.data.oid + '">' + e.data.title + '</a>');
+								}
+							});
+						}
+					})
+				});
+
+				// Declare direct H3 and H4 style formatter
+				tinyMCE.PluginManager.add('headers', function (editor, url) {
+					['h3', 'h4'].forEach(function (name) {
+						editor.addButton("header-" + name, {
+							tooltip: "Toggle " + name + " header",
+							text: name.toUpperCase(),
+							onClick: function () {
+								editor.execCommand('mceToggleFormat', false, name);
+							},
+							onPostRender: function () {
+								var self = this,
+									setup = function () {
+										editor.formatter.formatChanged(name, function (state) {
+											self.active(state);
+										});
+									};
+								editor.formatter ? setup() : editor.on('init', setup);
+							}
+						})
+					});
+				});
+
+				// Update TinyMCE settings
+				settings.image_list = PyAMS_content.TinyMCE.getImagesList;
+				settings.link_list = PyAMS_content.TinyMCE.getLinksList;
+				settings.style_formats = [
+					{
+						title: 'Inline',
+						items: [
+							{title: 'Bold', icon: 'bold', format: 'bold'},
+							{title: 'Italic', icon: 'italic', format: 'italic'},
+							{title: 'Underline', icon: 'underline', format: 'underline'},
+							{title: 'Strikethrough', icon: 'strikethrough', format: 'strikethrough'},
+							{title: 'Superscript', icon: 'superscript', format: 'superscript'},
+							{title: 'Subscript', icon: 'subscript', format: 'subscript'},
+							{title: 'Code', icon: 'code', format: 'code'}
+						]
+					},
+					{
+						title: 'Blocks',
+						items: [
+							{title: 'Paragraph', format: 'p'},
+							{title: 'Blockquote', format: 'blockquote'},
+							{title: 'Div', format: 'div'},
+							{title: 'Pre', format: 'pre'}
+						]
+					},
+					{
+						title: 'Alignment',
+						items: [
+							{title: 'Left', icon: 'alignleft', format: 'alignleft'},
+							{title: 'Center', icon: 'aligncenter', format: 'aligncenter'},
+							{title: 'Right', icon: 'alignright', format: 'alignright'},
+							{title: 'Justify', icon: 'alignjustify', format: 'alignjustify'}
+						]
+					}
+				];
+				settings.plugins += ' internal_links headers';
+				if (settings.toolbar1) {
+					settings.toolbar1 = "undo redo | header-h3 header-h4 styleselect | bold italic | " +
+										"alignleft aligncenter alignright alignjustify | bullist numlist outdent indent";
+				}
+				if (settings.toolbar2) {
+					settings.toolbar2 = "forecolor backcolor | charmap internal_links link | fullscreen preview print | code";
+				}
+				return settings;
+			},
+
+			getImagesList: function(callback) {
+				var form = $(document.activeElement).parents('form');
+				if (form.exists()) {
+					var base = form.attr('data-ams-form-handler') || form.attr('action');
+					var target = base.substr(0, base.lastIndexOf('/') + 1);
+					return MyAMS.ajax.post(target + 'get-images-list.json', {}, callback);
+				}
+			},
+
+			getLinksList: function(callback) {
+				var form = $(document.activeElement).parents('form');
+				if (form.exists()) {
+					var base = form.attr('data-ams-form-handler') || form.attr('action');
+					var target = base.substr(0, base.lastIndexOf('/')+1);
+					return MyAMS.ajax.post(target + 'get-links-list.json', {}, callback);
+				}
+			}
+		},
+
+		/**
+		 * Galleries management
+		 */
+		galleries: {
+
+			addMediaCallback: function(options) {
+				var gallery = $('.gallery', $('[id="' + options.parent + '"]'));
+				var switcher = gallery.siblings('.switcher');
+				if (switcher.parents('fieldset:first').hasClass('switched')) {
+					switcher.click();
+				}
+				for (var i=0; i < options.medias.length; i++) {
+					gallery.append(options.medias[i]);
+				}
+				gallery.sortable({
+					helper: 'clone',
+					stop: PyAMS_content.galleries.setOrder
+				})
+			},
+
+			updateMediaTitle: function(options) {
+				$('img[id="' + options.media_id + '"]').attr('original-title', options.title);
+			},
+
+			switchMediaVisibility: function(element) {
+				return function() {
+					var source = $(this);
+					var media = source.parents('.media');
+					var gallery = media.parents('.gallery');
+					$('i', source).attr('class', 'fa fa-fw fa-spinner fa-pulse');
+					MyAMS.ajax.post(gallery.data('ams-location') + '/set-media-visibility.json',
+									{object_name: media.data('ams-element-name')},
+									function(result, status) {
+										if (result.visible) {
+											$('i', source).attr('class', 'fa fa-fw fa-eye');
+											source.parents('.btn-group').siblings('a.fancyimg').removeClass('not-visible');
+										} else {
+											$('i', source).attr('class', 'fa fa-fw fa-eye-slash text-danger');
+											source.parents('.btn-group').siblings('a.fancyimg').addClass('not-visible');
+										}
+									});
+				};
+			},
+
+			setOrder: function(event, ui) {
+				if (ui && ui.item.hasClass('already-dropped')) {
+					return;
+				}
+				var gallery = ui.item.parents('.gallery');
+				var ids = $('.media', gallery).listattr('data-ams-element-name');
+				MyAMS.ajax.post(gallery.data('ams-location') + '/set-medias-order.json',
+								{medias: JSON.stringify(ids)});
+			},
+
+			removeMedia: function(element) {
+				return function() {
+					var link = $(this);
+					MyAMS.skin.bigBox({
+						title: MyAMS.i18n.WARNING,
+						content: '<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; ' + MyAMS.i18n.DELETE_WARNING,
+						buttons: MyAMS.i18n.BTN_OK_CANCEL
+					}, function(button) {
+						if (button === MyAMS.i18n.BTN_OK) {
+							var gallery = link.parents('.gallery');
+							var location = gallery.data('ams-location');
+							var media = link.parents('.media');
+							var object_name = media.data('ams-element-name');
+							MyAMS.ajax.post(location + '/delete-element.json',
+											{object_name: object_name},
+											function(result, status) {
+												media.remove();
+												if (result.handle_json) {
+													MyAMS.ajax.handleJSON(result);
+												}
+											});
+						}
+					});
+				};
+			},
+
+			afterFancyboxLoad: function(current, previous) {
+				var element = current.element;
+				if (element.hasClass('not-visible')) {
+					current.inner.prepend('<div class="hidden-mask"></div>');
+				}
+			}
+		},
+
+		/**
+		 * Illustrations management
+		 */
+		illustration: {
+
+			addIllustration: function() {
+				var source = $(this);
+				var group = source.parents('.btn-group');
+				var legend = group.siblings('legend.switcher');
+				$('i.fa-plus', legend).click();
+				source.hide();
+				$('input[type="file"]', legend.siblings('.form-group:first')).click();
+			}
+		},
+
+		/**
+		 * Paragraphs management
+		 */
+		paragraphs: {
+
+			/* Store and restore paragraphs state on reload */
+			preReload: function() {
+				PyAMS_content.paragraphs.switched = $('i.switch.fa-minus-square-o', '#paragraphs_list').parents('tr').listattr('id');
+			},
+
+			postReload: function() {
+				$(PyAMS_content.paragraphs.switched).each(function() {
+					$('i.switch.fa-plus-square-o', '[id="' + this + '"]').parents('div').first().click();
+				});
+				delete PyAMS_content.paragraphs.switched;
+			},
+
+			refreshParagraph: function(changes) {
+				var para = $('tr[id="' + changes.object_id + '"]');
+				$('span.title', para).html(changes.title || ' - - - - - - - -');
+			},
+
+			switchEditor: function(element) {
+				var source = $(this);
+				var switcher = $('i.switch', source);
+				var td = source.parents('td');
+				var editor = $('.editor', td);
+				var para = source.parents('tr');
+				if (switcher.hasClass('fa-plus-square-o')) {
+					var container = para.parents('table');
+					editor.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>');
+					MyAMS.ajax.post(container.data('ams-location') + '/get-paragraph-editor.json',
+									{object_name: para.data('ams-element-name')},
+									function(result) {
+										editor.html(result);
+										if (result) {
+											MyAMS.initContent(editor);
+											switcher.removeClass('fa-plus-square-o')
+													.addClass('fa-minus-square-o');
+											para.data('ams-disabled-handlers', true);
+											MyAMS.skin.scrollTo(editor, {
+												offset: editor.height() - para.height()
+											});
+										}
+									});
+				} else {
+					MyAMS.skin.cleanContainer(editor);
+					editor.empty();
+					switcher.removeClass('fa-minus-square-o')
+							.addClass('fa-plus-square-o');
+					para.removeData('ams-disabled-handlers');
+				}
+			},
+
+			switchLastEditor: function(table_id) {
+				var table = $('table[id="' + table_id + '"]');
+				var tr = $('tr:last', table);
+				$('[data-ams-click-handler="PyAMS_content.paragraphs.switchEditor"]', tr).click();
+			},
+
+			switchAllEditors: function(element) {
+				var source = $(this);
+				var switcher = $('i', source);
+				var container = source.parents('table');
+				if (switcher.hasClass('fa-plus-square-o')) {
+					switcher.removeClass('fa-plus-square-o')
+							.addClass('fa-cog fa-spin');
+					MyAMS.ajax.post(container.data('ams-location') + '/get-paragraphs-editors.json',
+									{},
+									function(result) {
+										for (var para_id in result) {
+											if (!result.hasOwnProperty(para_id)) {
+												continue;
+											}
+											var para = $('tr[data-ams-element-name="' + para_id + '"]', container);
+											var editor = $('.editor', para);
+											if (editor.is(':empty')) {
+												editor.html(result[para_id]);
+											}
+											$('.fa-plus-square-o', para).removeClass('fa-plus-square-o')
+																		.addClass('fa-minus-square-o');
+											para.data('ams-disabled-handlers', true);
+										}
+										if (!$('i.fa-plus-square-o', $('tbody', container)).exists()) {
+											switcher.removeClass('fa-cog fa-spin')
+													.addClass('fa-minus-square-o');
+										}
+										MyAMS.initContent(container);
+									});
+				} else {
+					$('.editor', container).each(function() {
+						MyAMS.skin.cleanContainer($(this));
+						$(this).empty();
+					});
+					$('.fa-minus-square-o', container).removeClass('fa-minus-square-o')
+													  .addClass('fa-plus-square-o');
+					$('tr', container).removeData('ams-disabled-handlers');
+				}
+			},
+
+			updateToolbar: function(settings) {
+				var para = $('tr[id="' + settings.object_id + '"]');
+				var toolbar = $('.title-toolbar', para);
+				toolbar.replaceWith(settings.toolbar_tag);
+				toolbar = $('.title-toolbar', para);
+				MyAMS.initContent(toolbar);
+			},
+
+			updateMarkers: function(settings) {
+				var para = $('tr[id="' + settings.object_id + '"]');
+				var toolbar = $('.title-toolbar', para);
+				var marker = $('DIV.action.' + settings.marker_type, toolbar);
+				if (marker.exists()) {
+					marker.replaceWith(settings.marker_tag);
+				} else {
+					$(settings.marker_tag).appendTo(toolbar);
+				}
+				if (settings.marker_tag) {
+					marker = $('DIV.action.' + settings.marker_type, toolbar);
+					MyAMS.initContent(marker);
+				}
+				MyAMS.helpers.sort(toolbar, 'weight');
+			}
+		},
+
+		/**
+		 * Pictograms management
+		 */
+		pictograms: {
+
+			initManagerSelection: function() {
+				var form = $(this);
+				var selected = $('input[type="hidden"]', $('.selected-pictograms', form)).listattr('value');
+				return {
+					selected: JSON.stringify(selected)
+				};
+			},
+
+			switchPictogram: function() {
+				var pictogram = $(this);
+				var parent = pictogram.parents('.pictograms');
+				var manager = parent.parents('.pictograms-manager');
+				if (parent.hasClass('available-pictograms')) {
+					$('.selected-pictograms', manager).append(pictogram);
+				} else {
+					$('.available-pictograms', manager).append(pictogram);
+				}
+			}
+		},
+
+		/**
+		 * Themes management
+		 */
+		themes: {
+
+			initExtracts: function(element) {
+				var thesaurus = $('select[name="manager_themes.widgets.thesaurus_name:list"]', element);
+				var thesaurus_name = thesaurus.val();
+				var extract = $('select[name="manager_themes.widgets.extract_name:list"]', element);
+				var extract_name = extract.val();
+				if (thesaurus_name) {
+					MyAMS.jsonrpc.post('getExtracts',
+									   {thesaurus_name: thesaurus_name},
+									   {url: '/api/thesaurus/json'},
+									   function(data) {
+											extract.empty();
+											$(data.result).each(function() {
+												$('<option></option>').attr('value', this.id)
+																	  .attr('selected', this.id === extract_name)
+																	  .text(this.text)
+																	  .appendTo(extract);
+											});
+									   });
+				}
+			},
+
+			getExtracts: function(event) {
+				var select = $(event.currentTarget);
+				var form = select.parents('form');
+				var thesaurus_name = $('select[name="manager_themes.widgets.thesaurus_name:list"]', form).val();
+				var extract = $('select[name="manager_themes.widgets.extract_name:list"]', form);
+				var plugin = extract.data('select2');
+				if (thesaurus_name && (thesaurus_name !== '--NOVALUE--')) {
+					MyAMS.jsonrpc.post('getExtracts',
+									   {thesaurus_name: thesaurus_name},
+									   {url: '/api/thesaurus/json'},
+									   function(data) {
+											plugin.results.empty();
+											plugin.opts.populateResults.call(plugin, plugin.results, data.result,
+																			 {term: ''});
+									   });
+				} else {
+					extract.select2('data', null);
+					plugin.results.empty();
+					plugin.opts.populateResults.call(plugin, plugin.results, [], {term: ''});
+				}
+			}
+		},
+
+		/**
+		 * Form fields management
+		 */
+		fields: {
+
+			refreshField: function(changes) {
+				var container = $('table[id="form_fields_list"]');
+				var para = $('tr[data-ams-element-name="' + changes.object_name + '"]', container);
+				$('td:nth-child(4)', para).html(changes.title);
+			}
+		},
+
+		/**
+		 * Image map management
+		 */
+		imgmap: {
+
+			init: function() {
+				var image = $(this);
+				MyAMS.ajax.check($.fn.canvasAreaDraw,
+								 '/--static--/pyams_content/js/jquery-canvasAreaDraw' + MyAMS.devext + '.js',
+								 function() {
+									image.canvasAreaDraw({imageUrl: image.data('ams-image-url')});
+								 });
+			},
+
+			initPreview: function() {
+				var image = $(this);
+				MyAMS.ajax.check($.fn.mapster,
+								 '/--static--/pyams_content/js/jquery-imagemapster-1.2.10' + MyAMS.devext + '.js',
+								 function() {
+									image.mapster({
+										fillColor: 'ff0000',
+										fillOpacity: 0.35,
+										selected: true,
+										highlight: true,
+										staticState: true
+									});
+								 });
+			}
+		},
+
+		/**
+		 * Site management
+		 */
+		site: {
+
+			switchVisibility: function() {
+				return function() {
+					var source = $(this);
+					var content = source.parents('tr').first();
+					MyAMS.ajax.post(content.data('ams-location') + '/switch-content-visibility.json',
+									{object_name: content.data('ams-element-name')},
+									function(result, status) {
+										var klass = 'fa-eye';
+										if (!result.visible) {
+											klass += '-slash';
+										}
+										if (!result.published) {
+											klass += ' text-danger';
+										}
+										$('i', source).attr('class', 'fa fa-fw ' + klass);
+									});
+				};
+			}
+		},
+
+		/**
+		 * Review comments management
+		 */
+		review: {
+
+			timer: null,
+			timer_duration: {
+				general: 30000,
+				chat: 5000
+			},
+
+			initComments: function(element) {
+				var chat = $('.chat-body', element);
+				chat.animate({scrollTop: chat[0].scrollHeight}, 1000);
+				clearInterval(PyAMS_content.review.timer);
+				PyAMS_content.review.timer = setInterval(PyAMS_content.review.updateComments,
+														 PyAMS_content.review.timer_duration.chat);
+				MyAMS.skin.registerCleanCallback(PyAMS_content.review.cleanCommentsCallback);
+			},
+
+			cleanCommentsCallback: function() {
+				clearInterval(PyAMS_content.review.timer);
+				PyAMS_content.review.timer = setInterval(PyAMS_content.review.updateComments,
+														 PyAMS_content.review.timer_duration.general);
+			},
+
+			updateComments: function() {
+				var badge = $('.badge', 'nav a[href="#review-comments.html"]'),
+					count;
+				var chat = $('.chat-body', '.widget-body');
+				if (chat.exists()) {
+					count = $('.message', chat).length;
+				} else {
+					count = parseInt(badge.text());
+				}
+				MyAMS.ajax.post('get-last-review-comments.json', {count: count}, function(result) {
+					if (chat.exists()) {
+						badge.removeClass('bg-color-danger')
+							 .addClass('bg-color-info');
+					}
+					if (count !== result.count) {
+						badge.text(result.count).removeClass('hidden');
+						if (chat.exists()) {
+							$('.messages', chat).append(result.content);
+							chat.animate({scrollTop: chat[0].scrollHeight}, 1000);
+						}
+						if (!chat.exists()) {
+							badge.removeClass('bg-color-info')
+								 .addClass('bg-color-danger')
+								 .animate({'padding': '3px 12px 2px',
+										   'margin-right': '9px'}, 'slow', function() {
+									$(this).animate({'padding': '3px 6px 2px',
+													 'margin-right': '15px'}, 'slow');
+								 });
+						}
+					}
+				});
+			},
+
+			initCommentData: function(veto) {
+				var chat = $('.chat-body', '.widget-body');
+				return {count: $('.message', chat).length};
+			},
+
+			addCommentAction: function() {
+				return function() {
+					$('textarea[name="comment"]').focus();
+				};
+			},
+
+			addCommentCallback: function(options) {
+				var form = $(this);
+				var widget = form.parents('.widget-body');
+				$('.messages', widget).append(options.content);
+				$('textarea[name="comment"]', form).val('');
+				var chat = $('.chat-body', widget);
+				chat.animate({scrollTop: chat[0].scrollHeight}, 1000);
+				$('.badge', 'nav a[href="#review-comments.html"]').text(options.count).removeClass('hidden');
+			}
+		},
+
+		/**
+		 * Header management
+		 */
+		header: {
+
+			submitEditForm: function() {
+				var form = $(this).parents('form').first();
+				MyAMS.form.submit(form, {form_data: {'autosubmit': true}});
+			}
+		},
+
+		/**
+		 * Footer management
+		 */
+		footer: {
+
+			submitEditForm: function() {
+				var form = $(this).parents('form').first();
+				MyAMS.form.submit(form, {form_data: {'autosubmit': true}});
+			}
+		},
+
+		/**
+		 * User profile management
+		 */
+		profile: {
+
+			switchFavorite: function() {
+				var star = $(this);
+				var oid = star.data('sequence-oid');
+				MyAMS.ajax.post('switch-user-favorite.json',
+								{oid: oid},
+								function(result, status) {
+									if (result.favorite) {
+										star.removeClass('fa-star-o')
+											.addClass('fa-star');
+									} else {
+										star.removeClass('fa-star')
+											.addClass('fa-star-o');
+									}
+								});
+			}
+		}
+	};
+
+	var badge = $('.badge', 'nav a[href="#review-comments.html"]');
+	if (badge.exists()) {
+		PyAMS_content.review.timer = setInterval(PyAMS_content.review.updateComments,
+												 PyAMS_content.review.timer_duration.general);
+	}
+
+	globals.PyAMS_content = PyAMS_content;
+
+})(jQuery, this);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/js/pyams_content.min.js	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,1 @@
+!function(t,e){"use strict";var a=e.MyAMS,i={widget:{treeview:{selectFolder:function(e,a){t(e.target).siblings('input[type="hidden"]').val(a.id)},unselectFolder:function(e,a){t(e.target).siblings('input[type="hidden"]').val(null)}}},TinyMCE:{initEditor:function(t){return tinyMCE.addI18n("fr",{"Link list":"Liste de liens","Toggle h3 header":"En-tête H3","Toggle h4 header":"En-tête H4","Insert internal link":"Insérer un lien interne","Link title":"Texte à afficher","Internal number":"N° interne"}),tinymce.PluginManager.add("internal_links",function(t,e){t.addButton("internal_links",{icon:"cloud-check",tooltip:"Insert internal link",image:"/--static--/pyams_content/img/internal-link.png",onclick:function(){t.windowManager.open({title:"Insert internal link",body:[{type:"textbox",name:"oid",label:"Internal number"},{type:"textbox",name:"title",label:"Link title",value:t.selection.getContent()}],onsubmit:function(e){t.insertContent('<a href="oid://'+e.data.oid+'">'+e.data.title+"</a>")}})}})}),tinyMCE.PluginManager.add("headers",function(t,e){["h3","h4"].forEach(function(e){t.addButton("header-"+e,{tooltip:"Toggle "+e+" header",text:e.toUpperCase(),onClick:function(){t.execCommand("mceToggleFormat",!1,e)},onPostRender:function(){var a=this,i=function(){t.formatter.formatChanged(e,function(t){a.active(t)})};t.formatter?i():t.on("init",i)}})})}),t.image_list=i.TinyMCE.getImagesList,t.link_list=i.TinyMCE.getLinksList,t.style_formats=[{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}],t.plugins+=" internal_links headers",t.toolbar1&&(t.toolbar1="undo redo | header-h3 header-h4 styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"),t.toolbar2&&(t.toolbar2="forecolor backcolor | charmap internal_links link | fullscreen preview print | code"),t},getImagesList:function(e){var i=t(document.activeElement).parents("form");if(i.exists()){var n=i.attr("data-ams-form-handler")||i.attr("action"),s=n.substr(0,n.lastIndexOf("/")+1);return a.ajax.post(s+"get-images-list.json",{},e)}},getLinksList:function(e){var i=t(document.activeElement).parents("form");if(i.exists()){var n=i.attr("data-ams-form-handler")||i.attr("action"),s=n.substr(0,n.lastIndexOf("/")+1);return a.ajax.post(s+"get-links-list.json",{},e)}}},galleries:{addMediaCallback:function(e){var a=t(".gallery",t('[id="'+e.parent+'"]')),n=a.siblings(".switcher");n.parents("fieldset:first").hasClass("switched")&&n.click();for(var s=0;s<e.medias.length;s++)a.append(e.medias[s]);a.sortable({helper:"clone",stop:i.galleries.setOrder})},updateMediaTitle:function(e){t('img[id="'+e.media_id+'"]').attr("original-title",e.title)},switchMediaVisibility:function(e){return function(){var e=t(this),i=e.parents(".media"),n=i.parents(".gallery");t("i",e).attr("class","fa fa-fw fa-spinner fa-pulse"),a.ajax.post(n.data("ams-location")+"/set-media-visibility.json",{object_name:i.data("ams-element-name")},function(a,i){a.visible?(t("i",e).attr("class","fa fa-fw fa-eye"),e.parents(".btn-group").siblings("a.fancyimg").removeClass("not-visible")):(t("i",e).attr("class","fa fa-fw fa-eye-slash text-danger"),e.parents(".btn-group").siblings("a.fancyimg").addClass("not-visible"))})}},setOrder:function(e,i){if(!i||!i.item.hasClass("already-dropped")){var n=i.item.parents(".gallery"),s=t(".media",n).listattr("data-ams-element-name");a.ajax.post(n.data("ams-location")+"/set-medias-order.json",{medias:JSON.stringify(s)})}},removeMedia:function(e){return function(){var e=t(this);a.skin.bigBox({title:a.i18n.WARNING,content:'<i class="text-danger fa fa-2x fa-bell shake animated"></i>&nbsp; '+a.i18n.DELETE_WARNING,buttons:a.i18n.BTN_OK_CANCEL},function(t){if(t===a.i18n.BTN_OK){var i=e.parents(".gallery").data("ams-location"),n=e.parents(".media"),s=n.data("ams-element-name");a.ajax.post(i+"/delete-element.json",{object_name:s},function(t,e){n.remove(),t.handle_json&&a.ajax.handleJSON(t)})}})}},afterFancyboxLoad:function(t,e){t.element.hasClass("not-visible")&&t.inner.prepend('<div class="hidden-mask"></div>')}},illustration:{addIllustration:function(){var e=t(this),a=e.parents(".btn-group").siblings("legend.switcher");t("i.fa-plus",a).click(),e.hide(),t('input[type="file"]',a.siblings(".form-group:first")).click()}},paragraphs:{preReload:function(){i.paragraphs.switched=t("i.switch.fa-minus-square-o","#paragraphs_list").parents("tr").listattr("id")},postReload:function(){t(i.paragraphs.switched).each(function(){t("i.switch.fa-plus-square-o",'[id="'+this+'"]').parents("div").first().click()}),delete i.paragraphs.switched},refreshParagraph:function(e){var a=t('tr[id="'+e.object_id+'"]');t("span.title",a).html(e.title||" - - - - - - - -")},switchEditor:function(e){var i=t(this),n=t("i.switch",i),s=i.parents("td"),r=t(".editor",s),o=i.parents("tr");if(n.hasClass("fa-plus-square-o")){var l=o.parents("table");r.html('<h1 class="loading"><i class="fa fa-2x fa-gear fa-spin"></i></h1>'),a.ajax.post(l.data("ams-location")+"/get-paragraph-editor.json",{object_name:o.data("ams-element-name")},function(t){r.html(t),t&&(a.initContent(r),n.removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),o.data("ams-disabled-handlers",!0),a.skin.scrollTo(r,{offset:r.height()-o.height()}))})}else a.skin.cleanContainer(r),r.empty(),n.removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),o.removeData("ams-disabled-handlers")},switchLastEditor:function(e){var a=t('table[id="'+e+'"]'),i=t("tr:last",a);t('[data-ams-click-handler="PyAMS_content.paragraphs.switchEditor"]',i).click()},switchAllEditors:function(e){var i=t(this),n=t("i",i),s=i.parents("table");n.hasClass("fa-plus-square-o")?(n.removeClass("fa-plus-square-o").addClass("fa-cog fa-spin"),a.ajax.post(s.data("ams-location")+"/get-paragraphs-editors.json",{},function(e){for(var i in e)if(e.hasOwnProperty(i)){var r=t('tr[data-ams-element-name="'+i+'"]',s),o=t(".editor",r);o.is(":empty")&&o.html(e[i]),t(".fa-plus-square-o",r).removeClass("fa-plus-square-o").addClass("fa-minus-square-o"),r.data("ams-disabled-handlers",!0)}t("i.fa-plus-square-o",t("tbody",s)).exists()||n.removeClass("fa-cog fa-spin").addClass("fa-minus-square-o"),a.initContent(s)})):(t(".editor",s).each(function(){a.skin.cleanContainer(t(this)),t(this).empty()}),t(".fa-minus-square-o",s).removeClass("fa-minus-square-o").addClass("fa-plus-square-o"),t("tr",s).removeData("ams-disabled-handlers"))},updateToolbar:function(e){var i=t('tr[id="'+e.object_id+'"]'),n=t(".title-toolbar",i);n.replaceWith(e.toolbar_tag),n=t(".title-toolbar",i),a.initContent(n)},updateMarkers:function(e){var i=t('tr[id="'+e.object_id+'"]'),n=t(".title-toolbar",i),s=t("DIV.action."+e.marker_type,n);s.exists()?s.replaceWith(e.marker_tag):t(e.marker_tag).appendTo(n),e.marker_tag&&(s=t("DIV.action."+e.marker_type,n),a.initContent(s)),a.helpers.sort(n,"weight")}},pictograms:{initManagerSelection:function(){var e=t(this),a=t('input[type="hidden"]',t(".selected-pictograms",e)).listattr("value");return{selected:JSON.stringify(a)}},switchPictogram:function(){var e=t(this),a=e.parents(".pictograms"),i=a.parents(".pictograms-manager");a.hasClass("available-pictograms")?t(".selected-pictograms",i).append(e):t(".available-pictograms",i).append(e)}},themes:{initExtracts:function(e){var i=t('select[name="manager_themes.widgets.thesaurus_name:list"]',e).val(),n=t('select[name="manager_themes.widgets.extract_name:list"]',e),s=n.val();i&&a.jsonrpc.post("getExtracts",{thesaurus_name:i},{url:"/api/thesaurus/json"},function(e){n.empty(),t(e.result).each(function(){t("<option></option>").attr("value",this.id).attr("selected",this.id===s).text(this.text).appendTo(n)})})},getExtracts:function(e){var i=t(e.currentTarget).parents("form"),n=t('select[name="manager_themes.widgets.thesaurus_name:list"]',i).val(),s=t('select[name="manager_themes.widgets.extract_name:list"]',i),r=s.data("select2");n&&"--NOVALUE--"!==n?a.jsonrpc.post("getExtracts",{thesaurus_name:n},{url:"/api/thesaurus/json"},function(t){r.results.empty(),r.opts.populateResults.call(r,r.results,t.result,{term:""})}):(s.select2("data",null),r.results.empty(),r.opts.populateResults.call(r,r.results,[],{term:""}))}},fields:{refreshField:function(e){var a=t('table[id="form_fields_list"]'),i=t('tr[data-ams-element-name="'+e.object_name+'"]',a);t("td:nth-child(4)",i).html(e.title)}},imgmap:{init:function(){var e=t(this);a.ajax.check(t.fn.canvasAreaDraw,"/--static--/pyams_content/js/jquery-canvasAreaDraw"+a.devext+".js",function(){e.canvasAreaDraw({imageUrl:e.data("ams-image-url")})})},initPreview:function(){var e=t(this);a.ajax.check(t.fn.mapster,"/--static--/pyams_content/js/jquery-imagemapster-1.2.10"+a.devext+".js",function(){e.mapster({fillColor:"ff0000",fillOpacity:.35,selected:!0,highlight:!0,staticState:!0})})}},site:{switchVisibility:function(){return function(){var e=t(this),i=e.parents("tr").first();a.ajax.post(i.data("ams-location")+"/switch-content-visibility.json",{object_name:i.data("ams-element-name")},function(a,i){var n="fa-eye";a.visible||(n+="-slash"),a.published||(n+=" text-danger"),t("i",e).attr("class","fa fa-fw "+n)})}}},review:{timer:null,timer_duration:{general:3e4,chat:5e3},initComments:function(e){var n=t(".chat-body",e);n.animate({scrollTop:n[0].scrollHeight},1e3),clearInterval(i.review.timer),i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.chat),a.skin.registerCleanCallback(i.review.cleanCommentsCallback)},cleanCommentsCallback:function(){clearInterval(i.review.timer),i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.general)},updateComments:function(){var e,i=t(".badge",'nav a[href="#review-comments.html"]'),n=t(".chat-body",".widget-body");e=n.exists()?t(".message",n).length:parseInt(i.text()),a.ajax.post("get-last-review-comments.json",{count:e},function(a){n.exists()&&i.removeClass("bg-color-danger").addClass("bg-color-info"),e!==a.count&&(i.text(a.count).removeClass("hidden"),n.exists()&&(t(".messages",n).append(a.content),n.animate({scrollTop:n[0].scrollHeight},1e3)),n.exists()||i.removeClass("bg-color-info").addClass("bg-color-danger").animate({padding:"3px 12px 2px","margin-right":"9px"},"slow",function(){t(this).animate({padding:"3px 6px 2px","margin-right":"15px"},"slow")}))})},initCommentData:function(e){var a=t(".chat-body",".widget-body");return{count:t(".message",a).length}},addCommentAction:function(){return function(){t('textarea[name="comment"]').focus()}},addCommentCallback:function(e){var a=t(this),i=a.parents(".widget-body");t(".messages",i).append(e.content),t('textarea[name="comment"]',a).val("");var n=t(".chat-body",i);n.animate({scrollTop:n[0].scrollHeight},1e3),t(".badge",'nav a[href="#review-comments.html"]').text(e.count).removeClass("hidden")}},header:{submitEditForm:function(){var e=t(this).parents("form").first();a.form.submit(e,{form_data:{autosubmit:!0}})}},footer:{submitEditForm:function(){var e=t(this).parents("form").first();a.form.submit(e,{form_data:{autosubmit:!0}})}},profile:{switchFavorite:function(){var e=t(this),i=e.data("sequence-oid");a.ajax.post("switch-user-favorite.json",{oid:i},function(t,a){t.favorite?e.removeClass("fa-star-o").addClass("fa-star"):e.removeClass("fa-star").addClass("fa-star-o")})}}};t(".badge",'nav a[href="#review-comments.html"]').exists()&&(i.review.timer=setInterval(i.review.updateComments,i.review.timer_duration.general)),e.PyAMS_content=i}(jQuery,this);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/js/tinymce/onflinks/langs/fr.js	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,5 @@
+tinyMCE.addI18n('fr', {
+	"Insert internal link": "Insérer un lien interne",
+	"Linktitle": "Texte du lien",
+	"Internal number": "N° interne"
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/js/tinymce/onflinks/langs/fr.min.js	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,1 @@
+tinyMCE.addI18n("fr",{"Insert internal link":"Insérer un lien interne",Linktitle:"Texte du lien","Internal number":"N° interne"});
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/js/tinymce/onflinks/plugin.js	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,20 @@
+tinymce.PluginManager.add('internal_links', function(editor, url) {
+
+	editor.addButton('internal_links', {
+		icon: 'cloud-check',
+		tooltip: "Insert internal link",
+		image: '/--static--/pyams_content/img/external.png',
+		onclick: function() {
+			editor.windowManager.open({
+				title: "Insert internal link",
+				body: [
+					{type: 'textbox', name: 'title', label: 'Link title', value: editor.selection.getContent()},
+					{type: 'textbox', name: 'oid', label:'Internal number'}
+				],
+				onsubmit: function(e) {
+					editor.insertContent('<a href="oid://' + e.data.oid + '">' + e.data.title + '</a>');
+				}
+			});
+		}
+	})
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/js/tinymce/onflinks/plugin.min.js	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,1 @@
+tinymce.PluginManager.add("internal_links",function(n,t){n.addButton("internal_links",{icon:"cloud-check",tooltip:"Insert internal link",image:"/--static--/pyams_content/img/external.png",onclick:function(){n.windowManager.open({title:"Insert internal link",body:[{type:"textbox",name:"title",label:"Link title",value:n.selection.getContent()},{type:"textbox",name:"oid",label:"Internal number"}],onsubmit:function(t){n.insertContent('<a href="oid://'+t.data.oid+'">'+t.data.title+"</a>")}})}})});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/resources/less/pyams_content.less	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,59 @@
+.ams-widget.comments {
+
+	.widget-body {
+		position: fixed;
+		height: ~"calc(100% - 337px)";
+
+		.chat-body {
+			position: relative;
+			height: 100%;
+		}
+
+		.chat-footer {
+			position: fixed;
+			bottom: 10px;
+		}
+
+		&,
+		.chat-footer {
+			width: ~"calc(100% - 240px)";
+
+			@media (max-width: 767px) {
+				width: ~"calc(100% - 10px)";
+			}
+			@media (min-width: 768px) and (max-width: 979px) {
+				width: ~"calc(100% - 20px)";
+			}
+
+			.minified & {
+				width: ~"calc(100% - 65px)";
+
+				@media (max-width: 767px) {
+					& {
+						width: ~"calc(100% - 55px)";
+					}
+				}
+			}
+			.hidden-menu & {
+				width: ~"calc(100% - 30px)";
+			}
+		}
+	}
+}
+
+
+.pictograms-manager {
+	.pictogram {
+		border-bottom: 1px solid silver;
+	}
+	.pictogram:last-child {
+		border-bottom: none;
+	}
+}
+
+
+.sortable {
+	&.gallery {
+		max-height: 550px;
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/tinymce.py	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_content.zmi import pyams_content
+from pyams_form.interfaces.form import IForm
+from pyams_skin.interfaces.tinymce import ITinyMCEConfiguration
+from pyams_skin.layer import IPyAMSLayer
+
+# import packages
+from pyams_utils.adapter import adapter_config, ContextRequestAdapter
+from pyams_utils.fanstatic import get_resource_path
+
+
+@adapter_config(context=(IForm, IPyAMSLayer), provides=ITinyMCEConfiguration)
+class TinyMCEEditorConfiguration(ContextRequestAdapter):
+    """TinyMCE editor configuration"""
+
+    @property
+    def configuration(self):
+        return {
+            'ams-plugins': 'pyams_content',
+            'ams-plugin-pyams_content-src': get_resource_path(pyams_content),
+            'ams-plugin-pyams_content-async': 'false',
+            'ams-tinymce-init-callback': 'PyAMS_content.TinyMCE.initEditor'
+        }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/viewlet/__init__.py	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+
+# import packages
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/viewlet/toplinks/__init__.py	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,161 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+import locale
+
+from hypatia.catalog import CatalogQuery
+from hypatia.interfaces import ICatalog
+from hypatia.query import And, Any, NotEq, Or
+
+from pyams_catalog.query import CatalogResultSet
+from pyams_content.shared.common.interfaces import IBaseSharedTool, ISharedSite
+from pyams_content.zmi.interfaces import IUserAddingsMenuLabel
+from pyams_i18n.interfaces import II18n
+from pyams_skin.interfaces.viewlet import ITopLinksViewletManager
+from pyams_skin.viewlet.toplinks import TopLinksMenu, TopLinksViewlet
+from pyams_template.template import template_config
+from pyams_utils.list import unique
+from pyams_utils.registry import get_all_utilities_registered_for, get_utility
+from pyams_utils.url import absolute_url
+from pyams_viewlet.viewlet import viewlet_config
+from pyams_zmi.layer import IAdminLayer
+
+from pyams_content import _
+
+
+@viewlet_config(name='shared-sites.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=20)
+class SharedSitesMenu(TopLinksViewlet):
+    """Shared sites menu"""
+
+    label = ''
+    css_class = 'top-menu bordered margin-top-10'
+    dropdown_label = _("Shared sites")
+
+    def update(self):
+        super(SharedSitesMenu, self).update()
+        context = self.context
+        request = self.request
+        parent = self.__parent__
+        for site in sorted(get_all_utilities_registered_for(ISharedSite),
+                           key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', request=request) or '')):
+            menu = TopLinksMenu(context, request, parent, self)
+            menu.label = II18n(site).query_attribute('title', request=request) or site.__name__
+            menu.url = absolute_url(site, request, 'admin#dashboard.html')
+            self.viewlets.append(menu)
+
+
+@viewlet_config(name='shared-contents.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=30)
+class SharedContentsMenu(TopLinksViewlet):
+    """Shared contents menu"""
+
+    label = ''
+    css_class = 'top-menu bordered margin-top-10'
+    dropdown_label = _("Shared contents")
+
+    def update(self):
+        super(SharedContentsMenu, self).update()
+        context = self.context
+        request = self.request
+        parent = self.__parent__
+        for tool in sorted(get_all_utilities_registered_for(IBaseSharedTool),
+                           key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', request=request) or '')):
+            if ISharedSite.providedBy(tool) or (not tool.shared_content_menu):
+                continue
+            menu = TopLinksMenu(context, request, parent, self)
+            menu.label = II18n(tool).query_attribute('title', request=request) or tool.__name__
+            menu.url = absolute_url(tool, request, 'admin#dashboard.html')
+            self.viewlets.append(menu)
+
+
+@viewlet_config(name='shared-tools.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=40)
+class SharedToolsMenu(TopLinksViewlet):
+    """Shared tools menu"""
+
+    label = ''
+    css_class = 'top-menu bordered margin-top-10'
+    dropdown_label = _("Shared tools")
+
+    def update(self):
+        super(SharedToolsMenu, self).update()
+        context = self.context
+        request = self.request
+        parent = self.__parent__
+        for tool in sorted(get_all_utilities_registered_for(IBaseSharedTool),
+                           key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', request=request) or '')):
+            if ISharedSite.providedBy(tool) or tool.shared_content_menu:
+                continue
+            menu = TopLinksMenu(context, request, parent, self)
+            menu.label = II18n(tool).query_attribute('title', request=request) or tool.__name__
+            menu.url = absolute_url(tool, request, 'admin#dashboard.html')
+            self.viewlets.append(menu)
+
+
+@viewlet_config(name='user-roles.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=90)
+class UserRolesMenu(TopLinksViewlet):
+    """User roles menu"""
+
+    label = ''
+    css_class = 'top-menu bordered margin-top-10'
+    dropdown_label = _("My roles")
+
+    def update(self):
+        super(UserRolesMenu, self).update()
+        catalog = get_utility(ICatalog)
+        context = self.context
+        request = self.request
+        parent = self.__parent__
+        params = And(Or(Any(catalog['role:contributor'], {request.principal.id}),
+                        Any(catalog['role:manager'], {request.principal.id}),
+                        Any(catalog['role:pilot'], {request.principal.id})),
+                     NotEq(catalog['content_type'], None))
+        for tool in sorted(unique(CatalogResultSet(CatalogQuery(catalog).query(params))),
+                           key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', request=request) or '')):
+            menu = TopLinksMenu(context, request, parent, self)
+            menu.label = II18n(tool).query_attribute('title', request=request) or tool.__name__
+            menu.url = absolute_url(tool, request, 'admin#dashboard.html')
+            self.viewlets.append(menu)
+
+
+@viewlet_config(name='user-addings.menu', layer=IAdminLayer, manager=ITopLinksViewletManager, weight=95)
+@template_config(template='templates/user-addings.pt', layer=IAdminLayer)
+class UserAddingsMenu(TopLinksViewlet):
+    """User addings menu"""
+
+    label = ''
+    css_class = 'top-menu margin-top-5-neg'
+    dropdown_label = ''
+
+    def update(self):
+        super(UserAddingsMenu, self).update()
+        catalog = get_utility(ICatalog)
+        context = self.context
+        request = self.request
+        parent = self.__parent__
+        registry = request.registry
+        params = And(Any(catalog['role:contributor'], {request.principal.id}),
+                     NotEq(catalog['content_type'], None))
+        for tool in sorted(unique(CatalogResultSet(CatalogQuery(catalog).query(params))),
+                           key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', request=request) or '')):
+            content_class = tool.shared_content_factory.content_class
+            if content_class is None:
+                continue
+            menu = TopLinksMenu(context, request, parent, self)
+            adapter = registry.queryMultiAdapter((tool, request), IUserAddingsMenuLabel)
+            if adapter is None:
+                menu.label = request.localizer.translate(content_class.content_name)
+            else:
+                menu.label = adapter.label
+            menu.url = absolute_url(tool, request, 'add-shared-content.html')
+            menu.data = {'data-toggle': 'modal'}
+            self.viewlets.append(menu)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/zmi/viewlet/toplinks/templates/user-addings.pt	Thu Nov 08 10:50:52 2018 +0100
@@ -0,0 +1,14 @@
+<div class="top-menu" tal:attributes="class view.css_class" i18n:domain="pyams_content">
+	<span class="label" tal:content="view.label | default">Label:</span>
+	<span class="top-selector popover-trigger-element dropdown-toggle btn-success"
+		  data-toggle="dropdown">
+		<i class="fa fa-3x fa-plus-square text-success opaque hint"
+		   data-ams-hint-gravity="w"
+		   title="Create new content" i18n:attributes="title"></i>
+	</span>
+	<ul class="dropdown-menu">
+		<tal:loop repeat="menu view.viewlets">
+			<tal:li replace="structure menu.render()" />
+		</tal:loop>
+	</ul>
+</div>