Browse Source

course-design

lsc 2 years ago
parent
commit
3a1b0f07ee
67 changed files with 22124 additions and 0 deletions
  1. 20 0
      course-design/LICENSE
  2. 2 0
      course-design/README.md
  3. BIN
      course-design/css/.DS_Store
  4. BIN
      course-design/css/OpenSans-Bold.ttf
  5. BIN
      course-design/css/OpenSans-BoldItalic.ttf
  6. BIN
      course-design/css/OpenSans-ExtraBold.ttf
  7. BIN
      course-design/css/OpenSans-ExtraBoldItalic.ttf
  8. BIN
      course-design/css/OpenSans-Italic.ttf
  9. BIN
      course-design/css/OpenSans-Light.ttf
  10. BIN
      course-design/css/OpenSans-LightItalic.ttf
  11. BIN
      course-design/css/OpenSans-Regular.ttf
  12. BIN
      course-design/css/OpenSans-Semibold.ttf
  13. BIN
      course-design/css/OpenSans-SemiboldItalic.ttf
  14. BIN
      course-design/css/OpenSans.woff
  15. 5 0
      course-design/css/bootstrap-select.min.css
  16. 1 0
      course-design/css/bootstrap-treeview.min.css
  17. 4 0
      course-design/css/bootstrap.min.css
  18. 690 0
      course-design/css/demo-all.css
  19. 762 0
      course-design/css/gollum-template.css
  20. 785 0
      course-design/css/jsplumb-doc.css
  21. 471 0
      course-design/css/jsplumb.css
  22. BIN
      course-design/img/bigdot.jpg
  23. BIN
      course-design/img/bigdot.png
  24. BIN
      course-design/img/bigdot.xcf
  25. BIN
      course-design/img/circle.png
  26. BIN
      course-design/img/diamond.png
  27. BIN
      course-design/img/dragging_1.jpg
  28. BIN
      course-design/img/dragging_2.jpg
  29. BIN
      course-design/img/dragging_3.jpg
  30. BIN
      course-design/img/dynamicAnchorBg.jpg
  31. BIN
      course-design/img/ellipse.png
  32. BIN
      course-design/img/endpointTest1.png
  33. BIN
      course-design/img/endpointTest1.xcf
  34. BIN
      course-design/img/favicon.jpg
  35. BIN
      course-design/img/favicon.png
  36. BIN
      course-design/img/favicon.xcf
  37. BIN
      course-design/img/glyphicons-halflings-white.png
  38. BIN
      course-design/img/glyphicons-halflings.png
  39. BIN
      course-design/img/index-bg.gif
  40. BIN
      course-design/img/jsplumb-logo-bw2.jpg
  41. BIN
      course-design/img/littledot.png
  42. BIN
      course-design/img/littledot.xcf
  43. BIN
      course-design/img/pattern.jpg
  44. BIN
      course-design/img/rectangle.png
  45. BIN
      course-design/img/swappedAnchors.jpg
  46. BIN
      course-design/img/triangle.png
  47. BIN
      course-design/img/triangle_90.png
  48. 165 0
      course-design/index.html
  49. BIN
      course-design/libs/.DS_Store
  50. 1608 0
      course-design/libs/backbone.js
  51. 195 0
      course-design/libs/biltong-0.2.js
  52. 0 0
      course-design/libs/bootstrap-treeview.min.js
  53. 2276 0
      course-design/libs/bootstrap.js
  54. 5 0
      course-design/libs/bootstrap.min.js
  55. 0 0
      course-design/libs/d3.min.js
  56. 1 0
      course-design/libs/jquery-1.11.1.min.js
  57. 4 0
      course-design/libs/jquery-ui-1.9.2.min.js
  58. 0 0
      course-design/libs/jquery.jsPlumb-1.7.2-min.js
  59. 11214 0
      course-design/libs/jquery.jsPlumb-1.7.2.js
  60. 8 0
      course-design/libs/jsBezier-0.6-min.js
  61. 422 0
      course-design/libs/jsBezier-0.6.js
  62. 489 0
      course-design/libs/json2.js
  63. 659 0
      course-design/libs/katavorio-0.4.js
  64. 524 0
      course-design/libs/mottle-0.4.js
  65. 4 0
      course-design/libs/underscore-min.js
  66. 1415 0
      course-design/libs/underscore.js
  67. 395 0
      course-design/main.js

+ 20 - 0
course-design/LICENSE

@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 naughty
+
+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.

+ 2 - 0
course-design/README.md

@@ -0,0 +1,2 @@
+# course-design
+

BIN
course-design/css/.DS_Store


BIN
course-design/css/OpenSans-Bold.ttf


BIN
course-design/css/OpenSans-BoldItalic.ttf


BIN
course-design/css/OpenSans-ExtraBold.ttf


BIN
course-design/css/OpenSans-ExtraBoldItalic.ttf


BIN
course-design/css/OpenSans-Italic.ttf


BIN
course-design/css/OpenSans-Light.ttf


BIN
course-design/css/OpenSans-LightItalic.ttf


BIN
course-design/css/OpenSans-Regular.ttf


BIN
course-design/css/OpenSans-Semibold.ttf


BIN
course-design/css/OpenSans-SemiboldItalic.ttf


BIN
course-design/css/OpenSans.woff


File diff suppressed because it is too large
+ 5 - 0
course-design/css/bootstrap-select.min.css


+ 1 - 0
course-design/css/bootstrap-treeview.min.css

@@ -0,0 +1 @@
+.list-group-item{cursor:pointer}span.indent{margin-left:10px;margin-right:10px}span.icon{margin-right:5px}

File diff suppressed because it is too large
+ 4 - 0
course-design/css/bootstrap.min.css


+ 690 - 0
course-design/css/demo-all.css

@@ -0,0 +1,690 @@
+/** DISABLE TEXT SELECTION (SET ON BODY WHEN DRAGGING IS OCCURRING) **/
+._jsPlumb_drag_select * {
+    -webkit-touch-callout: none;
+    -webkit-user-select: none;
+    -khtml-user-select: none;
+    -moz-user-select: -moz-none;
+    -ms-user-select: none;
+    user-select: none
+}
+
+/** OPEN SANS FONT **/
+@font-face {
+  font-family: 'Open Sans';
+  font-style: normal;
+  font-weight: 400;
+ 	src:local('Open Sans'), 
+ 		local('OpenSans'),
+ 		url("font/OpenSans-Regular.ttf") format('truetype'),
+ 		url("font/OpenSans.woff") format('woff');
+}
+
+/** PAGE STRUCTURE **/
+
+.dropdown { 
+  display:inline;
+}
+
+.dropdown-menu>li>a {
+  width:80%;
+  text-transform: uppercase;
+  font-size:12px;
+}
+
+/** FB **/
+#like {
+    position: fixed;
+    width: 77px;
+    height: 70px;
+    border: 0;
+    right: 11px;
+    bottom: -40px;
+}
+
+#retweet_button {
+  position: fixed;
+  bottom: 30px;
+  right: -7px;
+}
+
+body {
+    padding:0;
+    margin:0;    
+    font-family:'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;    
+    background-color:#eaedef;
+   
+}
+
+#headerWrapper {
+	width:100%;
+	background-color:white;
+	position:fixed;
+	top:0;left:0;
+  z-index:100001;
+	height:44px;
+  padding:0;
+  opacity:0.8;
+}
+
+#header {
+	margin-top:0;
+  height:44px;
+  font-size:13px;
+	margin-left:auto;
+	margin-right:auto;    
+  padding-right: 50px;
+  padding-left: 50px;
+}
+
+.explanation i {
+	float: right;
+	margin-right: 25px;
+	margin-top: 13px;
+	font-size: 25px;
+	cursor:pointer;
+}
+
+.explanation i:hover {
+	color:orange;
+}
+
+.logo {  
+  font-size:30px;
+  color:#1f1f1f;
+  text-shadow: 1px 1px #ccc;
+  float:left;
+  /*background-image:url(logo-export-35h.png);
+  background-repeat:no-repeat;    */
+  width:154px;
+  height:44px;
+  background-position:0px 5px;
+}
+
+ #main {  
+  margin-top:85px;  
+  font-size: 80%;    
+  width:75%;
+  margin-left:auto;
+  margin-right: auto;  
+  height:600px;
+  text-align: center;
+  position: relative;
+  max-width:852px;
+}
+
+.demo {
+  position: relative;
+  width:100%;
+  background-color:white;    
+  height:563px;
+  overflow:auto;  
+  margin-top:35px;
+  margin-bottom:25px;
+}
+
+.explanation {
+  position: absolute;
+  text-align: center;
+  background-color: #7AB02C;
+  opacity: 0.8;
+  filter: alpha(opacity=80);
+  color: white;
+  width: 100%;
+  height: 54px;
+  z-index: 10000;
+  overflow: hidden;
+  box-shadow: 0px 0px 10px gray;
+}
+
+.explanation.expanded {
+  height:auto;
+  min-height:54px;
+    max-height:100%;    
+}
+
+.commands {
+  margin-bottom:10px;
+}
+
+.commands:hover {
+  z-index:10000;
+}
+
+/* demo elements */
+
+a, a:visited {
+    text-decoration:none;
+    /*color:#057D9F;        */
+    color:black;
+    border-radius:0.2em;
+    -webkit-transition: color 0.15s ease-in;
+    -moz-transition: color 0.15s ease-in;
+    -o-transition: color 0.15s ease-in;
+    transition: color 0.15s ease-in;
+}
+
+a:hover {
+    color:#7AB02C;
+}
+
+a:active {
+  color:#FF2300;
+}
+
+.menu, #render, #explanation {   
+	background-color:#fff;	    
+}
+
+.menu {    
+  height: 15px;
+	float:right;     
+  padding-top:1em;
+  padding-bottom:0.4em;   
+  background-color: transparent;
+	margin-right:30px;
+  font-size:12px;
+}
+
+
+.menu a {
+  margin-right: 19px;
+}
+
+.otherLibraries {
+    display:inline;
+}
+
+#render a {
+    margin-right:10px;
+}
+
+.selected {
+	color:orange !important;
+}
+
+.window, .label { 
+    
+    text-align:center;
+    z-index:24;
+	cursor:pointer;
+	box-shadow: 2px 2px 19px #aaa;
+   -o-box-shadow: 2px 2px 19px #aaa;
+   -webkit-box-shadow: 2px 2px 19px #aaa;
+   -moz-box-shadow: 2px 2px 19px #aaa;
+    
+}
+path, ._jsPlumb_endpoint { cursor:pointer; }
+
+.cmd { 
+  color:white;
+  margin-right:25px;
+}
+
+.cmd:hover { 
+  color:#FF2300;
+  text-decoration: underline;
+}
+.cmd:active {
+  color:#FF2300;
+}
+
+.label {
+  font-size:13px; 
+  padding:8px;
+  padding:8px;
+}
+
+.component { 
+  border:1px solid #346789; 
+  border-radius:0.5em;        
+  opacity:0.8; 
+  filter:alpha(opacity=80);
+  background-color:white;
+  color:black;
+  padding:0.5em;   
+  font-size:0.8em;
+}
+
+.component:hover {
+    border:1px solid #123456;
+    box-shadow: 2px 2px 19px #444;
+   -o-box-shadow: 2px 2px 19px #444;
+   -webkit-box-shadow: 2px 2px 19px #444;
+   -moz-box-shadow: 2px 2px 19px #fff;
+    opacity:0.9;
+    filter:alpha(opacity=90);
+}
+
+.window {
+    background-color:white;
+    border:1px solid #346789;
+    box-shadow: 2px 2px 19px #e0e0e0;
+    -o-box-shadow: 2px 2px 19px #e0e0e0;
+    -webkit-box-shadow: 2px 2px 19px #e0e0e0;
+    -moz-box-shadow: 2px 2px 19px #e0e0e0;
+    -moz-border-radius:0.5em;
+    border-radius:0.5em;        
+    width:5em; height:5em;        
+    position:absolute;    
+    color:black;
+    padding:0.5em;
+    width:80px; 
+    height:80px;
+    line-height: 80px;     
+    -webkit-transition: -webkit-box-shadow 0.15s ease-in;
+    -moz-transition: -moz-box-shadow 0.15s ease-in;
+    -o-transition: -o-box-shadow 0.15s ease-in;
+    transition: box-shadow 0.15s ease-in;
+}
+
+.window:hover {
+    border:1px solid #123456;
+    box-shadow: 2px 2px 19px #444;
+   -o-box-shadow: 2px 2px 19px #444;
+   -webkit-box-shadow: 2px 2px 19px #444;
+   -moz-box-shadow: 2px 2px 19px #fff;
+    opacity:0.9;
+    filter:alpha(opacity=90);
+}
+
+.window a {
+    font-family:helvetica;
+}
+
+.demo-links, .library-links {
+  position: fixed;
+  right: 0;
+  top: 44px;
+  font-size: 11px;
+  background-color: white;
+  opacity: 0.8;
+  padding-right: 10px;
+  padding-left: 5px;
+  text-transform: uppercase;
+  z-index:100001;
+}
+
+.demo-links div, .library-links a {
+  display:inline;
+  margin-right:7px;
+  margin-left:7px;
+}
+
+.demo-links i, .library-links i {
+  padding:4px;
+}
+
+.library-links {
+    right: 454px;
+    height: 19px;
+    line-height: 19px;
+}
+
+.current-library {
+  color:#7AB02C !important;
+}
+
+/** Z-INDEX **/
+
+._jsPlumb_connector { z-index:18; }
+._jsPlumb_endpoint { z-index:19; }
+._jsPlumb_overlay { z-index:20; }
+/*
+._jsPlumb_connector._jsPlumb_hover {
+    z-index:21 !important;
+}
+._jsPlumb_endpoint._jsPlumb_hover {
+    z-index:22 !important;
+}
+._jsPlumb_overlay._jsPlumb_hover {
+    z-index:23 !important;
+}
+*/
+
+.aLabel {
+  background-color:white; 
+  padding:0.4em; 
+  font:12px sans-serif; 
+  color:#444;
+  z-index:21;
+  border:1px dotted gray;
+  opacity:0.8;
+  filter:alpha(opacity=80);
+  cursor: pointer;
+}
+.aLabel._jsPlumb_hover {
+  background-color:#5C96BC;
+  color:white;  
+  border:1px solid white;
+}
+
+/* A TEST 
+._jsPlumb_element_dragging path {    
+    z-index:21 !important;
+    stroke:green;
+}
+
+._jsPlumb_endpoint._jsPlumb_element_dragging * {
+    fill:green;
+}
+
+*/
+
+/* ANOTHER TEST 
+._jsPlumb_endpoint_anchor_foo * {
+    fill:black;
+}
+
+._jsPlumb_endpoint_anchor_bar * {
+    fill:red;
+}
+*/
+
+/**
+COMPLEMENT SCHEME
+
+*** Primary Color:
+
+   var. 1 = #5C96BC = rgb(92,150,188)
+   var. 2 = #57788D = rgb(87,120,141)
+   var. 3 = #1E567A = rgb(30,86,122)
+   var. 4 = #89BCDE = rgb(137,188,222)
+   var. 5 = #9FC5DE = rgb(159,197,222)
+
+*** Complementary Color:
+
+   var. 1 = #FFC275 = rgb(255,194,117)
+   var. 2 = #BF9D71 = rgb(191,157,113)
+   var. 3 = #A66D26 = rgb(166,109,38)
+   var. 4 = #FFD197 = rgb(255,209,151)
+
+ANALOGIC SCHEME
+
+*** Primary Color:
+
+   var. 1 = #5C96BC = rgb(92,150,188)
+   var. 2 = #57788D = rgb(87,120,141)
+   var. 3 = #1E567A = rgb(30,86,122)
+   var. 4 = #89BCDE = rgb(137,188,222)
+   var. 5 = #9FC5DE = rgb(159,197,222)
+
+*** Secondary Color A:
+
+   var. 1 = #6A6FC6 = rgb(106,111,198)
+   var. 2 = #616395 = rgb(97,99,149)
+   var. 3 = #222781 = rgb(34,39,129)
+   var. 4 = #9498E3 = rgb(148,152,227)
+   var. 5 = #A9ACE3 = rgb(169,172,227)
+
+*** Secondary Color B:
+
+   var. 1 = #5BC793 = rgb(91,199,147)
+   var. 2 = #589578 = rgb(88,149,120)
+   var. 3 = #1E8151 = rgb(30,129,81)
+   var. 4 = #86E3B6 = rgb(134,227,182)
+   var. 5 = #9FE3C2 = rgb(159,227,194)
+
+
+*/
+
+
+/* ---------------------- bootstrap dropdowns ------------------------- */
+.clearfix {
+  *zoom: 1;
+}
+
+.clearfix:before,
+.clearfix:after {
+  display: table;
+  line-height: 0;
+  content: "";
+}
+
+.clearfix:after {
+  clear: both;
+}
+
+.hide-text {
+  font: 0/0 a;
+  color: transparent;
+  text-shadow: none;
+  background-color: transparent;
+  border: 0;
+}
+
+.input-block-level {
+  display: block;
+  width: 100%;
+  min-height: 30px;
+  -webkit-box-sizing: border-box;
+     -moz-box-sizing: border-box;
+          box-sizing: border-box;
+}
+
+.dropup,
+.dropdown {
+  position: relative;
+}
+
+.dropdown-toggle {
+  *margin-bottom: -3px;
+}
+
+.dropdown-toggle:active,
+.open .dropdown-toggle {
+  outline: 0;
+}
+
+.caret {
+  display: inline-block;
+  width: 0;
+  height: 0;
+  vertical-align: top;
+  border-top: 4px solid #000000;
+  border-right: 4px solid transparent;
+  border-left: 4px solid transparent;
+  content: "";
+}
+
+.dropdown .caret {
+  margin-top: 8px;
+  margin-left: 2px;
+}
+
+.dropdown-menu {
+  position: absolute;
+  top: 100%;
+  left: 0;
+  z-index: 1000;
+  display: none;
+  float: left;
+  min-width: 160px;
+  padding: 5px 0;
+  margin: 2px 0 0;
+  list-style: none;
+  background-color: #ffffff;
+  border: 1px solid #ccc;
+  border: 1px solid rgba(0, 0, 0, 0.2);
+  *border-right-width: 2px;
+  *border-bottom-width: 2px;
+  -webkit-border-radius: 6px;
+     -moz-border-radius: 6px;
+          border-radius: 6px;
+  -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+     -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+          box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+  -webkit-background-clip: padding-box;
+     -moz-background-clip: padding;
+          background-clip: padding-box;
+}
+
+.dropdown-menu.pull-right {
+  right: 0;
+  left: auto;
+}
+
+.dropdown-menu .divider {
+  *width: 100%;
+  height: 1px;
+  margin: 9px 1px;
+  *margin: -5px 0 5px;
+  overflow: hidden;
+  background-color: #e5e5e5;
+  border-bottom: 1px solid #ffffff;
+}
+
+.dropdown-menu > li > a {
+  display: block;
+  padding: 3px 20px;
+  clear: both;
+  font-weight: normal;
+  line-height: 20px;
+  color: #333333;
+  white-space: nowrap;
+}
+
+.dropdown-menu > li > a:hover,
+.dropdown-menu > li > a:focus,
+.dropdown-submenu:hover > a,
+.dropdown-submenu:focus > a {
+  color: #ffffff;
+  text-decoration: none;
+  background-color: #0081c2;
+  background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
+  background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
+  background-image: -o-linear-gradient(top, #0088cc, #0077b3);
+  background-image: linear-gradient(to bottom, #0088cc, #0077b3);
+  background-repeat: repeat-x;
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0);
+}
+
+.dropdown-menu > .active > a,
+.dropdown-menu > .active > a:hover,
+.dropdown-menu > .active > a:focus {
+  color: #ffffff;
+  text-decoration: none;
+  background-color: #0081c2;
+  background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
+  background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
+  background-image: -o-linear-gradient(top, #0088cc, #0077b3);
+  background-image: linear-gradient(to bottom, #0088cc, #0077b3);
+  background-repeat: repeat-x;
+  outline: 0;
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0);
+}
+
+.dropdown-menu > .disabled > a,
+.dropdown-menu > .disabled > a:hover,
+.dropdown-menu > .disabled > a:focus {
+  color: #999999;
+}
+
+.dropdown-menu > .disabled > a:hover,
+.dropdown-menu > .disabled > a:focus {
+  text-decoration: none;
+  cursor: default;
+  background-color: transparent;
+  background-image: none;
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
+}
+
+.open {
+  *z-index: 1000;
+}
+
+.open > .dropdown-menu {
+  display: block;
+}
+
+.pull-right > .dropdown-menu {
+  right: 0;
+  left: auto;
+}
+
+.dropup .caret,
+.navbar-fixed-bottom .dropdown .caret {
+  border-top: 0;
+  border-bottom: 4px solid #000000;
+  content: "";
+}
+
+.dropup .dropdown-menu,
+.navbar-fixed-bottom .dropdown .dropdown-menu {
+  top: auto;
+  bottom: 100%;
+  margin-bottom: 1px;
+}
+
+.dropdown-submenu {
+  position: relative;
+}
+
+.dropdown-submenu > .dropdown-menu {
+  top: 0;
+  left: 100%;
+  margin-top: -6px;
+  margin-left: -1px;
+  -webkit-border-radius: 0 6px 6px 6px;
+     -moz-border-radius: 0 6px 6px 6px;
+          border-radius: 0 6px 6px 6px;
+}
+
+.dropdown-submenu:hover > .dropdown-menu {
+  display: block;
+}
+
+.dropup .dropdown-submenu > .dropdown-menu {
+  top: auto;
+  bottom: 0;
+  margin-top: 0;
+  margin-bottom: -2px;
+  -webkit-border-radius: 5px 5px 5px 0;
+     -moz-border-radius: 5px 5px 5px 0;
+          border-radius: 5px 5px 5px 0;
+}
+
+.dropdown-submenu > a:after {
+  display: block;
+  float: right;
+  width: 0;
+  height: 0;
+  margin-top: 5px;
+  margin-right: -10px;
+  border-color: transparent;
+  border-left-color: #cccccc;
+  border-style: solid;
+  border-width: 5px 0 5px 5px;
+  content: " ";
+}
+
+.dropdown-submenu:hover > a:after {
+  border-left-color: #ffffff;
+}
+
+.dropdown-submenu.pull-left {
+  float: none;
+}
+
+.dropdown-submenu.pull-left > .dropdown-menu {
+  left: -100%;
+  margin-left: 10px;
+  -webkit-border-radius: 6px 0 6px 6px;
+     -moz-border-radius: 6px 0 6px 6px;
+          border-radius: 6px 0 6px 6px;
+}
+
+.dropdown .dropdown-menu .nav-header {
+  padding-right: 20px;
+  padding-left: 20px;
+}
+
+.typeahead {
+  z-index: 1051;
+  margin-top: 2px;
+  -webkit-border-radius: 4px;
+     -moz-border-radius: 4px;
+          border-radius: 4px;
+}
+

+ 762 - 0
course-design/css/gollum-template.css

@@ -0,0 +1,762 @@
+/*
+  Gollum v3 Template
+*/
+
+/* jsplumb */
+
+.markdown-body {
+  font-size: 12.5px;
+  line-height: 1.6;
+  background-color: white;
+  padding-left: 10px;
+  margin-left: 265px;
+  margin-top: 65px;
+  padding-right: 20px;
+  margin-right: 10px;
+}
+
+
+
+
+
+@font-face {
+  font-family: 'Open Sans';
+  font-style: normal;
+  font-weight: 400;
+  src:local('Open Sans'), 
+    local('OpenSans'),
+    url("OpenSans-Regular.ttf") format('truetype'),
+    url("OpenSans.woff") format('woff');    
+}
+html { background-color: white; }
+body { font-family:'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;background-color:white; }
+
+a[name]:before {
+    display:block; 
+    content:" "; 
+    height:50px;     
+    margin-bottom:-18px;
+    margin-top:-79px;
+    visibility: hidden;    
+}
+
+/* corrections for  jsdoc (move these out) */
+#main {
+  height:auto;  
+  background-color: white;
+  border:none;
+  font-size: 85%;
+  text-align: left;
+  width: 90%;
+  max-width: none;
+}
+nav {
+  padding-bottom: 10px;
+  overflow-x: hidden;
+  overflow-y:auto;
+  height:100%;
+  background-color: white;
+  margin-top: 40px;
+  position: fixed;
+  left: 0;
+  border: none;
+  float: none;
+  margin-left: 0;
+  width:210px;
+}
+
+nav a:visited {
+  color:#01a3c6;
+}
+
+nav h2 {
+  display:none;
+}
+
+#main article dd {
+  border-bottom: 1px solid #ccc;
+  padding-bottom: 26px;
+}
+
+/* this is the location in source links */
+.details {
+  display:none;
+}
+
+/* constructors */
+.container-overview {
+  /*display:none;*/
+}
+
+.apidoc-main {
+  margin-left: 255px !important;  
+  height: auto;
+  width: auto;
+  background-color: white;
+  border: none;
+}
+
+.apidoc-summary {
+  width:150px;
+}
+.apidoc-detail {
+  margin-left:160px;
+}
+
+#qunit-tests li, #qunit-testresult {
+  background-color: white !important;
+}
+
+#qunit-userAgent {
+  text-shadow:none;
+}
+
+/* / jsplumb */
+
+/* added by SP */
+
+#headerWrapper {
+  background-color:#eaedef;
+}
+
+.nav {
+  width: 240px;
+  margin-left: 15px;
+  font-size: 12px;
+  position: fixed;
+  height: 88%;
+  overflow-y: auto;
+  overflow-x: hidden;
+  background-color: white;
+  padding-left: 5px;
+}
+
+.nav ul {
+  padding-left: 25px;
+  margin-top:8px;
+}
+
+.nav ul li {
+  margin-bottom:5px;
+}
+
+html, body {
+  color: #333;
+}
+
+body {
+  font: 13.34px helvetica,arial,freesans,clean,sans-serif;
+  line-height: 1.4;
+}
+
+img {
+  border: 0;
+}
+
+a, a:visited {
+  color: #4183C4;
+  text-decoration: none;
+  padding:0.3em;
+}
+
+a.absent {
+  color: #c00;
+}
+
+.markdown-body a[id].wiki-toc-anchor  {
+  color: inherit;
+  text-decoration: none;
+}
+
+.markdown-body>*:first-child {
+  margin-top: 0!important;
+}
+.markdown-body>*:last-child {
+  margin-bottom: 0!important;
+}
+.markdown-body a.absent {
+  color: #c00;
+}
+.markdown-body a.anchor {
+  display: block;
+  padding-left: 30px;
+  margin-left: -30px;
+  cursor: pointer;
+  position: absolute;
+  top: 0;
+  left: 0;
+  bottom: 0;
+}
+.markdown-body h1,
+.markdown-body h2,
+.markdown-body h3,
+.markdown-body h4,
+.markdown-body h5,
+.markdown-body h6 {
+  margin: 20px 0 10px;
+  padding: 0;
+  font-weight: bold;
+  -webkit-font-smoothing: antialiased;
+  cursor: text;
+  position: relative;
+}
+.markdown-body h1:hover a.anchor,
+.markdown-body h2:hover a.anchor,
+.markdown-body h3:hover a.anchor,
+.markdown-body h4:hover a.anchor,
+.markdown-body h5:hover a.anchor,
+.markdown-body h6:hover a.anchor {
+  background: url(../images/pin-20.png) no-repeat left center;
+  text-decoration: none;
+}
+.markdown-body h1 tt,
+.markdown-body h1 code,
+.markdown-body h2 tt,
+.markdown-body h2 code,
+.markdown-body h3 tt,
+.markdown-body h3 code,
+.markdown-body h4 tt,
+.markdown-body h4 code,
+.markdown-body h5 tt,
+.markdown-body h5 code,
+.markdown-body h6 tt,
+.markdown-body h6 code {
+  font-size: inherit;
+}
+.markdown-body h1 {
+  font-size: 28px;
+  color: #000;
+  margin-top: 50px;
+  margin-bottom: 20px;
+}
+.markdown-body h2 {
+  font-size: 24px;
+  border-bottom: 1px solid #ccc;
+  color: #000;
+  margin-top: 40px;
+  margin-bottom: 20px;
+}
+.markdown-body h3 {
+  font-size: 18px;
+  margin-top: 30px;
+  margin-bottom: 15px;
+}
+.markdown-body h4 {
+  font-size: 16px;
+}
+.markdown-body h5 {
+  font-size: 14px;
+}
+.markdown-body h6 {
+  color: #777;
+  font-size: 14px;
+}
+.markdown-body p,
+.markdown-body blockquote,
+.markdown-body ul,
+.markdown-body ol,
+.markdown-body dl,
+.markdown-body li,
+.markdown-body table,
+.markdown-body pre {
+  margin: 15px 0;
+}
+.markdown-body hr {
+  background: transparent url(../images/dirty-shade.png) repeat-x 0 0;
+  border: 0 none;
+  color: #ccc;
+  height: 4px;
+  padding: 0;
+}
+.markdown-body>h1:first-child,
+.markdown-body>h2:first-child,
+.markdown-body>h3:first-child,
+.markdown-body>h4:first-child,
+.markdown-body>h5:first-child,
+.markdown-body>h6:first-child {
+}
+.markdown-body h1+h2{
+  margin-top: 30px;
+}
+.markdown-body h2+h3{
+  margin-top: 10px;
+}
+.markdown-body a:first-child h1,
+.markdown-body a:first-child h2,
+.markdown-body a:first-child h3,
+.markdown-body a:first-child h4,
+.markdown-body a:first-child h5,
+.markdown-body a:first-child h6 {
+  margin-top: 0;
+  padding-top: 0;
+}
+.markdown-body h1+p,
+.markdown-body h2+p,
+.markdown-body h3+p,
+.markdown-body h4+p,
+.markdown-body h5+p,
+.markdown-body h6+p {
+  margin-top: 0;
+}
+.markdown-body li p.first {
+  display: inline-block;
+}
+.markdown-body ul,
+.markdown-body ol {
+  padding-left: 30px;
+}
+.markdown-body ul li>:first-child,
+.markdown-body ol li>:first-child {
+  margin-top: 0;
+}
+.markdown-body ul li>:last-child,
+.markdown-body ol li>:last-child {
+  margin-bottom: 0;
+}
+.markdown-body dl {
+  padding: 0;
+}
+.markdown-body dl dt {
+  font-size: 14px;
+  font-weight: bold;
+  font-style: italic;
+  padding: 0;
+  margin: 15px 0 5px;
+}
+.markdown-body dl dt:first-child {
+  padding: 0;
+}
+.markdown-body dl dt>:first-child {
+  margin-top: 0;
+}
+.markdown-body dl dt>:last-child {
+  margin-bottom: 0;
+}
+.markdown-body dl dd {
+  margin: 0 0 15px;
+  padding: 0 15px;
+}
+.markdown-body dl dd>:first-child {
+  margin-top: 0;
+}
+.markdown-body dl dd>:last-child {
+  margin-bottom: 0;
+}
+.markdown-body blockquote {
+  border-left: 4px solid #DDD;
+  padding: 0 15px;
+  color: #777;
+}
+.markdown-body blockquote>:first-child {
+  margin-top: 0;
+}
+.markdown-body blockquote>:last-child {
+  margin-bottom: 0;
+}
+.markdown-body table {
+  padding: 0;
+  border-collapse: collapse;
+  border-spacing: 0;
+}
+.markdown-body table tr {
+  border-top: 1px solid #ccc;
+  background-color: #fff;
+  margin: 0;
+  padding: 0;
+}
+.markdown-body table tr:nth-child(2n) {
+  background-color: #f8f8f8;
+}
+.markdown-body table tr th {
+  font-weight: bold;
+}
+.markdown-body table tr th,
+.markdown-body table tr td {
+  border: 1px solid #ccc;
+  text-align: left;
+  margin: 0;
+  padding: 6px 13px;
+}
+.markdown-body table tr th>:first-child,
+.markdown-body table tr td>:first-child {
+  margin-top: 0;
+}
+.markdown-body table tr th>:last-child,
+.markdown-body table tr td>:last-child {
+  margin-bottom: 0;
+}
+.markdown-body img {
+  max-width: 100%;
+}
+.markdown-body span.frame {
+  display: block;
+  overflow: hidden;
+}
+.markdown-body span.frame>span {
+  border: 1px solid #ddd;
+  display: block;
+  float: left;
+  overflow: hidden;
+  margin: 13px 0 0;
+  padding: 7px;
+  width: auto;
+}
+.markdown-body span.frame span img {
+  display: block;
+  float: left;
+}
+.markdown-body span.frame span span {
+  clear: both;
+  color: #333;
+  display: block;
+  padding: 5px 0 0;
+}
+.markdown-body span.align-center {
+  display: block;
+  overflow: hidden;
+  clear: both;
+}
+.markdown-body span.align-center>span {
+  display: block;
+  overflow: hidden;
+  margin: 13px auto 0;
+  text-align: center;
+}
+.markdown-body span.align-center span img {
+  margin: 0 auto;
+  text-align: center;
+}
+.markdown-body span.align-right {
+  display: block;
+  overflow: hidden;
+  clear: both;
+}
+.markdown-body span.align-right>span {
+  display: block;
+  overflow: hidden;
+  margin: 13px 0 0;
+  text-align: right;
+}
+.markdown-body span.align-right span img {
+  margin: 0;
+  text-align: right;
+}
+.markdown-body span.float-left {
+  display: block;
+  margin-right: 13px;
+  overflow: hidden;
+  float: left;
+}
+.markdown-body span.float-left span {
+  margin: 13px 0 0;
+}
+.markdown-body span.float-right {
+  display: block;
+  margin-left: 13px;
+  overflow: hidden;
+  float: right;
+}
+.markdown-body span.float-right>span {
+  display: block;
+  overflow: hidden;
+  margin: 13px auto 0;
+  text-align: right;
+}
+.markdown-body code,
+.markdown-body tt {
+  margin: 0 2px;
+  padding: 0 5px;
+  white-space: nowrap;
+  border: 1px solid #ddd;
+  background-color: #f8f8f8;
+  border-radius: 3px;
+}
+.markdown-body pre>tt,
+.markdown-body pre>code {
+  margin: 0;
+  padding: 0;
+  white-space: pre;
+  border: none;
+  background: transparent;
+}
+.markdown-body pre {
+  background-color: #f8f8f8;
+  border: 1px solid #ccc;
+  font-size: 11.5px;
+  line-height: 18px;
+  overflow: auto;
+  padding: 6px 10px;
+  border-radius: 3px;
+}
+.markdown-body pre pre,
+.markdown-body pre code,
+.markdown-body pre tt {
+  background-color: transparent;
+  border: none;
+}
+.markdown-body pre pre {
+  margin: 0;
+  padding: 0;
+}
+.toc {
+  background-color: #F7F7F7;
+  border: 1px solid #ddd;
+  padding: 5px 10px;
+  margin: 0;
+  border-radius: 3px;
+}
+.toc-title {
+  color: #888;
+  font-size: 14px;
+  line-height: 1.6;
+  padding: 2px;
+  border-bottom: 1px solid #ddd;
+  margin-bottom: 3px;
+}
+.toc ul {
+  padding-left: 10px;
+  margin: 0;
+}
+.toc>ul {
+  margin-left: 10px;
+  font-size: 17px;
+}
+.toc ul ul {
+  font-size: 15px;
+}
+.toc ul ul ul {
+  font-size: 14px;
+}
+.toc ul li{
+  margin: 0;
+}
+#header-content .toc,
+#footer-content .toc,
+#sidebar-content .toc {
+  border: none;
+}
+.highlight {
+  background: #fff;
+}
+.highlight .c {
+  color: #998;
+  font-style: italic;
+}
+.highlight .err {
+  color: #a61717;
+  background-color: #e3d2d2;
+}
+.highlight .k {
+  font-weight: bold;
+}
+.highlight .o {
+  font-weight: bold;
+}
+.highlight .cm {
+  color: #998;
+  font-style: italic;
+}
+.highlight .cp {
+  color: #999;
+  font-weight: bold;
+}
+.highlight .c1 {
+  color: #998;
+  font-style: italic;
+}
+.highlight .cs {
+  color: #999;
+  font-weight: bold;
+  font-style: italic;
+}
+.highlight .gd {
+  color: #000;
+  background-color: #fdd;
+}
+.highlight .gd .x {
+  color: #000;
+  background-color: #faa;
+}
+.highlight .ge {
+  font-style: italic;
+}
+.highlight .gr {
+  color: #a00;
+}
+.highlight .gh {
+  color: #999;
+}
+.highlight .gi {
+  color: #000;
+  background-color: #dfd;
+}
+.highlight .gi .x {
+  color: #000;
+  background-color: #afa;
+}
+.highlight .go {
+  color: #888;
+}
+.highlight .gp {
+  color: #555;
+}
+.highlight .gs {
+  font-weight: bold;
+}
+.highlight .gu {
+  color: #800080;
+  font-weight: bold;
+}
+.highlight .gt {
+  color: #a00;
+}
+.highlight .kc {
+  font-weight: bold;
+}
+.highlight .kd {
+  font-weight: bold;
+}
+.highlight .kn {
+  font-weight: bold;
+}
+.highlight .kp {
+  font-weight: bold;
+}
+.highlight .kr {
+  font-weight: bold;
+}
+.highlight .kt {
+  color: #458;
+  font-weight: bold;
+}
+.highlight .m {
+  color: #099;
+}
+.highlight .s {
+  color: #d14;
+}
+.highlight .na {
+  color: #008080;
+}
+.highlight .nb {
+  color: #0086B3;
+}
+.highlight .nc {
+  color: #458;
+  font-weight: bold;
+}
+.highlight .no {
+  color: #008080;
+}
+.highlight .ni {
+  color: #800080;
+}
+.highlight .ne {
+  color: #900;
+  font-weight: bold;
+}
+.highlight .nf {
+  color: #900;
+  font-weight: bold;
+}
+.highlight .nn {
+  color: #555;
+}
+.highlight .nt {
+  color: #000080;
+}
+.highlight .nv {
+  color: #008080;
+}
+.highlight .ow {
+  font-weight: bold;
+}
+.highlight .w {
+  color: #bbb;
+}
+.highlight .mf {
+  color: #099;
+}
+.highlight .mh {
+  color: #099;
+}
+.highlight .mi {
+  color: #099;
+}
+.highlight .mo {
+  color: #099;
+}
+.highlight .sb {
+  color: #d14;
+}
+.highlight .sc {
+  color: #d14;
+}
+.highlight .sd {
+  color: #d14;
+}
+.highlight .s2 {
+  color: #d14;
+}
+.highlight .se {
+  color: #d14;
+}
+.highlight .sh {
+  color: #d14;
+}
+.highlight .si {
+  color: #d14;
+}
+.highlight .sx {
+  color: #d14;
+}
+.highlight .sr {
+  color: #009926;
+}
+.highlight .s1 {
+  color: #d14;
+}
+.highlight .ss {
+  color: #990073;
+}
+.highlight .bp {
+  color: #999;
+}
+.highlight .vc {
+  color: #008080;
+}
+.highlight .vg {
+  color: #008080;
+}
+.highlight .vi {
+  color: #008080;
+}
+.highlight .il {
+  color: #099;
+}
+.highlight .gc {
+  color: #999;
+  background-color: #EAF2F5;
+}
+.type-csharp .highlight .k {
+  color: #00F;
+}
+.type-csharp .highlight .kt {
+  color: #00F;
+}
+.type-csharp .highlight .nf {
+  color: #000;
+  font-weight: normal;
+}
+.type-csharp .highlight .nc {
+  color: #2B91AF;
+}
+.type-csharp .highlight .nn {
+  color: #000;
+}
+.type-csharp .highlight .s {
+  color: #A31515;
+}
+.type-csharp .highlight .sc {
+  color: #A31515;
+}

+ 785 - 0
course-design/css/jsplumb-doc.css

@@ -0,0 +1,785 @@
+/*
+  Gollum v3 Template
+*/
+
+/* jsplumb */
+
+.markdown-body {
+  font-size: 12.5px;
+  line-height: 1.6;
+  background-color: white;
+  padding-left: 10px;
+  margin-left: 265px;
+  margin-top: 65px;
+  padding-right: 20px;
+  margin-right: 10px;
+}
+
+li {
+  list-style-type: disc;
+}
+
+.apis li {
+  list-style-type: none;
+}
+
+
+
+@font-face {
+  font-family: 'Open Sans';
+  font-style: normal;
+  font-weight: 400;
+  src:local('Open Sans'), 
+    local('OpenSans'),
+    url("OpenSans-Regular.ttf") format('truetype'),
+    url("OpenSans.woff") format('woff');    
+}
+html { background-color: white; }
+body { 
+  font-family:'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
+  background-color:white; 
+  text-align:left;
+}
+
+a[name]:before {
+    display:block; 
+    content:" "; 
+    height:50px;     
+    margin-bottom:-18px;
+    margin-top:-79px;
+    visibility: hidden;    
+}
+
+/* corrections for  jsdoc (move these out) */
+#main {
+  height:auto;  
+  background-color: white;
+  border:none;
+  font-size: 85%;
+  text-align: left;
+  width: 90%;
+  max-width: none;
+}
+nav {
+  padding-bottom: 10px;
+  overflow-x: hidden;
+  overflow-y:auto;
+  height:100%;
+  background-color: white;
+  margin-top: 40px;
+  position: fixed;
+  left: 0;
+  border: none;
+  float: none;
+  margin-left: 0;
+  width:210px;
+}
+
+nav a:visited {
+  color:#01a3c6;
+}
+
+nav h2 {
+  display:none;
+}
+
+#main article dd {
+  border-bottom: 1px solid #ccc;
+  padding-bottom: 26px;
+}
+
+/* this is the location in source links */
+.details {
+  display:none;
+}
+
+/* constructors */
+.container-overview {
+  /*display:none;*/
+}
+
+.apidoc-main {
+  margin-left: 255px !important;  
+  height: auto;
+  width: auto;
+  background-color: white;
+  border: none;
+}
+
+.apidoc-summary {
+  width:150px;
+}
+.apidoc-detail {
+  margin-left:160px;
+}
+
+#qunit-tests li, #qunit-testresult {
+  background-color: white !important;
+}
+
+#qunit-userAgent {
+  text-shadow:none;
+}
+
+/* / jsplumb */
+
+/* added by SP */
+
+#headerWrapper {
+  background-color:#eaedef;
+}
+
+.menu {
+  background-color: #eaedef;
+}
+
+.nav {
+  width: 240px;
+  margin-left: 15px;
+  font-size: 12px;
+  position: fixed;
+  height: 88%;
+  overflow-y: auto;
+  overflow-x: hidden;
+  background-color: white;
+  padding-left: 5px;
+}
+
+.nav ul {
+  padding-left: 25px;
+  margin-top:8px;
+}
+
+.nav ul li {
+  margin-bottom:5px;
+}
+
+html, body {
+  color: #333;
+}
+
+body {
+  font: 13.34px helvetica,arial,freesans,clean,sans-serif;
+  line-height: 1.4;
+}
+
+img {
+  border: 0;
+}
+
+a, a:visited {
+  color: #4183C4;
+  text-decoration: none;
+  padding:0.3em;
+}
+
+a.absent {
+  color: #c00;
+}
+
+.markdown-body a[id].wiki-toc-anchor  {
+  color: inherit;
+  text-decoration: none;
+}
+
+.markdown-body>*:first-child {
+  margin-top: 0!important;
+}
+.markdown-body>*:last-child {
+  margin-bottom: 0!important;
+}
+.markdown-body a.absent {
+  color: #c00;
+}
+.markdown-body a.anchor {
+  display: block;
+  padding-left: 30px;
+  margin-left: -30px;
+  cursor: pointer;
+  position: absolute;
+  top: 0;
+  left: 0;
+  bottom: 0;
+}
+.markdown-body h1,
+.markdown-body h2,
+.markdown-body h3,
+.markdown-body h4,
+.markdown-body h5,
+.markdown-body h6 {
+  margin: 20px 0 10px;
+  padding: 0;
+  font-weight: bold;
+  -webkit-font-smoothing: antialiased;
+  cursor: text;
+  position: relative;
+}
+.markdown-body h1:hover a.anchor,
+.markdown-body h2:hover a.anchor,
+.markdown-body h3:hover a.anchor,
+.markdown-body h4:hover a.anchor,
+.markdown-body h5:hover a.anchor,
+.markdown-body h6:hover a.anchor {
+  background: url(../images/pin-20.png) no-repeat left center;
+  text-decoration: none;
+}
+.markdown-body h1 tt,
+.markdown-body h1 code,
+.markdown-body h2 tt,
+.markdown-body h2 code,
+.markdown-body h3 tt,
+.markdown-body h3 code,
+.markdown-body h4 tt,
+.markdown-body h4 code,
+.markdown-body h5 tt,
+.markdown-body h5 code,
+.markdown-body h6 tt,
+.markdown-body h6 code {
+  font-size: inherit;
+}
+.markdown-body h1 {
+  font-size: 28px;
+  color: #000;
+  margin-top: 50px;
+  margin-bottom: 20px;
+}
+.markdown-body h2 {
+  font-size: 24px;
+  border-bottom: 1px solid #ccc;
+  color: #000;
+  margin-top: 40px;
+  margin-bottom: 20px;
+}
+.markdown-body h3 {
+  font-size: 18px;
+  margin-top: 30px;
+  margin-bottom: 15px;
+}
+.markdown-body h4 {
+  font-size: 16px;
+}
+.markdown-body h5 {
+  font-size: 14px;
+}
+.markdown-body h6 {
+  color: #777;
+  font-size: 14px;
+}
+.markdown-body p,
+.markdown-body blockquote,
+.markdown-body ul,
+.markdown-body ol,
+.markdown-body dl,
+.markdown-body li,
+.markdown-body table,
+.markdown-body pre {
+  margin: 15px 0;
+}
+.markdown-body hr {
+  background: transparent url(../images/dirty-shade.png) repeat-x 0 0;
+  border: 0 none;
+  color: #ccc;
+  height: 4px;
+  padding: 0;
+}
+.markdown-body>h1:first-child,
+.markdown-body>h2:first-child,
+.markdown-body>h3:first-child,
+.markdown-body>h4:first-child,
+.markdown-body>h5:first-child,
+.markdown-body>h6:first-child {
+}
+.markdown-body h1+h2{
+  margin-top: 30px;
+}
+.markdown-body h2+h3{
+  margin-top: 10px;
+}
+.markdown-body a:first-child h1,
+.markdown-body a:first-child h2,
+.markdown-body a:first-child h3,
+.markdown-body a:first-child h4,
+.markdown-body a:first-child h5,
+.markdown-body a:first-child h6 {
+  margin-top: 0;
+  padding-top: 0;
+}
+.markdown-body h1+p,
+.markdown-body h2+p,
+.markdown-body h3+p,
+.markdown-body h4+p,
+.markdown-body h5+p,
+.markdown-body h6+p {
+  margin-top: 0;
+}
+.markdown-body li p.first {
+  display: inline-block;
+}
+.markdown-body ul,
+.markdown-body ol {
+  padding-left: 30px;
+}
+.markdown-body ul li>:first-child,
+.markdown-body ol li>:first-child {
+  margin-top: 0;
+}
+.markdown-body ul li>:last-child,
+.markdown-body ol li>:last-child {
+  margin-bottom: 0;
+}
+.markdown-body dl {
+  padding: 0;
+}
+.markdown-body dl dt {
+  font-size: 14px;
+  font-weight: bold;
+  font-style: italic;
+  padding: 0;
+  margin: 15px 0 5px;
+}
+.markdown-body dl dt:first-child {
+  padding: 0;
+}
+.markdown-body dl dt>:first-child {
+  margin-top: 0;
+}
+.markdown-body dl dt>:last-child {
+  margin-bottom: 0;
+}
+.markdown-body dl dd {
+  margin: 0 0 15px;
+  padding: 0 15px;
+}
+.markdown-body dl dd>:first-child {
+  margin-top: 0;
+}
+.markdown-body dl dd>:last-child {
+  margin-bottom: 0;
+}
+.markdown-body blockquote {
+  border-left: 4px solid #DDD;
+  padding: 0 15px;
+  color: #777;
+}
+.markdown-body blockquote>:first-child {
+  margin-top: 0;
+}
+.markdown-body blockquote>:last-child {
+  margin-bottom: 0;
+}
+.markdown-body table {
+  padding: 0;
+  border-collapse: collapse;
+  border-spacing: 0;
+}
+.markdown-body table tr {
+  border-top: 1px solid #ccc;
+  background-color: #fff;
+  margin: 0;
+  padding: 0;
+}
+.markdown-body table tr:nth-child(2n) {
+  background-color: #f8f8f8;
+}
+.markdown-body table tr th {
+  font-weight: bold;
+}
+.markdown-body table tr th,
+.markdown-body table tr td {
+  border: 1px solid #ccc;
+  text-align: left;
+  margin: 0;
+  padding: 6px 13px;
+}
+.markdown-body table tr th>:first-child,
+.markdown-body table tr td>:first-child {
+  margin-top: 0;
+}
+.markdown-body table tr th>:last-child,
+.markdown-body table tr td>:last-child {
+  margin-bottom: 0;
+}
+.markdown-body img {
+  max-width: 100%;
+}
+.markdown-body span.frame {
+  display: block;
+  overflow: hidden;
+}
+.markdown-body span.frame>span {
+  border: 1px solid #ddd;
+  display: block;
+  float: left;
+  overflow: hidden;
+  margin: 13px 0 0;
+  padding: 7px;
+  width: auto;
+}
+.markdown-body span.frame span img {
+  display: block;
+  float: left;
+}
+.markdown-body span.frame span span {
+  clear: both;
+  color: #333;
+  display: block;
+  padding: 5px 0 0;
+}
+.markdown-body span.align-center {
+  display: block;
+  overflow: hidden;
+  clear: both;
+}
+.markdown-body span.align-center>span {
+  display: block;
+  overflow: hidden;
+  margin: 13px auto 0;
+  text-align: center;
+}
+.markdown-body span.align-center span img {
+  margin: 0 auto;
+  text-align: center;
+}
+.markdown-body span.align-right {
+  display: block;
+  overflow: hidden;
+  clear: both;
+}
+.markdown-body span.align-right>span {
+  display: block;
+  overflow: hidden;
+  margin: 13px 0 0;
+  text-align: right;
+}
+.markdown-body span.align-right span img {
+  margin: 0;
+  text-align: right;
+}
+.markdown-body span.float-left {
+  display: block;
+  margin-right: 13px;
+  overflow: hidden;
+  float: left;
+}
+.markdown-body span.float-left span {
+  margin: 13px 0 0;
+}
+.markdown-body span.float-right {
+  display: block;
+  margin-left: 13px;
+  overflow: hidden;
+  float: right;
+}
+.markdown-body span.float-right>span {
+  display: block;
+  overflow: hidden;
+  margin: 13px auto 0;
+  text-align: right;
+}
+.markdown-body code,
+.markdown-body tt {
+  margin: 0 2px;
+  padding: 0 5px;
+  white-space: nowrap;
+  border: 1px solid #ddd;
+  background-color: #f8f8f8;
+  border-radius: 3px;
+}
+.markdown-body pre>tt,
+.markdown-body pre>code {
+  margin: 0;
+  padding: 0;
+  white-space: pre;
+  border: none;
+  background: transparent;
+}
+.markdown-body pre {
+  background-color: #f8f8f8;
+  border: 1px solid #ccc;
+  font-size: 11.5px;
+  line-height: 18px;
+  overflow: auto;
+  padding: 6px 10px;
+  border-radius: 3px;
+}
+.markdown-body pre pre,
+.markdown-body pre code,
+.markdown-body pre tt {
+  background-color: transparent;
+  border: none;
+}
+.markdown-body pre pre {
+  margin: 0;
+  padding: 0;
+}
+.toc {
+  background-color: #F7F7F7;
+  border: 1px solid #ddd;
+  padding: 5px 10px;
+  margin: 0;
+  border-radius: 3px;
+}
+.toc-title {
+  color: #888;
+  font-size: 14px;
+  line-height: 1.6;
+  padding: 2px;
+  border-bottom: 1px solid #ddd;
+  margin-bottom: 3px;
+}
+.toc ul {
+  padding-left: 10px;
+  margin: 0;
+}
+.toc>ul {
+  margin-left: 10px;
+  font-size: 17px;
+}
+.toc ul ul {
+  font-size: 15px;
+}
+.toc ul ul ul {
+  font-size: 14px;
+}
+.toc ul li{
+  margin: 0;
+}
+#header-content .toc,
+#footer-content .toc,
+#sidebar-content .toc {
+  border: none;
+}
+.highlight {
+  background: #fff;
+}
+.highlight .c {
+  color: #998;
+  font-style: italic;
+}
+.highlight .err {
+  color: #a61717;
+  background-color: #e3d2d2;
+}
+.highlight .k {
+  font-weight: bold;
+}
+.highlight .o {
+  font-weight: bold;
+}
+.highlight .cm {
+  color: #998;
+  font-style: italic;
+}
+.highlight .cp {
+  color: #999;
+  font-weight: bold;
+}
+.highlight .c1 {
+  color: #998;
+  font-style: italic;
+}
+.highlight .cs {
+  color: #999;
+  font-weight: bold;
+  font-style: italic;
+}
+.highlight .gd {
+  color: #000;
+  background-color: #fdd;
+}
+.highlight .gd .x {
+  color: #000;
+  background-color: #faa;
+}
+.highlight .ge {
+  font-style: italic;
+}
+.highlight .gr {
+  color: #a00;
+}
+.highlight .gh {
+  color: #999;
+}
+.highlight .gi {
+  color: #000;
+  background-color: #dfd;
+}
+.highlight .gi .x {
+  color: #000;
+  background-color: #afa;
+}
+.highlight .go {
+  color: #888;
+}
+.highlight .gp {
+  color: #555;
+}
+.highlight .gs {
+  font-weight: bold;
+}
+.highlight .gu {
+  color: #800080;
+  font-weight: bold;
+}
+.highlight .gt {
+  color: #a00;
+}
+.highlight .kc {
+  font-weight: bold;
+}
+.highlight .kd {
+  font-weight: bold;
+}
+.highlight .kn {
+  font-weight: bold;
+}
+.highlight .kp {
+  font-weight: bold;
+}
+.highlight .kr {
+  font-weight: bold;
+}
+.highlight .kt {
+  color: #458;
+  font-weight: bold;
+}
+.highlight .m {
+  color: #099;
+}
+.highlight .s {
+  color: #d14;
+}
+.highlight .na {
+  color: #008080;
+}
+.highlight .nb {
+  color: #0086B3;
+}
+.highlight .nc {
+  color: #458;
+  font-weight: bold;
+}
+.highlight .no {
+  color: #008080;
+}
+.highlight .ni {
+  color: #800080;
+}
+.highlight .ne {
+  color: #900;
+  font-weight: bold;
+}
+.highlight .nf {
+  color: #900;
+  font-weight: bold;
+}
+.highlight .nn {
+  color: #555;
+}
+.highlight .nt {
+  color: #000080;
+}
+.highlight .nv {
+  color: #008080;
+}
+.highlight .ow {
+  font-weight: bold;
+}
+.highlight .w {
+  color: #bbb;
+}
+.highlight .mf {
+  color: #099;
+}
+.highlight .mh {
+  color: #099;
+}
+.highlight .mi {
+  color: #099;
+}
+.highlight .mo {
+  color: #099;
+}
+.highlight .sb {
+  color: #d14;
+}
+.highlight .sc {
+  color: #d14;
+}
+.highlight .sd {
+  color: #d14;
+}
+.highlight .s2 {
+  color: #d14;
+}
+.highlight .se {
+  color: #d14;
+}
+.highlight .sh {
+  color: #d14;
+}
+.highlight .si {
+  color: #d14;
+}
+.highlight .sx {
+  color: #d14;
+}
+.highlight .sr {
+  color: #009926;
+}
+.highlight .s1 {
+  color: #d14;
+}
+.highlight .ss {
+  color: #990073;
+}
+.highlight .bp {
+  color: #999;
+}
+.highlight .vc {
+  color: #008080;
+}
+.highlight .vg {
+  color: #008080;
+}
+.highlight .vi {
+  color: #008080;
+}
+.highlight .il {
+  color: #099;
+}
+.highlight .gc {
+  color: #999;
+  background-color: #EAF2F5;
+}
+.type-csharp .highlight .k {
+  color: #00F;
+}
+.type-csharp .highlight .kt {
+  color: #00F;
+}
+.type-csharp .highlight .nf {
+  color: #000;
+  font-weight: normal;
+}
+.type-csharp .highlight .nc {
+  color: #2B91AF;
+}
+.type-csharp .highlight .nn {
+  color: #000;
+}
+.type-csharp .highlight .s {
+  color: #A31515;
+}
+.type-csharp .highlight .sc {
+  color: #A31515;
+}
+
+/* api docs */
+.apidocs {
+  margin-top: 20px !important;
+}
+
+.apidoc-intro {
+  padding-top:30px !important;
+}

+ 471 - 0
course-design/css/jsplumb.css

@@ -0,0 +1,471 @@
+/** DISABLE TEXT SELECTION (SET ON BODY WHEN DRAGGING IS OCCURRING) **/
+._jsPlumb_drag_select * {
+    -webkit-touch-callout: none;
+    -webkit-user-select: none;
+    -khtml-user-select: none;
+    -moz-user-select: none;
+    -ms-user-select: none;
+    user-select: none;
+}
+
+/** OPEN SANS FONT **/
+@font-face {
+  font-family: 'Open Sans';
+  font-style: normal;
+  font-weight: 400;
+ 	src:local('Open Sans'), 
+ 		local('OpenSans'),
+ 		url("OpenSans-Regular.ttf") format('truetype'),
+ 		url("OpenSans.woff") format('woff');
+}
+
+/** FB **/
+#like {
+    position: fixed;
+    width: 77px;
+    height: 70px;
+    border: 0;
+    right: 11px;
+    bottom: -40px;
+}
+
+#retweet_button {
+  position: fixed;
+  bottom: 30px;
+  right: -7px;
+}
+
+body {
+    padding:0;
+    margin:0;    
+    font-family:'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;    
+    background-color: whitesmoke;
+}
+
+#headerWrapper {
+	width:100%;
+	background-color:white;
+	position:fixed;
+	top:0;left:0;
+  z-index:100001;
+	height:44px;
+  padding:0;
+  opacity:0.8;
+  text-align: center;
+  border-bottom: 1px solid #e5e5e5;
+  box-shadow: 0px 1px #eee;
+}
+
+#header {
+	margin-top:0;
+  
+	height:44px;
+  font-size:13px;
+	margin-left:auto;
+	margin-right:auto;    
+  
+	line-height: 44px;
+  max-width:1000px;
+  width:80%;
+}
+
+@media screen and (max-width:1000px) {
+	#header {
+		width:100%;
+	}
+}
+
+@media screen and (max-width:800px) {
+	#header select {
+		display:none;
+	}
+}
+
+@media screen and (max-width:700px) {
+	.library-links {
+		right:330px;
+	}
+}
+
+@media screen and (max-width:640px) {
+	.logo {
+		display:none;
+	}
+	#header {
+		text-align:center;
+		overflow:hidden;
+	}
+}
+
+.explanation i {
+	float: right;
+	margin-right: 25px;
+	margin-top: 13px;
+	font-size: 25px;
+	cursor:pointer;
+}
+
+.explanation i:hover {
+	color:orange;
+}
+
+.words {
+  text-align: left;
+  padding:50px;
+  background-color:white;
+}
+
+.code {
+  border:1px solid #456;
+}
+
+.logo {  
+  font-size:30px;
+  color:#1f1f1f;
+  text-shadow: 1px 1px #ccc;
+  float:left;
+  width:154px;
+  height:44px;
+  background-position:0px 5px;
+}
+
+ #main {  
+  margin-top: 106px;  
+  font-size: 80%;    
+  width: 80%;
+  margin-left:auto;
+  margin-right: auto;  
+  height: 600px;
+  text-align: center;
+  position: relative;
+  max-width: 1200px;
+  max-height: 1000px;
+}
+
+.demo {
+  position: relative;
+  width:100%;
+  background-color:white;    
+  overflow:auto;  
+  margin-top: 53px;
+  margin-bottom:25px;
+  height: 600px;
+}
+
+.explanation {
+  position: absolute;
+  text-align: center;
+  background-color: #7AB02C;
+  opacity: 0.8;
+  filter: alpha(opacity=80);
+  color: white;
+  width: 100%;
+  height: 54px;
+  z-index: 10000;
+  overflow: hidden;
+  box-shadow: 0px 0px 10px gray;
+}
+
+.explanation.expanded {
+  height:auto;
+  min-height:54px;
+    
+  -webkit-transition: max-height 0.8s;
+  max-height:100%;    
+}
+
+.commands {
+  margin-bottom:10px;
+}
+
+.commands:hover {
+  z-index:10000;
+}
+
+/* demo elements */
+
+a, a:visited {
+    text-decoration:none;
+    color:black;
+    border-radius:0.2em;
+    -webkit-transition: color 0.15s ease-in;
+    -moz-transition: color 0.15s ease-in;
+    -o-transition: color 0.15s ease-in;
+    transition: color 0.15s ease-in;
+}
+
+a:hover {
+    color:#7AB02C;
+}
+
+a:active {
+  color:#FF2300;
+}
+
+.menu, #render, #explanation {   
+	background-color:#fff;	    
+}
+
+.menu {    
+  float:right;
+  font-size:12px;
+}
+
+.menu a {
+  margin-right: 19px;
+}
+
+.otherLibraries {
+  display:inline;
+}
+
+#render a {
+  margin-right:10px;
+}
+
+.selected {
+  color:orange !important;
+}
+
+.window, .label {   
+  text-align:center;
+  z-index:24;
+	cursor:pointer;
+	box-shadow: 2px 2px 19px #aaa;
+   -o-box-shadow: 2px 2px 19px #aaa;
+   -webkit-box-shadow: 2px 2px 19px #aaa;
+   -moz-box-shadow: 2px 2px 19px #aaa;
+    
+}
+path, ._jsPlumb_endpoint { cursor:pointer; }
+
+.cmd { 
+  color:white;
+  margin-right:25px;
+}
+
+.cmd:hover { 
+  color:#FF2300;
+  text-decoration: underline;
+}
+.cmd:active {
+  color:#FF2300;
+}
+
+.label {
+  font-size:13px; 
+  padding:8px;
+  padding:8px;
+}
+
+.component { 
+  border:1px solid #346789; 
+  border-radius:0.5em;        
+  opacity:0.8; 
+  filter:alpha(opacity=80);
+  background-color:white;
+  color:black;
+  padding:0.5em;   
+  font-size:0.8em;
+}
+
+.component:hover {
+    border:1px solid #123456;
+    box-shadow: 2px 2px 19px #444;
+   -o-box-shadow: 2px 2px 19px #444;
+   -webkit-box-shadow: 2px 2px 19px #444;
+   -moz-box-shadow: 2px 2px 19px #fff;
+    opacity:0.9;
+    filter:alpha(opacity=90);
+}
+
+.window {
+    background-color:white;
+    border:1px solid #346789;
+    box-shadow: 2px 2px 19px #e0e0e0;
+    -o-box-shadow: 2px 2px 19px #e0e0e0;
+    -webkit-box-shadow: 2px 2px 19px #e0e0e0;
+    -moz-box-shadow: 2px 2px 19px #e0e0e0;
+    -moz-border-radius:0.5em;
+    border-radius:0.5em;        
+    width:5em; height:5em;        
+    position:absolute;    
+    color:black;
+    padding:0.5em;
+    width:80px; 
+    height:80px;
+    line-height: 80px;     
+    -webkit-transition: -webkit-box-shadow 0.15s ease-in;
+    -moz-transition: -moz-box-shadow 0.15s ease-in;
+    -o-transition: -o-box-shadow 0.15s ease-in;
+    transition: box-shadow 0.15s ease-in;
+}
+
+.window:hover {
+    border:1px solid #123456;
+    box-shadow: 2px 2px 19px #444;
+   -o-box-shadow: 2px 2px 19px #444;
+   -webkit-box-shadow: 2px 2px 19px #444;
+   -moz-box-shadow: 2px 2px 19px #fff;
+    opacity:0.9;
+    filter:alpha(opacity=90);
+}
+
+.window a {
+    font-family:helvetica;
+}
+
+.demo-links, .library-links {
+  position: fixed;
+  right: 0;
+  top: 44px;
+  font-size: 11px;
+  background-color: white;
+  opacity: 0.8;
+  padding-right: 10px;
+  padding-left: 5px;
+  text-transform: uppercase;
+  z-index:100001;
+}
+
+.demo-links div, .library-links a {
+  display:inline;
+  margin-right:7px;
+  margin-left:7px;
+}
+
+.demo-links i, .library-links i {
+  padding:4px;
+}
+
+.library-links {
+    right: 515px;
+    height: 19px;
+    line-height: 19px;
+}
+
+.current-library {
+  color:#7AB02C !important;
+}
+
+/** Z-INDEX **/
+
+._jsPlumb_connector { z-index:18; }
+._jsPlumb_endpoint { z-index:19; }
+._jsPlumb_overlay { z-index:20; }
+
+.aLabel {
+  background-color:white; 
+  padding:0.4em; 
+  font:12px sans-serif; 
+  color:#444;
+  z-index:21;
+  border:1px dotted gray;
+  opacity:0.8;
+  filter:alpha(opacity=80);
+  cursor: pointer;
+}
+.aLabel._jsPlumb_hover {
+  background-color:#5C96BC;
+  color:white;  
+  border:1px solid white;
+}
+
+/* ---------------------- bootstrap dropdowns ------------------------- */
+.clearfix {
+  *zoom: 1;
+}
+
+.clearfix:before,
+.clearfix:after {
+  display: table;
+  line-height: 0;
+  content: "";
+}
+
+.clearfix:after {
+  clear: both;
+}
+
+.hide-text {
+  font: 0/0 a;
+  color: transparent;
+  text-shadow: none;
+  background-color: transparent;
+  border: 0;
+}
+
+.input-block-level {
+  display: block;
+  width: 100%;
+  min-height: 30px;
+  -webkit-box-sizing: border-box;
+     -moz-box-sizing: border-box;
+          box-sizing: border-box;
+}
+
+/* load test */
+
+
+    #iframe { 
+      width: 98%;
+	height: 1000px;
+	position: absolute;
+	top: 8px;
+	left: 1%;
+	border: 0;
+    }     
+    #render { height:20px;}
+    #links {      
+      width: 143px;
+      font-size: 14px;
+      padding-left: 0px;
+      position: fixed;
+      left: 9px;
+      top: 52px;
+      z-index: 20;
+      background-color: white;                  
+    }
+    ul { padding:0; }
+    li {
+      list-style-type:none;
+    }
+    .current-tests {
+      color:orange !important;
+    }
+    #qunit-tests li.pass, #qunit-tests li.fail {
+      background-color:transparent;
+    }
+    .loadtest #main, #main.test  {
+      max-width: none;
+      margin-top: 52px;
+      background-color: white;
+    
+      margin-left: 162px;
+}
+
+
+.loadtest ._jsPlumb_connection { z-index:3; }
+.loadtest .jspLoad {
+    z-index:4;
+    position:absolute;
+    width:70px;
+    height:70px;
+    cursor:pointer;
+}
+
+.loadtest #header {
+  height:11em;
+  border:2px solid #824563;
+}
+
+.loadtest #setup {
+  float:left;
+}
+.loadtest #demo {
+  margin-top:10em;
+  position:relative;
+}
+.loadtest #setup, .loadtest #output {
+  font-size:12px;
+}

BIN
course-design/img/bigdot.jpg


BIN
course-design/img/bigdot.png


BIN
course-design/img/bigdot.xcf


BIN
course-design/img/circle.png


BIN
course-design/img/diamond.png


BIN
course-design/img/dragging_1.jpg


BIN
course-design/img/dragging_2.jpg


BIN
course-design/img/dragging_3.jpg


BIN
course-design/img/dynamicAnchorBg.jpg


BIN
course-design/img/ellipse.png


BIN
course-design/img/endpointTest1.png


BIN
course-design/img/endpointTest1.xcf


BIN
course-design/img/favicon.jpg


BIN
course-design/img/favicon.png


BIN
course-design/img/favicon.xcf


BIN
course-design/img/glyphicons-halflings-white.png


BIN
course-design/img/glyphicons-halflings.png


BIN
course-design/img/index-bg.gif


BIN
course-design/img/jsplumb-logo-bw2.jpg


BIN
course-design/img/littledot.png


BIN
course-design/img/littledot.xcf


BIN
course-design/img/pattern.jpg


BIN
course-design/img/rectangle.png


BIN
course-design/img/swappedAnchors.jpg


BIN
course-design/img/triangle.png


BIN
course-design/img/triangle_90.png


+ 165 - 0
course-design/index.html

@@ -0,0 +1,165 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+  <meta charset="utf-8">
+  <title>TA Flow Builder</title>
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <meta name="description" content="">
+  <meta name="author" content="Gang Tao">
+
+  <link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css" />
+  <link rel="stylesheet" type="text/css" href="./css/bootstrap-treeview.min.css" />
+  <link rel="stylesheet" type="text/css" href="./css/jsplumb.css" />
+
+  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
+  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
+  <!--[if lt IE 9]>
+      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
+      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
+    <![endif]-->
+
+  <style type="text/css">
+    html,
+    body {
+      /* padding-top: 60px;
+          padding-bottom: 40px; */
+      float: center;
+      width: 100%;
+      height: 99%;
+    }
+
+    .btn.active.focus,
+    .btn.active:focus,
+    .btn.focus,
+    .btn:active.focus,
+    .btn:active:focus,
+    .btn:focus {
+      outline: none;
+    }
+
+    .button {
+      outline: none;
+    }
+  </style>
+</head>
+
+<body>
+  <div class="flow-fluid" style="height: 100%;">
+    <div class="row" style="margin-top: 10px;margin-left: 0;margin-right: 0;">
+      <button class="btn btn-primary button" style="margin-left:140px;" data-toggle="modal"
+        data-target="#Modal">+</button>
+    </div>
+    <div class="row" style="margin: 0;height: 80%;">
+      <!-- <div class="col-md-2">
+          <div class="panel panel-default" style="margin:2px;height:400px">
+            <div class="panel-body">
+              <div id="control-panel">
+              </div>
+            </div>
+          </div>
+        </div> -->
+      <div class="col-md-12" style="height:100%">
+        <div class="panel1 panel-default" style="margin:0px;height:100%">
+          <div class="panel-body" style="padding: 0;">
+            <div id="flow-panel" class='col-md-12' style="height:100%">
+            </div>
+          </div>
+        </div>
+      </div>
+      <!-- <div class="col-md-4">
+          <div class="panel panel-default" style="margin:2px;height:400px">
+            <div class="panel-body">
+              Data Preview
+            </div>
+          </div>
+        </div> -->
+    </div>
+  </div>
+
+  <!-- 模态框(Modal) -->
+  <div class="modal fade" id="Modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
+    data-backdrop="static">
+    <div class="modal-dialog" style="z-index: 1060;">
+      <div class="modal-content">
+        <div class="modal-header">
+          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+          <h4 class="modal-title" id="myModalLabel">添加节点类别</h4>
+        </div>
+        <div class="modal-body">
+          <form role="form" id="bbb" onsubmit="return false">
+            <!-- <div class="form-group">
+              <input type="text" id="columns" class="form-control" placeholder="请输入第几列">
+
+            </div> -->
+
+            <div class="form-group">
+              <label style="vertical-align: middle;display:inline-block;width: 100%;">1
+                <input type="text" id="types1" class="form-control" placeholder="请输入节点类别名字"
+                  style="width: 92%;display:inline-block;" onkeydown="bbb()">
+              </label>
+            </div>
+          </form>
+        </div>
+        <div class="modal-footer">
+          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
+          <button type="button" class="btn btn-primary" id="SubmitB">提交更改</button>
+        </div>
+      </div><!-- /.modal-content -->
+    </div><!-- /.modal -->
+  </div>
+
+  <!-- 模态框(Modal) -->
+  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
+    data-backdrop="static">
+    <div class="modal-dialog" style="z-index: 1060;">
+      <div class="modal-content">
+        <div class="modal-header">
+          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+          <h4 class="modal-title" id="myModalLabel">添加节点</h4>
+        </div>
+        <div class="modal-body">
+          <div>
+            <input type="text" id="column" class="form-control" placeholder="请输入第几列" style="display:none" />
+          </div>
+          <form role="form" id="aaa" onsubmit="return false">
+            <!-- <div class="row" style="margin-top: 10px;margin-left: 0;margin-right: 0;margin-bottom: 20px;">
+              <button class="btn btn-primary button" onclick="addInput()">+</button>
+            </div> -->
+            <div class="form-group">
+              <label style="vertical-align: middle;display:inline-block;width: 100%;">1
+                <input type="text" id="names1" class="form-control" placeholder="请输入节点名字"
+                  style="width: 92%;display:inline-block;" onkeydown="addInput()">
+              </label>
+            </div>
+          </form>
+        </div>
+        <div class="modal-footer">
+          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
+          <button type="button" class="btn btn-primary" id="SubmitA">提交更改</button>
+        </div>
+      </div><!-- /.modal-content -->
+    </div><!-- /.modal -->
+  </div>
+  <!-- <hr> -->
+  <!-- <div class="footer">
+      <div class="container">
+        <p>Make Data Collecting Interesting :)</p>
+      </div>
+    </div> -->
+
+  <script type='text/javascript'></script>
+  <script type="text/javascript" src="./libs/jquery-1.11.1.min.js"></script>
+  <script type="text/javascript" src="./libs/jquery-ui-1.9.2.min.js"></script>
+  <script type="text/javascript" src="./libs/d3.min.js"></script>
+  <script type="text/javascript" src="./libs/bootstrap.min.js"></script>
+  <script type="text/javascript" src="./libs/bootstrap-treeview.min.js"></script>
+  <script type="text/javascript" src="./libs/json2.js"></script>
+  <script type="text/javascript" src="./libs/jquery.jsPlumb-1.7.2.js"></script>
+  <script type="text/javascript" src="./libs/biltong-0.2.js"></script>
+  <script type="text/javascript" src="./libs/jsBezier-0.6.js"></script>
+
+  <script type="text/javascript" src="./main.js"></script>
+</body>
+
+</html>

BIN
course-design/libs/.DS_Store


+ 1608 - 0
course-design/libs/backbone.js

@@ -0,0 +1,1608 @@
+//     Backbone.js 1.1.2
+
+//     (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+//     Backbone may be freely distributed under the MIT license.
+//     For all details and documentation:
+//     http://backbonejs.org
+
+(function(root, factory) {
+
+  // Set up Backbone appropriately for the environment. Start with AMD.
+  if (typeof define === 'function' && define.amd) {
+    define(['underscore', 'jquery', 'exports'], function(_, $, exports) {
+      // Export global even in AMD case in case this script is loaded with
+      // others that may still expect a global Backbone.
+      root.Backbone = factory(root, exports, _, $);
+    });
+
+  // Next for Node.js or CommonJS. jQuery may not be needed as a module.
+  } else if (typeof exports !== 'undefined') {
+    var _ = require('underscore');
+    factory(root, exports, _);
+
+  // Finally, as a browser global.
+  } else {
+    root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$));
+  }
+
+}(this, function(root, Backbone, _, $) {
+
+  // Initial Setup
+  // -------------
+
+  // Save the previous value of the `Backbone` variable, so that it can be
+  // restored later on, if `noConflict` is used.
+  var previousBackbone = root.Backbone;
+
+  // Create local references to array methods we'll want to use later.
+  var array = [];
+  var push = array.push;
+  var slice = array.slice;
+  var splice = array.splice;
+
+  // Current version of the library. Keep in sync with `package.json`.
+  Backbone.VERSION = '1.1.2';
+
+  // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
+  // the `$` variable.
+  Backbone.$ = $;
+
+  // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
+  // to its previous owner. Returns a reference to this Backbone object.
+  Backbone.noConflict = function() {
+    root.Backbone = previousBackbone;
+    return this;
+  };
+
+  // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option
+  // will fake `"PATCH"`, `"PUT"` and `"DELETE"` requests via the `_method` parameter and
+  // set a `X-Http-Method-Override` header.
+  Backbone.emulateHTTP = false;
+
+  // Turn on `emulateJSON` to support legacy servers that can't deal with direct
+  // `application/json` requests ... will encode the body as
+  // `application/x-www-form-urlencoded` instead and will send the model in a
+  // form param named `model`.
+  Backbone.emulateJSON = false;
+
+  // Backbone.Events
+  // ---------------
+
+  // A module that can be mixed in to *any object* in order to provide it with
+  // custom events. You may bind with `on` or remove with `off` callback
+  // functions to an event; `trigger`-ing an event fires all callbacks in
+  // succession.
+  //
+  //     var object = {};
+  //     _.extend(object, Backbone.Events);
+  //     object.on('expand', function(){ alert('expanded'); });
+  //     object.trigger('expand');
+  //
+  var Events = Backbone.Events = {
+
+    // Bind an event to a `callback` function. Passing `"all"` will bind
+    // the callback to all events fired.
+    on: function(name, callback, context) {
+      if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this;
+      this._events || (this._events = {});
+      var events = this._events[name] || (this._events[name] = []);
+      events.push({callback: callback, context: context, ctx: context || this});
+      return this;
+    },
+
+    // Bind an event to only be triggered a single time. After the first time
+    // the callback is invoked, it will be removed.
+    once: function(name, callback, context) {
+      if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this;
+      var self = this;
+      var once = _.once(function() {
+        self.off(name, once);
+        callback.apply(this, arguments);
+      });
+      once._callback = callback;
+      return this.on(name, once, context);
+    },
+
+    // Remove one or many callbacks. If `context` is null, removes all
+    // callbacks with that function. If `callback` is null, removes all
+    // callbacks for the event. If `name` is null, removes all bound
+    // callbacks for all events.
+    off: function(name, callback, context) {
+      var retain, ev, events, names, i, l, j, k;
+      if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this;
+      if (!name && !callback && !context) {
+        this._events = void 0;
+        return this;
+      }
+      names = name ? [name] : _.keys(this._events);
+      for (i = 0, l = names.length; i < l; i++) {
+        name = names[i];
+        if (events = this._events[name]) {
+          this._events[name] = retain = [];
+          if (callback || context) {
+            for (j = 0, k = events.length; j < k; j++) {
+              ev = events[j];
+              if ((callback && callback !== ev.callback && callback !== ev.callback._callback) ||
+                  (context && context !== ev.context)) {
+                retain.push(ev);
+              }
+            }
+          }
+          if (!retain.length) delete this._events[name];
+        }
+      }
+
+      return this;
+    },
+
+    // Trigger one or many events, firing all bound callbacks. Callbacks are
+    // passed the same arguments as `trigger` is, apart from the event name
+    // (unless you're listening on `"all"`, which will cause your callback to
+    // receive the true name of the event as the first argument).
+    trigger: function(name) {
+      if (!this._events) return this;
+      var args = slice.call(arguments, 1);
+      if (!eventsApi(this, 'trigger', name, args)) return this;
+      var events = this._events[name];
+      var allEvents = this._events.all;
+      if (events) triggerEvents(events, args);
+      if (allEvents) triggerEvents(allEvents, arguments);
+      return this;
+    },
+
+    // Tell this object to stop listening to either specific events ... or
+    // to every object it's currently listening to.
+    stopListening: function(obj, name, callback) {
+      var listeningTo = this._listeningTo;
+      if (!listeningTo) return this;
+      var remove = !name && !callback;
+      if (!callback && typeof name === 'object') callback = this;
+      if (obj) (listeningTo = {})[obj._listenId] = obj;
+      for (var id in listeningTo) {
+        obj = listeningTo[id];
+        obj.off(name, callback, this);
+        if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id];
+      }
+      return this;
+    }
+
+  };
+
+  // Regular expression used to split event strings.
+  var eventSplitter = /\s+/;
+
+  // Implement fancy features of the Events API such as multiple event
+  // names `"change blur"` and jQuery-style event maps `{change: action}`
+  // in terms of the existing API.
+  var eventsApi = function(obj, action, name, rest) {
+    if (!name) return true;
+
+    // Handle event maps.
+    if (typeof name === 'object') {
+      for (var key in name) {
+        obj[action].apply(obj, [key, name[key]].concat(rest));
+      }
+      return false;
+    }
+
+    // Handle space separated event names.
+    if (eventSplitter.test(name)) {
+      var names = name.split(eventSplitter);
+      for (var i = 0, l = names.length; i < l; i++) {
+        obj[action].apply(obj, [names[i]].concat(rest));
+      }
+      return false;
+    }
+
+    return true;
+  };
+
+  // A difficult-to-believe, but optimized internal dispatch function for
+  // triggering events. Tries to keep the usual cases speedy (most internal
+  // Backbone events have 3 arguments).
+  var triggerEvents = function(events, args) {
+    var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
+    switch (args.length) {
+      case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return;
+      case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
+      case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
+      case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
+      default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
+    }
+  };
+
+  var listenMethods = {listenTo: 'on', listenToOnce: 'once'};
+
+  // Inversion-of-control versions of `on` and `once`. Tell *this* object to
+  // listen to an event in another object ... keeping track of what it's
+  // listening to.
+  _.each(listenMethods, function(implementation, method) {
+    Events[method] = function(obj, name, callback) {
+      var listeningTo = this._listeningTo || (this._listeningTo = {});
+      var id = obj._listenId || (obj._listenId = _.uniqueId('l'));
+      listeningTo[id] = obj;
+      if (!callback && typeof name === 'object') callback = this;
+      obj[implementation](name, callback, this);
+      return this;
+    };
+  });
+
+  // Aliases for backwards compatibility.
+  Events.bind   = Events.on;
+  Events.unbind = Events.off;
+
+  // Allow the `Backbone` object to serve as a global event bus, for folks who
+  // want global "pubsub" in a convenient place.
+  _.extend(Backbone, Events);
+
+  // Backbone.Model
+  // --------------
+
+  // Backbone **Models** are the basic data object in the framework --
+  // frequently representing a row in a table in a database on your server.
+  // A discrete chunk of data and a bunch of useful, related methods for
+  // performing computations and transformations on that data.
+
+  // Create a new model with the specified attributes. A client id (`cid`)
+  // is automatically generated and assigned for you.
+  var Model = Backbone.Model = function(attributes, options) {
+    var attrs = attributes || {};
+    options || (options = {});
+    this.cid = _.uniqueId('c');
+    this.attributes = {};
+    if (options.collection) this.collection = options.collection;
+    if (options.parse) attrs = this.parse(attrs, options) || {};
+    attrs = _.defaults({}, attrs, _.result(this, 'defaults'));
+    this.set(attrs, options);
+    this.changed = {};
+    this.initialize.apply(this, arguments);
+  };
+
+  // Attach all inheritable methods to the Model prototype.
+  _.extend(Model.prototype, Events, {
+
+    // A hash of attributes whose current and previous value differ.
+    changed: null,
+
+    // The value returned during the last failed validation.
+    validationError: null,
+
+    // The default name for the JSON `id` attribute is `"id"`. MongoDB and
+    // CouchDB users may want to set this to `"_id"`.
+    idAttribute: 'id',
+
+    // Initialize is an empty function by default. Override it with your own
+    // initialization logic.
+    initialize: function(){},
+
+    // Return a copy of the model's `attributes` object.
+    toJSON: function(options) {
+      return _.clone(this.attributes);
+    },
+
+    // Proxy `Backbone.sync` by default -- but override this if you need
+    // custom syncing semantics for *this* particular model.
+    sync: function() {
+      return Backbone.sync.apply(this, arguments);
+    },
+
+    // Get the value of an attribute.
+    get: function(attr) {
+      return this.attributes[attr];
+    },
+
+    // Get the HTML-escaped value of an attribute.
+    escape: function(attr) {
+      return _.escape(this.get(attr));
+    },
+
+    // Returns `true` if the attribute contains a value that is not null
+    // or undefined.
+    has: function(attr) {
+      return this.get(attr) != null;
+    },
+
+    // Set a hash of model attributes on the object, firing `"change"`. This is
+    // the core primitive operation of a model, updating the data and notifying
+    // anyone who needs to know about the change in state. The heart of the beast.
+    set: function(key, val, options) {
+      var attr, attrs, unset, changes, silent, changing, prev, current;
+      if (key == null) return this;
+
+      // Handle both `"key", value` and `{key: value}` -style arguments.
+      if (typeof key === 'object') {
+        attrs = key;
+        options = val;
+      } else {
+        (attrs = {})[key] = val;
+      }
+
+      options || (options = {});
+
+      // Run validation.
+      if (!this._validate(attrs, options)) return false;
+
+      // Extract attributes and options.
+      unset           = options.unset;
+      silent          = options.silent;
+      changes         = [];
+      changing        = this._changing;
+      this._changing  = true;
+
+      if (!changing) {
+        this._previousAttributes = _.clone(this.attributes);
+        this.changed = {};
+      }
+      current = this.attributes, prev = this._previousAttributes;
+
+      // Check for changes of `id`.
+      if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
+
+      // For each `set` attribute, update or delete the current value.
+      for (attr in attrs) {
+        val = attrs[attr];
+        if (!_.isEqual(current[attr], val)) changes.push(attr);
+        if (!_.isEqual(prev[attr], val)) {
+          this.changed[attr] = val;
+        } else {
+          delete this.changed[attr];
+        }
+        unset ? delete current[attr] : current[attr] = val;
+      }
+
+      // Trigger all relevant attribute changes.
+      if (!silent) {
+        if (changes.length) this._pending = options;
+        for (var i = 0, l = changes.length; i < l; i++) {
+          this.trigger('change:' + changes[i], this, current[changes[i]], options);
+        }
+      }
+
+      // You might be wondering why there's a `while` loop here. Changes can
+      // be recursively nested within `"change"` events.
+      if (changing) return this;
+      if (!silent) {
+        while (this._pending) {
+          options = this._pending;
+          this._pending = false;
+          this.trigger('change', this, options);
+        }
+      }
+      this._pending = false;
+      this._changing = false;
+      return this;
+    },
+
+    // Remove an attribute from the model, firing `"change"`. `unset` is a noop
+    // if the attribute doesn't exist.
+    unset: function(attr, options) {
+      return this.set(attr, void 0, _.extend({}, options, {unset: true}));
+    },
+
+    // Clear all attributes on the model, firing `"change"`.
+    clear: function(options) {
+      var attrs = {};
+      for (var key in this.attributes) attrs[key] = void 0;
+      return this.set(attrs, _.extend({}, options, {unset: true}));
+    },
+
+    // Determine if the model has changed since the last `"change"` event.
+    // If you specify an attribute name, determine if that attribute has changed.
+    hasChanged: function(attr) {
+      if (attr == null) return !_.isEmpty(this.changed);
+      return _.has(this.changed, attr);
+    },
+
+    // Return an object containing all the attributes that have changed, or
+    // false if there are no changed attributes. Useful for determining what
+    // parts of a view need to be updated and/or what attributes need to be
+    // persisted to the server. Unset attributes will be set to undefined.
+    // You can also pass an attributes object to diff against the model,
+    // determining if there *would be* a change.
+    changedAttributes: function(diff) {
+      if (!diff) return this.hasChanged() ? _.clone(this.changed) : false;
+      var val, changed = false;
+      var old = this._changing ? this._previousAttributes : this.attributes;
+      for (var attr in diff) {
+        if (_.isEqual(old[attr], (val = diff[attr]))) continue;
+        (changed || (changed = {}))[attr] = val;
+      }
+      return changed;
+    },
+
+    // Get the previous value of an attribute, recorded at the time the last
+    // `"change"` event was fired.
+    previous: function(attr) {
+      if (attr == null || !this._previousAttributes) return null;
+      return this._previousAttributes[attr];
+    },
+
+    // Get all of the attributes of the model at the time of the previous
+    // `"change"` event.
+    previousAttributes: function() {
+      return _.clone(this._previousAttributes);
+    },
+
+    // Fetch the model from the server. If the server's representation of the
+    // model differs from its current attributes, they will be overridden,
+    // triggering a `"change"` event.
+    fetch: function(options) {
+      options = options ? _.clone(options) : {};
+      if (options.parse === void 0) options.parse = true;
+      var model = this;
+      var success = options.success;
+      options.success = function(resp) {
+        if (!model.set(model.parse(resp, options), options)) return false;
+        if (success) success(model, resp, options);
+        model.trigger('sync', model, resp, options);
+      };
+      wrapError(this, options);
+      return this.sync('read', this, options);
+    },
+
+    // Set a hash of model attributes, and sync the model to the server.
+    // If the server returns an attributes hash that differs, the model's
+    // state will be `set` again.
+    save: function(key, val, options) {
+      var attrs, method, xhr, attributes = this.attributes;
+
+      // Handle both `"key", value` and `{key: value}` -style arguments.
+      if (key == null || typeof key === 'object') {
+        attrs = key;
+        options = val;
+      } else {
+        (attrs = {})[key] = val;
+      }
+
+      options = _.extend({validate: true}, options);
+
+      // If we're not waiting and attributes exist, save acts as
+      // `set(attr).save(null, opts)` with validation. Otherwise, check if
+      // the model will be valid when the attributes, if any, are set.
+      if (attrs && !options.wait) {
+        if (!this.set(attrs, options)) return false;
+      } else {
+        if (!this._validate(attrs, options)) return false;
+      }
+
+      // Set temporary attributes if `{wait: true}`.
+      if (attrs && options.wait) {
+        this.attributes = _.extend({}, attributes, attrs);
+      }
+
+      // After a successful server-side save, the client is (optionally)
+      // updated with the server-side state.
+      if (options.parse === void 0) options.parse = true;
+      var model = this;
+      var success = options.success;
+      options.success = function(resp) {
+        // Ensure attributes are restored during synchronous saves.
+        model.attributes = attributes;
+        var serverAttrs = model.parse(resp, options);
+        if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs);
+        if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) {
+          return false;
+        }
+        if (success) success(model, resp, options);
+        model.trigger('sync', model, resp, options);
+      };
+      wrapError(this, options);
+
+      method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update');
+      if (method === 'patch') options.attrs = attrs;
+      xhr = this.sync(method, this, options);
+
+      // Restore attributes.
+      if (attrs && options.wait) this.attributes = attributes;
+
+      return xhr;
+    },
+
+    // Destroy this model on the server if it was already persisted.
+    // Optimistically removes the model from its collection, if it has one.
+    // If `wait: true` is passed, waits for the server to respond before removal.
+    destroy: function(options) {
+      options = options ? _.clone(options) : {};
+      var model = this;
+      var success = options.success;
+
+      var destroy = function() {
+        model.trigger('destroy', model, model.collection, options);
+      };
+
+      options.success = function(resp) {
+        if (options.wait || model.isNew()) destroy();
+        if (success) success(model, resp, options);
+        if (!model.isNew()) model.trigger('sync', model, resp, options);
+      };
+
+      if (this.isNew()) {
+        options.success();
+        return false;
+      }
+      wrapError(this, options);
+
+      var xhr = this.sync('delete', this, options);
+      if (!options.wait) destroy();
+      return xhr;
+    },
+
+    // Default URL for the model's representation on the server -- if you're
+    // using Backbone's restful methods, override this to change the endpoint
+    // that will be called.
+    url: function() {
+      var base =
+        _.result(this, 'urlRoot') ||
+        _.result(this.collection, 'url') ||
+        urlError();
+      if (this.isNew()) return base;
+      return base.replace(/([^\/])$/, '$1/') + encodeURIComponent(this.id);
+    },
+
+    // **parse** converts a response into the hash of attributes to be `set` on
+    // the model. The default implementation is just to pass the response along.
+    parse: function(resp, options) {
+      return resp;
+    },
+
+    // Create a new model with identical attributes to this one.
+    clone: function() {
+      return new this.constructor(this.attributes);
+    },
+
+    // A model is new if it has never been saved to the server, and lacks an id.
+    isNew: function() {
+      return !this.has(this.idAttribute);
+    },
+
+    // Check if the model is currently in a valid state.
+    isValid: function(options) {
+      return this._validate({}, _.extend(options || {}, { validate: true }));
+    },
+
+    // Run validation against the next complete set of model attributes,
+    // returning `true` if all is well. Otherwise, fire an `"invalid"` event.
+    _validate: function(attrs, options) {
+      if (!options.validate || !this.validate) return true;
+      attrs = _.extend({}, this.attributes, attrs);
+      var error = this.validationError = this.validate(attrs, options) || null;
+      if (!error) return true;
+      this.trigger('invalid', this, error, _.extend(options, {validationError: error}));
+      return false;
+    }
+
+  });
+
+  // Underscore methods that we want to implement on the Model.
+  var modelMethods = ['keys', 'values', 'pairs', 'invert', 'pick', 'omit'];
+
+  // Mix in each Underscore method as a proxy to `Model#attributes`.
+  _.each(modelMethods, function(method) {
+    Model.prototype[method] = function() {
+      var args = slice.call(arguments);
+      args.unshift(this.attributes);
+      return _[method].apply(_, args);
+    };
+  });
+
+  // Backbone.Collection
+  // -------------------
+
+  // If models tend to represent a single row of data, a Backbone Collection is
+  // more analagous to a table full of data ... or a small slice or page of that
+  // table, or a collection of rows that belong together for a particular reason
+  // -- all of the messages in this particular folder, all of the documents
+  // belonging to this particular author, and so on. Collections maintain
+  // indexes of their models, both in order, and for lookup by `id`.
+
+  // Create a new **Collection**, perhaps to contain a specific type of `model`.
+  // If a `comparator` is specified, the Collection will maintain
+  // its models in sort order, as they're added and removed.
+  var Collection = Backbone.Collection = function(models, options) {
+    options || (options = {});
+    if (options.model) this.model = options.model;
+    if (options.comparator !== void 0) this.comparator = options.comparator;
+    this._reset();
+    this.initialize.apply(this, arguments);
+    if (models) this.reset(models, _.extend({silent: true}, options));
+  };
+
+  // Default options for `Collection#set`.
+  var setOptions = {add: true, remove: true, merge: true};
+  var addOptions = {add: true, remove: false};
+
+  // Define the Collection's inheritable methods.
+  _.extend(Collection.prototype, Events, {
+
+    // The default model for a collection is just a **Backbone.Model**.
+    // This should be overridden in most cases.
+    model: Model,
+
+    // Initialize is an empty function by default. Override it with your own
+    // initialization logic.
+    initialize: function(){},
+
+    // The JSON representation of a Collection is an array of the
+    // models' attributes.
+    toJSON: function(options) {
+      return this.map(function(model){ return model.toJSON(options); });
+    },
+
+    // Proxy `Backbone.sync` by default.
+    sync: function() {
+      return Backbone.sync.apply(this, arguments);
+    },
+
+    // Add a model, or list of models to the set.
+    add: function(models, options) {
+      return this.set(models, _.extend({merge: false}, options, addOptions));
+    },
+
+    // Remove a model, or a list of models from the set.
+    remove: function(models, options) {
+      var singular = !_.isArray(models);
+      models = singular ? [models] : _.clone(models);
+      options || (options = {});
+      var i, l, index, model;
+      for (i = 0, l = models.length; i < l; i++) {
+        model = models[i] = this.get(models[i]);
+        if (!model) continue;
+        delete this._byId[model.id];
+        delete this._byId[model.cid];
+        index = this.indexOf(model);
+        this.models.splice(index, 1);
+        this.length--;
+        if (!options.silent) {
+          options.index = index;
+          model.trigger('remove', model, this, options);
+        }
+        this._removeReference(model, options);
+      }
+      return singular ? models[0] : models;
+    },
+
+    // Update a collection by `set`-ing a new list of models, adding new ones,
+    // removing models that are no longer present, and merging models that
+    // already exist in the collection, as necessary. Similar to **Model#set**,
+    // the core operation for updating the data contained by the collection.
+    set: function(models, options) {
+      options = _.defaults({}, options, setOptions);
+      if (options.parse) models = this.parse(models, options);
+      var singular = !_.isArray(models);
+      models = singular ? (models ? [models] : []) : _.clone(models);
+      var i, l, id, model, attrs, existing, sort;
+      var at = options.at;
+      var targetModel = this.model;
+      var sortable = this.comparator && (at == null) && options.sort !== false;
+      var sortAttr = _.isString(this.comparator) ? this.comparator : null;
+      var toAdd = [], toRemove = [], modelMap = {};
+      var add = options.add, merge = options.merge, remove = options.remove;
+      var order = !sortable && add && remove ? [] : false;
+
+      // Turn bare objects into model references, and prevent invalid models
+      // from being added.
+      for (i = 0, l = models.length; i < l; i++) {
+        attrs = models[i] || {};
+        if (attrs instanceof Model) {
+          id = model = attrs;
+        } else {
+          id = attrs[targetModel.prototype.idAttribute || 'id'];
+        }
+
+        // If a duplicate is found, prevent it from being added and
+        // optionally merge it into the existing model.
+        if (existing = this.get(id)) {
+          if (remove) modelMap[existing.cid] = true;
+          if (merge) {
+            attrs = attrs === model ? model.attributes : attrs;
+            if (options.parse) attrs = existing.parse(attrs, options);
+            existing.set(attrs, options);
+            if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true;
+          }
+          models[i] = existing;
+
+        // If this is a new, valid model, push it to the `toAdd` list.
+        } else if (add) {
+          model = models[i] = this._prepareModel(attrs, options);
+          if (!model) continue;
+          toAdd.push(model);
+          this._addReference(model, options);
+        }
+
+        // Do not add multiple models with the same `id`.
+        model = existing || model;
+        if (order && (model.isNew() || !modelMap[model.id])) order.push(model);
+        modelMap[model.id] = true;
+      }
+
+      // Remove nonexistent models if appropriate.
+      if (remove) {
+        for (i = 0, l = this.length; i < l; ++i) {
+          if (!modelMap[(model = this.models[i]).cid]) toRemove.push(model);
+        }
+        if (toRemove.length) this.remove(toRemove, options);
+      }
+
+      // See if sorting is needed, update `length` and splice in new models.
+      if (toAdd.length || (order && order.length)) {
+        if (sortable) sort = true;
+        this.length += toAdd.length;
+        if (at != null) {
+          for (i = 0, l = toAdd.length; i < l; i++) {
+            this.models.splice(at + i, 0, toAdd[i]);
+          }
+        } else {
+          if (order) this.models.length = 0;
+          var orderedModels = order || toAdd;
+          for (i = 0, l = orderedModels.length; i < l; i++) {
+            this.models.push(orderedModels[i]);
+          }
+        }
+      }
+
+      // Silently sort the collection if appropriate.
+      if (sort) this.sort({silent: true});
+
+      // Unless silenced, it's time to fire all appropriate add/sort events.
+      if (!options.silent) {
+        for (i = 0, l = toAdd.length; i < l; i++) {
+          (model = toAdd[i]).trigger('add', model, this, options);
+        }
+        if (sort || (order && order.length)) this.trigger('sort', this, options);
+      }
+
+      // Return the added (or merged) model (or models).
+      return singular ? models[0] : models;
+    },
+
+    // When you have more items than you want to add or remove individually,
+    // you can reset the entire set with a new list of models, without firing
+    // any granular `add` or `remove` events. Fires `reset` when finished.
+    // Useful for bulk operations and optimizations.
+    reset: function(models, options) {
+      options || (options = {});
+      for (var i = 0, l = this.models.length; i < l; i++) {
+        this._removeReference(this.models[i], options);
+      }
+      options.previousModels = this.models;
+      this._reset();
+      models = this.add(models, _.extend({silent: true}, options));
+      if (!options.silent) this.trigger('reset', this, options);
+      return models;
+    },
+
+    // Add a model to the end of the collection.
+    push: function(model, options) {
+      return this.add(model, _.extend({at: this.length}, options));
+    },
+
+    // Remove a model from the end of the collection.
+    pop: function(options) {
+      var model = this.at(this.length - 1);
+      this.remove(model, options);
+      return model;
+    },
+
+    // Add a model to the beginning of the collection.
+    unshift: function(model, options) {
+      return this.add(model, _.extend({at: 0}, options));
+    },
+
+    // Remove a model from the beginning of the collection.
+    shift: function(options) {
+      var model = this.at(0);
+      this.remove(model, options);
+      return model;
+    },
+
+    // Slice out a sub-array of models from the collection.
+    slice: function() {
+      return slice.apply(this.models, arguments);
+    },
+
+    // Get a model from the set by id.
+    get: function(obj) {
+      if (obj == null) return void 0;
+      return this._byId[obj] || this._byId[obj.id] || this._byId[obj.cid];
+    },
+
+    // Get the model at the given index.
+    at: function(index) {
+      return this.models[index];
+    },
+
+    // Return models with matching attributes. Useful for simple cases of
+    // `filter`.
+    where: function(attrs, first) {
+      if (_.isEmpty(attrs)) return first ? void 0 : [];
+      return this[first ? 'find' : 'filter'](function(model) {
+        for (var key in attrs) {
+          if (attrs[key] !== model.get(key)) return false;
+        }
+        return true;
+      });
+    },
+
+    // Return the first model with matching attributes. Useful for simple cases
+    // of `find`.
+    findWhere: function(attrs) {
+      return this.where(attrs, true);
+    },
+
+    // Force the collection to re-sort itself. You don't need to call this under
+    // normal circumstances, as the set will maintain sort order as each item
+    // is added.
+    sort: function(options) {
+      if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
+      options || (options = {});
+
+      // Run sort based on type of `comparator`.
+      if (_.isString(this.comparator) || this.comparator.length === 1) {
+        this.models = this.sortBy(this.comparator, this);
+      } else {
+        this.models.sort(_.bind(this.comparator, this));
+      }
+
+      if (!options.silent) this.trigger('sort', this, options);
+      return this;
+    },
+
+    // Pluck an attribute from each model in the collection.
+    pluck: function(attr) {
+      return _.invoke(this.models, 'get', attr);
+    },
+
+    // Fetch the default set of models for this collection, resetting the
+    // collection when they arrive. If `reset: true` is passed, the response
+    // data will be passed through the `reset` method instead of `set`.
+    fetch: function(options) {
+      options = options ? _.clone(options) : {};
+      if (options.parse === void 0) options.parse = true;
+      var success = options.success;
+      var collection = this;
+      options.success = function(resp) {
+        var method = options.reset ? 'reset' : 'set';
+        collection[method](resp, options);
+        if (success) success(collection, resp, options);
+        collection.trigger('sync', collection, resp, options);
+      };
+      wrapError(this, options);
+      return this.sync('read', this, options);
+    },
+
+    // Create a new instance of a model in this collection. Add the model to the
+    // collection immediately, unless `wait: true` is passed, in which case we
+    // wait for the server to agree.
+    create: function(model, options) {
+      options = options ? _.clone(options) : {};
+      if (!(model = this._prepareModel(model, options))) return false;
+      if (!options.wait) this.add(model, options);
+      var collection = this;
+      var success = options.success;
+      options.success = function(model, resp) {
+        if (options.wait) collection.add(model, options);
+        if (success) success(model, resp, options);
+      };
+      model.save(null, options);
+      return model;
+    },
+
+    // **parse** converts a response into a list of models to be added to the
+    // collection. The default implementation is just to pass it through.
+    parse: function(resp, options) {
+      return resp;
+    },
+
+    // Create a new collection with an identical list of models as this one.
+    clone: function() {
+      return new this.constructor(this.models);
+    },
+
+    // Private method to reset all internal state. Called when the collection
+    // is first initialized or reset.
+    _reset: function() {
+      this.length = 0;
+      this.models = [];
+      this._byId  = {};
+    },
+
+    // Prepare a hash of attributes (or other model) to be added to this
+    // collection.
+    _prepareModel: function(attrs, options) {
+      if (attrs instanceof Model) return attrs;
+      options = options ? _.clone(options) : {};
+      options.collection = this;
+      var model = new this.model(attrs, options);
+      if (!model.validationError) return model;
+      this.trigger('invalid', this, model.validationError, options);
+      return false;
+    },
+
+    // Internal method to create a model's ties to a collection.
+    _addReference: function(model, options) {
+      this._byId[model.cid] = model;
+      if (model.id != null) this._byId[model.id] = model;
+      if (!model.collection) model.collection = this;
+      model.on('all', this._onModelEvent, this);
+    },
+
+    // Internal method to sever a model's ties to a collection.
+    _removeReference: function(model, options) {
+      if (this === model.collection) delete model.collection;
+      model.off('all', this._onModelEvent, this);
+    },
+
+    // Internal method called every time a model in the set fires an event.
+    // Sets need to update their indexes when models change ids. All other
+    // events simply proxy through. "add" and "remove" events that originate
+    // in other collections are ignored.
+    _onModelEvent: function(event, model, collection, options) {
+      if ((event === 'add' || event === 'remove') && collection !== this) return;
+      if (event === 'destroy') this.remove(model, options);
+      if (model && event === 'change:' + model.idAttribute) {
+        delete this._byId[model.previous(model.idAttribute)];
+        if (model.id != null) this._byId[model.id] = model;
+      }
+      this.trigger.apply(this, arguments);
+    }
+
+  });
+
+  // Underscore methods that we want to implement on the Collection.
+  // 90% of the core usefulness of Backbone Collections is actually implemented
+  // right here:
+  var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl',
+    'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
+    'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
+    'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
+    'tail', 'drop', 'last', 'without', 'difference', 'indexOf', 'shuffle',
+    'lastIndexOf', 'isEmpty', 'chain', 'sample'];
+
+  // Mix in each Underscore method as a proxy to `Collection#models`.
+  _.each(methods, function(method) {
+    Collection.prototype[method] = function() {
+      var args = slice.call(arguments);
+      args.unshift(this.models);
+      return _[method].apply(_, args);
+    };
+  });
+
+  // Underscore methods that take a property name as an argument.
+  var attributeMethods = ['groupBy', 'countBy', 'sortBy', 'indexBy'];
+
+  // Use attributes instead of properties.
+  _.each(attributeMethods, function(method) {
+    Collection.prototype[method] = function(value, context) {
+      var iterator = _.isFunction(value) ? value : function(model) {
+        return model.get(value);
+      };
+      return _[method](this.models, iterator, context);
+    };
+  });
+
+  // Backbone.View
+  // -------------
+
+  // Backbone Views are almost more convention than they are actual code. A View
+  // is simply a JavaScript object that represents a logical chunk of UI in the
+  // DOM. This might be a single item, an entire list, a sidebar or panel, or
+  // even the surrounding frame which wraps your whole app. Defining a chunk of
+  // UI as a **View** allows you to define your DOM events declaratively, without
+  // having to worry about render order ... and makes it easy for the view to
+  // react to specific changes in the state of your models.
+
+  // Creating a Backbone.View creates its initial element outside of the DOM,
+  // if an existing element is not provided...
+  var View = Backbone.View = function(options) {
+    this.cid = _.uniqueId('view');
+    options || (options = {});
+    _.extend(this, _.pick(options, viewOptions));
+    this._ensureElement();
+    this.initialize.apply(this, arguments);
+    this.delegateEvents();
+  };
+
+  // Cached regex to split keys for `delegate`.
+  var delegateEventSplitter = /^(\S+)\s*(.*)$/;
+
+  // List of view options to be merged as properties.
+  var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
+
+  // Set up all inheritable **Backbone.View** properties and methods.
+  _.extend(View.prototype, Events, {
+
+    // The default `tagName` of a View's element is `"div"`.
+    tagName: 'div',
+
+    // jQuery delegate for element lookup, scoped to DOM elements within the
+    // current view. This should be preferred to global lookups where possible.
+    $: function(selector) {
+      return this.$el.find(selector);
+    },
+
+    // Initialize is an empty function by default. Override it with your own
+    // initialization logic.
+    initialize: function(){},
+
+    // **render** is the core function that your view should override, in order
+    // to populate its element (`this.el`), with the appropriate HTML. The
+    // convention is for **render** to always return `this`.
+    render: function() {
+      return this;
+    },
+
+    // Remove this view by taking the element out of the DOM, and removing any
+    // applicable Backbone.Events listeners.
+    remove: function() {
+      this.$el.remove();
+      this.stopListening();
+      return this;
+    },
+
+    // Change the view's element (`this.el` property), including event
+    // re-delegation.
+    setElement: function(element, delegate) {
+      if (this.$el) this.undelegateEvents();
+      this.$el = element instanceof Backbone.$ ? element : Backbone.$(element);
+      this.el = this.$el[0];
+      if (delegate !== false) this.delegateEvents();
+      return this;
+    },
+
+    // Set callbacks, where `this.events` is a hash of
+    //
+    // *{"event selector": "callback"}*
+    //
+    //     {
+    //       'mousedown .title':  'edit',
+    //       'click .button':     'save',
+    //       'click .open':       function(e) { ... }
+    //     }
+    //
+    // pairs. Callbacks will be bound to the view, with `this` set properly.
+    // Uses event delegation for efficiency.
+    // Omitting the selector binds the event to `this.el`.
+    // This only works for delegate-able events: not `focus`, `blur`, and
+    // not `change`, `submit`, and `reset` in Internet Explorer.
+    delegateEvents: function(events) {
+      if (!(events || (events = _.result(this, 'events')))) return this;
+      this.undelegateEvents();
+      for (var key in events) {
+        var method = events[key];
+        if (!_.isFunction(method)) method = this[events[key]];
+        if (!method) continue;
+
+        var match = key.match(delegateEventSplitter);
+        var eventName = match[1], selector = match[2];
+        method = _.bind(method, this);
+        eventName += '.delegateEvents' + this.cid;
+        if (selector === '') {
+          this.$el.on(eventName, method);
+        } else {
+          this.$el.on(eventName, selector, method);
+        }
+      }
+      return this;
+    },
+
+    // Clears all callbacks previously bound to the view with `delegateEvents`.
+    // You usually don't need to use this, but may wish to if you have multiple
+    // Backbone views attached to the same DOM element.
+    undelegateEvents: function() {
+      this.$el.off('.delegateEvents' + this.cid);
+      return this;
+    },
+
+    // Ensure that the View has a DOM element to render into.
+    // If `this.el` is a string, pass it through `$()`, take the first
+    // matching element, and re-assign it to `el`. Otherwise, create
+    // an element from the `id`, `className` and `tagName` properties.
+    _ensureElement: function() {
+      if (!this.el) {
+        var attrs = _.extend({}, _.result(this, 'attributes'));
+        if (this.id) attrs.id = _.result(this, 'id');
+        if (this.className) attrs['class'] = _.result(this, 'className');
+        var $el = Backbone.$('<' + _.result(this, 'tagName') + '>').attr(attrs);
+        this.setElement($el, false);
+      } else {
+        this.setElement(_.result(this, 'el'), false);
+      }
+    }
+
+  });
+
+  // Backbone.sync
+  // -------------
+
+  // Override this function to change the manner in which Backbone persists
+  // models to the server. You will be passed the type of request, and the
+  // model in question. By default, makes a RESTful Ajax request
+  // to the model's `url()`. Some possible customizations could be:
+  //
+  // * Use `setTimeout` to batch rapid-fire updates into a single request.
+  // * Send up the models as XML instead of JSON.
+  // * Persist models via WebSockets instead of Ajax.
+  //
+  // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests
+  // as `POST`, with a `_method` parameter containing the true HTTP method,
+  // as well as all requests with the body as `application/x-www-form-urlencoded`
+  // instead of `application/json` with the model in a param named `model`.
+  // Useful when interfacing with server-side languages like **PHP** that make
+  // it difficult to read the body of `PUT` requests.
+  Backbone.sync = function(method, model, options) {
+    var type = methodMap[method];
+
+    // Default options, unless specified.
+    _.defaults(options || (options = {}), {
+      emulateHTTP: Backbone.emulateHTTP,
+      emulateJSON: Backbone.emulateJSON
+    });
+
+    // Default JSON-request options.
+    var params = {type: type, dataType: 'json'};
+
+    // Ensure that we have a URL.
+    if (!options.url) {
+      params.url = _.result(model, 'url') || urlError();
+    }
+
+    // Ensure that we have the appropriate request data.
+    if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) {
+      params.contentType = 'application/json';
+      params.data = JSON.stringify(options.attrs || model.toJSON(options));
+    }
+
+    // For older servers, emulate JSON by encoding the request into an HTML-form.
+    if (options.emulateJSON) {
+      params.contentType = 'application/x-www-form-urlencoded';
+      params.data = params.data ? {model: params.data} : {};
+    }
+
+    // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
+    // And an `X-HTTP-Method-Override` header.
+    if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) {
+      params.type = 'POST';
+      if (options.emulateJSON) params.data._method = type;
+      var beforeSend = options.beforeSend;
+      options.beforeSend = function(xhr) {
+        xhr.setRequestHeader('X-HTTP-Method-Override', type);
+        if (beforeSend) return beforeSend.apply(this, arguments);
+      };
+    }
+
+    // Don't process data on a non-GET request.
+    if (params.type !== 'GET' && !options.emulateJSON) {
+      params.processData = false;
+    }
+
+    // If we're sending a `PATCH` request, and we're in an old Internet Explorer
+    // that still has ActiveX enabled by default, override jQuery to use that
+    // for XHR instead. Remove this line when jQuery supports `PATCH` on IE8.
+    if (params.type === 'PATCH' && noXhrPatch) {
+      params.xhr = function() {
+        return new ActiveXObject("Microsoft.XMLHTTP");
+      };
+    }
+
+    // Make the request, allowing the user to override any Ajax options.
+    var xhr = options.xhr = Backbone.ajax(_.extend(params, options));
+    model.trigger('request', model, xhr, options);
+    return xhr;
+  };
+
+  var noXhrPatch =
+    typeof window !== 'undefined' && !!window.ActiveXObject &&
+      !(window.XMLHttpRequest && (new XMLHttpRequest).dispatchEvent);
+
+  // Map from CRUD to HTTP for our default `Backbone.sync` implementation.
+  var methodMap = {
+    'create': 'POST',
+    'update': 'PUT',
+    'patch':  'PATCH',
+    'delete': 'DELETE',
+    'read':   'GET'
+  };
+
+  // Set the default implementation of `Backbone.ajax` to proxy through to `$`.
+  // Override this if you'd like to use a different library.
+  Backbone.ajax = function() {
+    return Backbone.$.ajax.apply(Backbone.$, arguments);
+  };
+
+  // Backbone.Router
+  // ---------------
+
+  // Routers map faux-URLs to actions, and fire events when routes are
+  // matched. Creating a new one sets its `routes` hash, if not set statically.
+  var Router = Backbone.Router = function(options) {
+    options || (options = {});
+    if (options.routes) this.routes = options.routes;
+    this._bindRoutes();
+    this.initialize.apply(this, arguments);
+  };
+
+  // Cached regular expressions for matching named param parts and splatted
+  // parts of route strings.
+  var optionalParam = /\((.*?)\)/g;
+  var namedParam    = /(\(\?)?:\w+/g;
+  var splatParam    = /\*\w+/g;
+  var escapeRegExp  = /[\-{}\[\]+?.,\\\^$|#\s]/g;
+
+  // Set up all inheritable **Backbone.Router** properties and methods.
+  _.extend(Router.prototype, Events, {
+
+    // Initialize is an empty function by default. Override it with your own
+    // initialization logic.
+    initialize: function(){},
+
+    // Manually bind a single named route to a callback. For example:
+    //
+    //     this.route('search/:query/p:num', 'search', function(query, num) {
+    //       ...
+    //     });
+    //
+    route: function(route, name, callback) {
+      if (!_.isRegExp(route)) route = this._routeToRegExp(route);
+      if (_.isFunction(name)) {
+        callback = name;
+        name = '';
+      }
+      if (!callback) callback = this[name];
+      var router = this;
+      Backbone.history.route(route, function(fragment) {
+        var args = router._extractParameters(route, fragment);
+        router.execute(callback, args);
+        router.trigger.apply(router, ['route:' + name].concat(args));
+        router.trigger('route', name, args);
+        Backbone.history.trigger('route', router, name, args);
+      });
+      return this;
+    },
+
+    // Execute a route handler with the provided parameters.  This is an
+    // excellent place to do pre-route setup or post-route cleanup.
+    execute: function(callback, args) {
+      if (callback) callback.apply(this, args);
+    },
+
+    // Simple proxy to `Backbone.history` to save a fragment into the history.
+    navigate: function(fragment, options) {
+      Backbone.history.navigate(fragment, options);
+      return this;
+    },
+
+    // Bind all defined routes to `Backbone.history`. We have to reverse the
+    // order of the routes here to support behavior where the most general
+    // routes can be defined at the bottom of the route map.
+    _bindRoutes: function() {
+      if (!this.routes) return;
+      this.routes = _.result(this, 'routes');
+      var route, routes = _.keys(this.routes);
+      while ((route = routes.pop()) != null) {
+        this.route(route, this.routes[route]);
+      }
+    },
+
+    // Convert a route string into a regular expression, suitable for matching
+    // against the current location hash.
+    _routeToRegExp: function(route) {
+      route = route.replace(escapeRegExp, '\\$&')
+                   .replace(optionalParam, '(?:$1)?')
+                   .replace(namedParam, function(match, optional) {
+                     return optional ? match : '([^/?]+)';
+                   })
+                   .replace(splatParam, '([^?]*?)');
+      return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$');
+    },
+
+    // Given a route, and a URL fragment that it matches, return the array of
+    // extracted decoded parameters. Empty or unmatched parameters will be
+    // treated as `null` to normalize cross-browser behavior.
+    _extractParameters: function(route, fragment) {
+      var params = route.exec(fragment).slice(1);
+      return _.map(params, function(param, i) {
+        // Don't decode the search params.
+        if (i === params.length - 1) return param || null;
+        return param ? decodeURIComponent(param) : null;
+      });
+    }
+
+  });
+
+  // Backbone.History
+  // ----------------
+
+  // Handles cross-browser history management, based on either
+  // [pushState](http://diveintohtml5.info/history.html) and real URLs, or
+  // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange)
+  // and URL fragments. If the browser supports neither (old IE, natch),
+  // falls back to polling.
+  var History = Backbone.History = function() {
+    this.handlers = [];
+    _.bindAll(this, 'checkUrl');
+
+    // Ensure that `History` can be used outside of the browser.
+    if (typeof window !== 'undefined') {
+      this.location = window.location;
+      this.history = window.history;
+    }
+  };
+
+  // Cached regex for stripping a leading hash/slash and trailing space.
+  var routeStripper = /^[#\/]|\s+$/g;
+
+  // Cached regex for stripping leading and trailing slashes.
+  var rootStripper = /^\/+|\/+$/g;
+
+  // Cached regex for detecting MSIE.
+  var isExplorer = /msie [\w.]+/;
+
+  // Cached regex for removing a trailing slash.
+  var trailingSlash = /\/$/;
+
+  // Cached regex for stripping urls of hash.
+  var pathStripper = /#.*$/;
+
+  // Has the history handling already been started?
+  History.started = false;
+
+  // Set up all inheritable **Backbone.History** properties and methods.
+  _.extend(History.prototype, Events, {
+
+    // The default interval to poll for hash changes, if necessary, is
+    // twenty times a second.
+    interval: 50,
+
+    // Are we at the app root?
+    atRoot: function() {
+      return this.location.pathname.replace(/[^\/]$/, '$&/') === this.root;
+    },
+
+    // Gets the true hash value. Cannot use location.hash directly due to bug
+    // in Firefox where location.hash will always be decoded.
+    getHash: function(window) {
+      var match = (window || this).location.href.match(/#(.*)$/);
+      return match ? match[1] : '';
+    },
+
+    // Get the cross-browser normalized URL fragment, either from the URL,
+    // the hash, or the override.
+    getFragment: function(fragment, forcePushState) {
+      if (fragment == null) {
+        if (this._hasPushState || !this._wantsHashChange || forcePushState) {
+          fragment = decodeURI(this.location.pathname + this.location.search);
+          var root = this.root.replace(trailingSlash, '');
+          if (!fragment.indexOf(root)) fragment = fragment.slice(root.length);
+        } else {
+          fragment = this.getHash();
+        }
+      }
+      return fragment.replace(routeStripper, '');
+    },
+
+    // Start the hash change handling, returning `true` if the current URL matches
+    // an existing route, and `false` otherwise.
+    start: function(options) {
+      if (History.started) throw new Error("Backbone.history has already been started");
+      History.started = true;
+
+      // Figure out the initial configuration. Do we need an iframe?
+      // Is pushState desired ... is it available?
+      this.options          = _.extend({root: '/'}, this.options, options);
+      this.root             = this.options.root;
+      this._wantsHashChange = this.options.hashChange !== false;
+      this._wantsPushState  = !!this.options.pushState;
+      this._hasPushState    = !!(this.options.pushState && this.history && this.history.pushState);
+      var fragment          = this.getFragment();
+      var docMode           = document.documentMode;
+      var oldIE             = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
+
+      // Normalize root to always include a leading and trailing slash.
+      this.root = ('/' + this.root + '/').replace(rootStripper, '/');
+
+      if (oldIE && this._wantsHashChange) {
+        var frame = Backbone.$('<iframe src="javascript:0" tabindex="-1">');
+        this.iframe = frame.hide().appendTo('body')[0].contentWindow;
+        this.navigate(fragment);
+      }
+
+      // Depending on whether we're using pushState or hashes, and whether
+      // 'onhashchange' is supported, determine how we check the URL state.
+      if (this._hasPushState) {
+        Backbone.$(window).on('popstate', this.checkUrl);
+      } else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) {
+        Backbone.$(window).on('hashchange', this.checkUrl);
+      } else if (this._wantsHashChange) {
+        this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
+      }
+
+      // Determine if we need to change the base url, for a pushState link
+      // opened by a non-pushState browser.
+      this.fragment = fragment;
+      var loc = this.location;
+
+      // Transition from hashChange to pushState or vice versa if both are
+      // requested.
+      if (this._wantsHashChange && this._wantsPushState) {
+
+        // If we've started off with a route from a `pushState`-enabled
+        // browser, but we're currently in a browser that doesn't support it...
+        if (!this._hasPushState && !this.atRoot()) {
+          this.fragment = this.getFragment(null, true);
+          this.location.replace(this.root + '#' + this.fragment);
+          // Return immediately as browser will do redirect to new url
+          return true;
+
+        // Or if we've started out with a hash-based route, but we're currently
+        // in a browser where it could be `pushState`-based instead...
+        } else if (this._hasPushState && this.atRoot() && loc.hash) {
+          this.fragment = this.getHash().replace(routeStripper, '');
+          this.history.replaceState({}, document.title, this.root + this.fragment);
+        }
+
+      }
+
+      if (!this.options.silent) return this.loadUrl();
+    },
+
+    // Disable Backbone.history, perhaps temporarily. Not useful in a real app,
+    // but possibly useful for unit testing Routers.
+    stop: function() {
+      Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl);
+      if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
+      History.started = false;
+    },
+
+    // Add a route to be tested when the fragment changes. Routes added later
+    // may override previous routes.
+    route: function(route, callback) {
+      this.handlers.unshift({route: route, callback: callback});
+    },
+
+    // Checks the current URL to see if it has changed, and if it has,
+    // calls `loadUrl`, normalizing across the hidden iframe.
+    checkUrl: function(e) {
+      var current = this.getFragment();
+      if (current === this.fragment && this.iframe) {
+        current = this.getFragment(this.getHash(this.iframe));
+      }
+      if (current === this.fragment) return false;
+      if (this.iframe) this.navigate(current);
+      this.loadUrl();
+    },
+
+    // Attempt to load the current URL fragment. If a route succeeds with a
+    // match, returns `true`. If no defined routes matches the fragment,
+    // returns `false`.
+    loadUrl: function(fragment) {
+      fragment = this.fragment = this.getFragment(fragment);
+      return _.any(this.handlers, function(handler) {
+        if (handler.route.test(fragment)) {
+          handler.callback(fragment);
+          return true;
+        }
+      });
+    },
+
+    // Save a fragment into the hash history, or replace the URL state if the
+    // 'replace' option is passed. You are responsible for properly URL-encoding
+    // the fragment in advance.
+    //
+    // The options object can contain `trigger: true` if you wish to have the
+    // route callback be fired (not usually desirable), or `replace: true`, if
+    // you wish to modify the current URL without adding an entry to the history.
+    navigate: function(fragment, options) {
+      if (!History.started) return false;
+      if (!options || options === true) options = {trigger: !!options};
+
+      var url = this.root + (fragment = this.getFragment(fragment || ''));
+
+      // Strip the hash for matching.
+      fragment = fragment.replace(pathStripper, '');
+
+      if (this.fragment === fragment) return;
+      this.fragment = fragment;
+
+      // Don't include a trailing slash on the root.
+      if (fragment === '' && url !== '/') url = url.slice(0, -1);
+
+      // If pushState is available, we use it to set the fragment as a real URL.
+      if (this._hasPushState) {
+        this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url);
+
+      // If hash changes haven't been explicitly disabled, update the hash
+      // fragment to store history.
+      } else if (this._wantsHashChange) {
+        this._updateHash(this.location, fragment, options.replace);
+        if (this.iframe && (fragment !== this.getFragment(this.getHash(this.iframe)))) {
+          // Opening and closing the iframe tricks IE7 and earlier to push a
+          // history entry on hash-tag change.  When replace is true, we don't
+          // want this.
+          if(!options.replace) this.iframe.document.open().close();
+          this._updateHash(this.iframe.location, fragment, options.replace);
+        }
+
+      // If you've told us that you explicitly don't want fallback hashchange-
+      // based history, then `navigate` becomes a page refresh.
+      } else {
+        return this.location.assign(url);
+      }
+      if (options.trigger) return this.loadUrl(fragment);
+    },
+
+    // Update the hash location, either replacing the current entry, or adding
+    // a new one to the browser history.
+    _updateHash: function(location, fragment, replace) {
+      if (replace) {
+        var href = location.href.replace(/(javascript:|#).*$/, '');
+        location.replace(href + '#' + fragment);
+      } else {
+        // Some browsers require that `hash` contains a leading #.
+        location.hash = '#' + fragment;
+      }
+    }
+
+  });
+
+  // Create the default Backbone.history.
+  Backbone.history = new History;
+
+  // Helpers
+  // -------
+
+  // Helper function to correctly set up the prototype chain, for subclasses.
+  // Similar to `goog.inherits`, but uses a hash of prototype properties and
+  // class properties to be extended.
+  var extend = function(protoProps, staticProps) {
+    var parent = this;
+    var child;
+
+    // The constructor function for the new subclass is either defined by you
+    // (the "constructor" property in your `extend` definition), or defaulted
+    // by us to simply call the parent's constructor.
+    if (protoProps && _.has(protoProps, 'constructor')) {
+      child = protoProps.constructor;
+    } else {
+      child = function(){ return parent.apply(this, arguments); };
+    }
+
+    // Add static properties to the constructor function, if supplied.
+    _.extend(child, parent, staticProps);
+
+    // Set the prototype chain to inherit from `parent`, without calling
+    // `parent`'s constructor function.
+    var Surrogate = function(){ this.constructor = child; };
+    Surrogate.prototype = parent.prototype;
+    child.prototype = new Surrogate;
+
+    // Add prototype properties (instance properties) to the subclass,
+    // if supplied.
+    if (protoProps) _.extend(child.prototype, protoProps);
+
+    // Set a convenience property in case the parent's prototype is needed
+    // later.
+    child.__super__ = parent.prototype;
+
+    return child;
+  };
+
+  // Set up inheritance for the model, collection, router, view and history.
+  Model.extend = Collection.extend = Router.extend = View.extend = History.extend = extend;
+
+  // Throw an error when a URL is needed, and none is supplied.
+  var urlError = function() {
+    throw new Error('A "url" property or function must be specified');
+  };
+
+  // Wrap an optional error callback with a fallback error event.
+  var wrapError = function(model, options) {
+    var error = options.error;
+    options.error = function(resp) {
+      if (error) error(model, resp, options);
+      model.trigger('error', model, resp, options);
+    };
+  };
+
+  return Backbone;
+
+}));

+ 195 - 0
course-design/libs/biltong-0.2.js

@@ -0,0 +1,195 @@
+/**
+ * Biltong v0.2
+ *
+ * Various geometry functions written as part of jsPlumb and perhaps useful for others.
+ *
+ * Copyright (c) 2014 Simon Porritt
+ *
+ * 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.
+ */
+;(function() {
+
+	
+	"use strict";
+
+	var Biltong = this.Biltong = {};
+
+	var _isa = function(a) { return Object.prototype.toString.call(a) === "[object Array]"; },
+		_pointHelper = function(p1, p2, fn) {
+		    p1 = _isa(p1) ? p1 : [p1.x, p1.y];
+		    p2 = _isa(p2) ? p2 : [p2.x, p2.y];    
+		    return fn(p1, p2);
+		},
+		/**
+		* @name Biltong.gradient
+		* @function
+		* @desc Calculates the gradient of a line between the two points.
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Float} The gradient of a line between the two points.
+		*/
+		_gradient = Biltong.gradient = function(p1, p2) {
+		    return _pointHelper(p1, p2, function(_p1, _p2) { 
+		        if (_p2[0] == _p1[0])
+		            return _p2[1] > _p1[1] ? Infinity : -Infinity;
+		        else if (_p2[1] == _p1[1]) 
+		            return _p2[0] > _p1[0] ? 0 : -0;
+		        else 
+		            return (_p2[1] - _p1[1]) / (_p2[0] - _p1[0]); 
+		    });		
+		},
+		/**
+		* @name Biltong.normal
+		* @function
+		* @desc Calculates the gradient of a normal to a line between the two points.
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Float} The gradient of a normal to a line between the two points.
+		*/
+		_normal = Biltong.normal = function(p1, p2) {
+		    return -1 / _gradient(p1, p2);
+		},
+		/**
+		* @name Biltong.lineLength
+		* @function
+		* @desc Calculates the length of a line between the two points.
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Float} The length of a line between the two points.
+		*/
+		_lineLength = Biltong.lineLength = function(p1, p2) {
+		    return _pointHelper(p1, p2, function(_p1, _p2) {
+		        return Math.sqrt(Math.pow(_p2[1] - _p1[1], 2) + Math.pow(_p2[0] - _p1[0], 2));			
+		    });
+		},
+		/**
+		* @name Biltong.quadrant
+		* @function
+		* @desc Calculates the quadrant in which the angle between the two points lies. 
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Integer} The quadrant - 1 for upper right, 2 for lower right, 3 for lower left, 4 for upper left.
+		*/
+		_quadrant = Biltong.quadrant = function(p1, p2) {
+		    return _pointHelper(p1, p2, function(_p1, _p2) {
+		        if (_p2[0] > _p1[0]) {
+		            return (_p2[1] > _p1[1]) ? 2 : 1;
+		        }
+		        else if (_p2[0] == _p1[0]) {
+		            return _p2[1] > _p1[1] ? 2 : 1;    
+		        }
+		        else {
+		            return (_p2[1] > _p1[1]) ? 3 : 4;
+		        }
+		    });
+		},
+		/**
+		* @name Biltong.theta
+		* @function
+		* @desc Calculates the angle between the two points. 
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Float} The angle between the two points.
+		*/
+		_theta = Biltong.theta = function(p1, p2) {
+		    return _pointHelper(p1, p2, function(_p1, _p2) {
+		        var m = _gradient(_p1, _p2),
+		            t = Math.atan(m),
+		            s = _quadrant(_p1, _p2);
+		        if ((s == 4 || s== 3)) t += Math.PI;
+		        if (t < 0) t += (2 * Math.PI);
+		    
+		        return t;
+		    });
+		},
+		/**
+		* @name Biltong.intersects
+		* @function
+		* @desc Calculates whether or not the two rectangles intersect.
+		* @param {Rectangle} r1 First rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}`
+		* @param {Rectangle} r2 Second rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}`
+		* @return {Boolean} True if the rectangles intersect, false otherwise.
+		*/
+		_intersects = Biltong.intersects = function(r1, r2) {
+		    var x1 = r1.x, x2 = r1.x + r1.w, y1 = r1.y, y2 = r1.y + r1.h,
+		        a1 = r2.x, a2 = r2.x + r2.w, b1 = r2.y, b2 = r2.y + r2.h;
+		
+			return  ( (x1 <= a1 && a1 <= x2) && (y1 <= b1 && b1 <= y2) ) ||
+			        ( (x1 <= a2 && a2 <= x2) && (y1 <= b1 && b1 <= y2) ) ||
+			        ( (x1 <= a1 && a1 <= x2) && (y1 <= b2 && b2 <= y2) ) ||
+			        ( (x1 <= a2 && a1 <= x2) && (y1 <= b2 && b2 <= y2) ) ||	
+			        ( (a1 <= x1 && x1 <= a2) && (b1 <= y1 && y1 <= b2) ) ||
+			        ( (a1 <= x2 && x2 <= a2) && (b1 <= y1 && y1 <= b2) ) ||
+			        ( (a1 <= x1 && x1 <= a2) && (b1 <= y2 && y2 <= b2) ) ||
+			        ( (a1 <= x2 && x1 <= a2) && (b1 <= y2 && y2 <= b2) );
+		},
+		/**
+		* @name Biltong.encloses
+		* @function
+		* @desc Calculates whether or not r2 is completely enclosed by r1.
+		* @param {Rectangle} r1 First rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}`
+		* @param {Rectangle} r2 Second rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}`
+		* @param {Boolean} [allowSharedEdges=false] If true, the concept of enclosure allows for one or more edges to be shared by the two rectangles.
+		* @return {Boolean} True if r1 encloses r2, false otherwise.
+		*/
+		_encloses = Biltong.encloses = function(r1, r2, allowSharedEdges) {
+			var x1 = r1.x, x2 = r1.x + r1.w, y1 = r1.y, y2 = r1.y + r1.h,
+		        a1 = r2.x, a2 = r2.x + r2.w, b1 = r2.y, b2 = r2.y + r2.h,
+				c = function(v1, v2, v3, v4) { return allowSharedEdges ? v1 <= v2 && v3>= v4 : v1 < v2 && v3 > v4; };
+				
+			return c(x1,a1,x2,a2) && c(y1,b1,y2,b2);
+		},
+		_segmentMultipliers = [null, [1, -1], [1, 1], [-1, 1], [-1, -1] ],
+		_inverseSegmentMultipliers = [null, [-1, -1], [-1, 1], [1, 1], [1, -1] ],
+		/**
+		* @name Biltong.pointOnLine
+		* @function
+		* @desc Calculates a point on the line from `fromPoint` to `toPoint` that is `distance` units along the length of the line.
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Point} Point on the line, in the form `{ x:..., y:... }`.
+		*/
+		_pointOnLine = Biltong.pointOnLine = function(fromPoint, toPoint, distance) {
+		    var m = _gradient(fromPoint, toPoint),
+		        s = _quadrant(fromPoint, toPoint),
+		        segmentMultiplier = distance > 0 ? _segmentMultipliers[s] : _inverseSegmentMultipliers[s],
+		        theta = Math.atan(m),
+		        y = Math.abs(distance * Math.sin(theta)) * segmentMultiplier[1],
+		        x =  Math.abs(distance * Math.cos(theta)) * segmentMultiplier[0];
+		    return { x:fromPoint.x + x, y:fromPoint.y + y };
+		},
+		/**
+		* @name Biltong.perpendicularLineTo
+		* @function
+		* @desc Calculates a line of length `length` that is perpendicular to the line from `fromPoint` to `toPoint` and passes through `toPoint`.
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Line} Perpendicular line, in the form `[ { x:..., y:... }, { x:..., y:... } ]`.
+		*/        
+		_perpendicularLineTo = Biltong.perpendicularLineTo = function(fromPoint, toPoint, length) {
+		    var m = _gradient(fromPoint, toPoint),
+		        theta2 = Math.atan(-1 / m),
+		        y =  length / 2 * Math.sin(theta2),
+		        x =  length / 2 * Math.cos(theta2);
+		    return [{x:toPoint.x + x, y:toPoint.y + y}, {x:toPoint.x - x, y:toPoint.y - y}];
+		};	
+}).call(this);

File diff suppressed because it is too large
+ 0 - 0
course-design/libs/bootstrap-treeview.min.js


+ 2276 - 0
course-design/libs/bootstrap.js

@@ -0,0 +1,2276 @@
+/*!
+ * Bootstrap v3.3.0 (http://getbootstrap.com)
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ */
+
+if (typeof jQuery === 'undefined') {
+  throw new Error('Bootstrap\'s JavaScript requires jQuery')
+}
+
++function ($) {
+  var version = $.fn.jquery.split(' ')[0].split('.')
+  if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1)) {
+    throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher')
+  }
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: transition.js v3.3.0
+ * http://getbootstrap.com/javascript/#transitions
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
+  // ============================================================
+
+  function transitionEnd() {
+    var el = document.createElement('bootstrap')
+
+    var transEndEventNames = {
+      WebkitTransition : 'webkitTransitionEnd',
+      MozTransition    : 'transitionend',
+      OTransition      : 'oTransitionEnd otransitionend',
+      transition       : 'transitionend'
+    }
+
+    for (var name in transEndEventNames) {
+      if (el.style[name] !== undefined) {
+        return { end: transEndEventNames[name] }
+      }
+    }
+
+    return false // explicit for ie8 (  ._.)
+  }
+
+  // http://blog.alexmaccaw.com/css-transitions
+  $.fn.emulateTransitionEnd = function (duration) {
+    var called = false
+    var $el = this
+    $(this).one('bsTransitionEnd', function () { called = true })
+    var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
+    setTimeout(callback, duration)
+    return this
+  }
+
+  $(function () {
+    $.support.transition = transitionEnd()
+
+    if (!$.support.transition) return
+
+    $.event.special.bsTransitionEnd = {
+      bindType: $.support.transition.end,
+      delegateType: $.support.transition.end,
+      handle: function (e) {
+        if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
+      }
+    }
+  })
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: alert.js v3.3.0
+ * http://getbootstrap.com/javascript/#alerts
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // ALERT CLASS DEFINITION
+  // ======================
+
+  var dismiss = '[data-dismiss="alert"]'
+  var Alert   = function (el) {
+    $(el).on('click', dismiss, this.close)
+  }
+
+  Alert.VERSION = '3.3.0'
+
+  Alert.TRANSITION_DURATION = 150
+
+  Alert.prototype.close = function (e) {
+    var $this    = $(this)
+    var selector = $this.attr('data-target')
+
+    if (!selector) {
+      selector = $this.attr('href')
+      selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
+    }
+
+    var $parent = $(selector)
+
+    if (e) e.preventDefault()
+
+    if (!$parent.length) {
+      $parent = $this.closest('.alert')
+    }
+
+    $parent.trigger(e = $.Event('close.bs.alert'))
+
+    if (e.isDefaultPrevented()) return
+
+    $parent.removeClass('in')
+
+    function removeElement() {
+      // detach from parent, fire event then clean up data
+      $parent.detach().trigger('closed.bs.alert').remove()
+    }
+
+    $.support.transition && $parent.hasClass('fade') ?
+      $parent
+        .one('bsTransitionEnd', removeElement)
+        .emulateTransitionEnd(Alert.TRANSITION_DURATION) :
+      removeElement()
+  }
+
+
+  // ALERT PLUGIN DEFINITION
+  // =======================
+
+  function Plugin(option) {
+    return this.each(function () {
+      var $this = $(this)
+      var data  = $this.data('bs.alert')
+
+      if (!data) $this.data('bs.alert', (data = new Alert(this)))
+      if (typeof option == 'string') data[option].call($this)
+    })
+  }
+
+  var old = $.fn.alert
+
+  $.fn.alert             = Plugin
+  $.fn.alert.Constructor = Alert
+
+
+  // ALERT NO CONFLICT
+  // =================
+
+  $.fn.alert.noConflict = function () {
+    $.fn.alert = old
+    return this
+  }
+
+
+  // ALERT DATA-API
+  // ==============
+
+  $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: button.js v3.3.0
+ * http://getbootstrap.com/javascript/#buttons
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // BUTTON PUBLIC CLASS DEFINITION
+  // ==============================
+
+  var Button = function (element, options) {
+    this.$element  = $(element)
+    this.options   = $.extend({}, Button.DEFAULTS, options)
+    this.isLoading = false
+  }
+
+  Button.VERSION  = '3.3.0'
+
+  Button.DEFAULTS = {
+    loadingText: 'loading...'
+  }
+
+  Button.prototype.setState = function (state) {
+    var d    = 'disabled'
+    var $el  = this.$element
+    var val  = $el.is('input') ? 'val' : 'html'
+    var data = $el.data()
+
+    state = state + 'Text'
+
+    if (data.resetText == null) $el.data('resetText', $el[val]())
+
+    // push to event loop to allow forms to submit
+    setTimeout($.proxy(function () {
+      $el[val](data[state] == null ? this.options[state] : data[state])
+
+      if (state == 'loadingText') {
+        this.isLoading = true
+        $el.addClass(d).attr(d, d)
+      } else if (this.isLoading) {
+        this.isLoading = false
+        $el.removeClass(d).removeAttr(d)
+      }
+    }, this), 0)
+  }
+
+  Button.prototype.toggle = function () {
+    var changed = true
+    var $parent = this.$element.closest('[data-toggle="buttons"]')
+
+    if ($parent.length) {
+      var $input = this.$element.find('input')
+      if ($input.prop('type') == 'radio') {
+        if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
+        else $parent.find('.active').removeClass('active')
+      }
+      if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
+    } else {
+      this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
+    }
+
+    if (changed) this.$element.toggleClass('active')
+  }
+
+
+  // BUTTON PLUGIN DEFINITION
+  // ========================
+
+  function Plugin(option) {
+    return this.each(function () {
+      var $this   = $(this)
+      var data    = $this.data('bs.button')
+      var options = typeof option == 'object' && option
+
+      if (!data) $this.data('bs.button', (data = new Button(this, options)))
+
+      if (option == 'toggle') data.toggle()
+      else if (option) data.setState(option)
+    })
+  }
+
+  var old = $.fn.button
+
+  $.fn.button             = Plugin
+  $.fn.button.Constructor = Button
+
+
+  // BUTTON NO CONFLICT
+  // ==================
+
+  $.fn.button.noConflict = function () {
+    $.fn.button = old
+    return this
+  }
+
+
+  // BUTTON DATA-API
+  // ===============
+
+  $(document)
+    .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
+      var $btn = $(e.target)
+      if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
+      Plugin.call($btn, 'toggle')
+      e.preventDefault()
+    })
+    .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
+      $(e.target).closest('.btn').toggleClass('focus', e.type == 'focus')
+    })
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: carousel.js v3.3.0
+ * http://getbootstrap.com/javascript/#carousel
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // CAROUSEL CLASS DEFINITION
+  // =========================
+
+  var Carousel = function (element, options) {
+    this.$element    = $(element)
+    this.$indicators = this.$element.find('.carousel-indicators')
+    this.options     = options
+    this.paused      =
+    this.sliding     =
+    this.interval    =
+    this.$active     =
+    this.$items      = null
+
+    this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))
+
+    this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element
+      .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
+      .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
+  }
+
+  Carousel.VERSION  = '3.3.0'
+
+  Carousel.TRANSITION_DURATION = 600
+
+  Carousel.DEFAULTS = {
+    interval: 5000,
+    pause: 'hover',
+    wrap: true,
+    keyboard: true
+  }
+
+  Carousel.prototype.keydown = function (e) {
+    switch (e.which) {
+      case 37: this.prev(); break
+      case 39: this.next(); break
+      default: return
+    }
+
+    e.preventDefault()
+  }
+
+  Carousel.prototype.cycle = function (e) {
+    e || (this.paused = false)
+
+    this.interval && clearInterval(this.interval)
+
+    this.options.interval
+      && !this.paused
+      && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
+
+    return this
+  }
+
+  Carousel.prototype.getItemIndex = function (item) {
+    this.$items = item.parent().children('.item')
+    return this.$items.index(item || this.$active)
+  }
+
+  Carousel.prototype.getItemForDirection = function (direction, active) {
+    var delta = direction == 'prev' ? -1 : 1
+    var activeIndex = this.getItemIndex(active)
+    var itemIndex = (activeIndex + delta) % this.$items.length
+    return this.$items.eq(itemIndex)
+  }
+
+  Carousel.prototype.to = function (pos) {
+    var that        = this
+    var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
+
+    if (pos > (this.$items.length - 1) || pos < 0) return
+
+    if (this.sliding)       return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
+    if (activeIndex == pos) return this.pause().cycle()
+
+    return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos))
+  }
+
+  Carousel.prototype.pause = function (e) {
+    e || (this.paused = true)
+
+    if (this.$element.find('.next, .prev').length && $.support.transition) {
+      this.$element.trigger($.support.transition.end)
+      this.cycle(true)
+    }
+
+    this.interval = clearInterval(this.interval)
+
+    return this
+  }
+
+  Carousel.prototype.next = function () {
+    if (this.sliding) return
+    return this.slide('next')
+  }
+
+  Carousel.prototype.prev = function () {
+    if (this.sliding) return
+    return this.slide('prev')
+  }
+
+  Carousel.prototype.slide = function (type, next) {
+    var $active   = this.$element.find('.item.active')
+    var $next     = next || this.getItemForDirection(type, $active)
+    var isCycling = this.interval
+    var direction = type == 'next' ? 'left' : 'right'
+    var fallback  = type == 'next' ? 'first' : 'last'
+    var that      = this
+
+    if (!$next.length) {
+      if (!this.options.wrap) return
+      $next = this.$element.find('.item')[fallback]()
+    }
+
+    if ($next.hasClass('active')) return (this.sliding = false)
+
+    var relatedTarget = $next[0]
+    var slideEvent = $.Event('slide.bs.carousel', {
+      relatedTarget: relatedTarget,
+      direction: direction
+    })
+    this.$element.trigger(slideEvent)
+    if (slideEvent.isDefaultPrevented()) return
+
+    this.sliding = true
+
+    isCycling && this.pause()
+
+    if (this.$indicators.length) {
+      this.$indicators.find('.active').removeClass('active')
+      var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
+      $nextIndicator && $nextIndicator.addClass('active')
+    }
+
+    var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
+    if ($.support.transition && this.$element.hasClass('slide')) {
+      $next.addClass(type)
+      $next[0].offsetWidth // force reflow
+      $active.addClass(direction)
+      $next.addClass(direction)
+      $active
+        .one('bsTransitionEnd', function () {
+          $next.removeClass([type, direction].join(' ')).addClass('active')
+          $active.removeClass(['active', direction].join(' '))
+          that.sliding = false
+          setTimeout(function () {
+            that.$element.trigger(slidEvent)
+          }, 0)
+        })
+        .emulateTransitionEnd(Carousel.TRANSITION_DURATION)
+    } else {
+      $active.removeClass('active')
+      $next.addClass('active')
+      this.sliding = false
+      this.$element.trigger(slidEvent)
+    }
+
+    isCycling && this.cycle()
+
+    return this
+  }
+
+
+  // CAROUSEL PLUGIN DEFINITION
+  // ==========================
+
+  function Plugin(option) {
+    return this.each(function () {
+      var $this   = $(this)
+      var data    = $this.data('bs.carousel')
+      var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
+      var action  = typeof option == 'string' ? option : options.slide
+
+      if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
+      if (typeof option == 'number') data.to(option)
+      else if (action) data[action]()
+      else if (options.interval) data.pause().cycle()
+    })
+  }
+
+  var old = $.fn.carousel
+
+  $.fn.carousel             = Plugin
+  $.fn.carousel.Constructor = Carousel
+
+
+  // CAROUSEL NO CONFLICT
+  // ====================
+
+  $.fn.carousel.noConflict = function () {
+    $.fn.carousel = old
+    return this
+  }
+
+
+  // CAROUSEL DATA-API
+  // =================
+
+  var clickHandler = function (e) {
+    var href
+    var $this   = $(this)
+    var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
+    if (!$target.hasClass('carousel')) return
+    var options = $.extend({}, $target.data(), $this.data())
+    var slideIndex = $this.attr('data-slide-to')
+    if (slideIndex) options.interval = false
+
+    Plugin.call($target, options)
+
+    if (slideIndex) {
+      $target.data('bs.carousel').to(slideIndex)
+    }
+
+    e.preventDefault()
+  }
+
+  $(document)
+    .on('click.bs.carousel.data-api', '[data-slide]', clickHandler)
+    .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler)
+
+  $(window).on('load', function () {
+    $('[data-ride="carousel"]').each(function () {
+      var $carousel = $(this)
+      Plugin.call($carousel, $carousel.data())
+    })
+  })
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: collapse.js v3.3.0
+ * http://getbootstrap.com/javascript/#collapse
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // COLLAPSE PUBLIC CLASS DEFINITION
+  // ================================
+
+  var Collapse = function (element, options) {
+    this.$element      = $(element)
+    this.options       = $.extend({}, Collapse.DEFAULTS, options)
+    this.$trigger      = $(this.options.trigger).filter('[href="#' + element.id + '"], [data-target="#' + element.id + '"]')
+    this.transitioning = null
+
+    if (this.options.parent) {
+      this.$parent = this.getParent()
+    } else {
+      this.addAriaAndCollapsedClass(this.$element, this.$trigger)
+    }
+
+    if (this.options.toggle) this.toggle()
+  }
+
+  Collapse.VERSION  = '3.3.0'
+
+  Collapse.TRANSITION_DURATION = 350
+
+  Collapse.DEFAULTS = {
+    toggle: true,
+    trigger: '[data-toggle="collapse"]'
+  }
+
+  Collapse.prototype.dimension = function () {
+    var hasWidth = this.$element.hasClass('width')
+    return hasWidth ? 'width' : 'height'
+  }
+
+  Collapse.prototype.show = function () {
+    if (this.transitioning || this.$element.hasClass('in')) return
+
+    var activesData
+    var actives = this.$parent && this.$parent.find('> .panel').children('.in, .collapsing')
+
+    if (actives && actives.length) {
+      activesData = actives.data('bs.collapse')
+      if (activesData && activesData.transitioning) return
+    }
+
+    var startEvent = $.Event('show.bs.collapse')
+    this.$element.trigger(startEvent)
+    if (startEvent.isDefaultPrevented()) return
+
+    if (actives && actives.length) {
+      Plugin.call(actives, 'hide')
+      activesData || actives.data('bs.collapse', null)
+    }
+
+    var dimension = this.dimension()
+
+    this.$element
+      .removeClass('collapse')
+      .addClass('collapsing')[dimension](0)
+      .attr('aria-expanded', true)
+
+    this.$trigger
+      .removeClass('collapsed')
+      .attr('aria-expanded', true)
+
+    this.transitioning = 1
+
+    var complete = function () {
+      this.$element
+        .removeClass('collapsing')
+        .addClass('collapse in')[dimension]('')
+      this.transitioning = 0
+      this.$element
+        .trigger('shown.bs.collapse')
+    }
+
+    if (!$.support.transition) return complete.call(this)
+
+    var scrollSize = $.camelCase(['scroll', dimension].join('-'))
+
+    this.$element
+      .one('bsTransitionEnd', $.proxy(complete, this))
+      .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize])
+  }
+
+  Collapse.prototype.hide = function () {
+    if (this.transitioning || !this.$element.hasClass('in')) return
+
+    var startEvent = $.Event('hide.bs.collapse')
+    this.$element.trigger(startEvent)
+    if (startEvent.isDefaultPrevented()) return
+
+    var dimension = this.dimension()
+
+    this.$element[dimension](this.$element[dimension]())[0].offsetHeight
+
+    this.$element
+      .addClass('collapsing')
+      .removeClass('collapse in')
+      .attr('aria-expanded', false)
+
+    this.$trigger
+      .addClass('collapsed')
+      .attr('aria-expanded', false)
+
+    this.transitioning = 1
+
+    var complete = function () {
+      this.transitioning = 0
+      this.$element
+        .removeClass('collapsing')
+        .addClass('collapse')
+        .trigger('hidden.bs.collapse')
+    }
+
+    if (!$.support.transition) return complete.call(this)
+
+    this.$element
+      [dimension](0)
+      .one('bsTransitionEnd', $.proxy(complete, this))
+      .emulateTransitionEnd(Collapse.TRANSITION_DURATION)
+  }
+
+  Collapse.prototype.toggle = function () {
+    this[this.$element.hasClass('in') ? 'hide' : 'show']()
+  }
+
+  Collapse.prototype.getParent = function () {
+    return $(this.options.parent)
+      .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]')
+      .each($.proxy(function (i, element) {
+        var $element = $(element)
+        this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element)
+      }, this))
+      .end()
+  }
+
+  Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
+    var isOpen = $element.hasClass('in')
+
+    $element.attr('aria-expanded', isOpen)
+    $trigger
+      .toggleClass('collapsed', !isOpen)
+      .attr('aria-expanded', isOpen)
+  }
+
+  function getTargetFromTrigger($trigger) {
+    var href
+    var target = $trigger.attr('data-target')
+      || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
+
+    return $(target)
+  }
+
+
+  // COLLAPSE PLUGIN DEFINITION
+  // ==========================
+
+  function Plugin(option) {
+    return this.each(function () {
+      var $this   = $(this)
+      var data    = $this.data('bs.collapse')
+      var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
+
+      if (!data && options.toggle && option == 'show') options.toggle = false
+      if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
+      if (typeof option == 'string') data[option]()
+    })
+  }
+
+  var old = $.fn.collapse
+
+  $.fn.collapse             = Plugin
+  $.fn.collapse.Constructor = Collapse
+
+
+  // COLLAPSE NO CONFLICT
+  // ====================
+
+  $.fn.collapse.noConflict = function () {
+    $.fn.collapse = old
+    return this
+  }
+
+
+  // COLLAPSE DATA-API
+  // =================
+
+  $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
+    var $this   = $(this)
+
+    if (!$this.attr('data-target')) e.preventDefault()
+
+    var $target = getTargetFromTrigger($this)
+    var data    = $target.data('bs.collapse')
+    var option  = data ? 'toggle' : $.extend({}, $this.data(), { trigger: this })
+
+    Plugin.call($target, option)
+  })
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: dropdown.js v3.3.0
+ * http://getbootstrap.com/javascript/#dropdowns
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // DROPDOWN CLASS DEFINITION
+  // =========================
+
+  var backdrop = '.dropdown-backdrop'
+  var toggle   = '[data-toggle="dropdown"]'
+  var Dropdown = function (element) {
+    $(element).on('click.bs.dropdown', this.toggle)
+  }
+
+  Dropdown.VERSION = '3.3.0'
+
+  Dropdown.prototype.toggle = function (e) {
+    var $this = $(this)
+
+    if ($this.is('.disabled, :disabled')) return
+
+    var $parent  = getParent($this)
+    var isActive = $parent.hasClass('open')
+
+    clearMenus()
+
+    if (!isActive) {
+      if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
+        // if mobile we use a backdrop because click events don't delegate
+        $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
+      }
+
+      var relatedTarget = { relatedTarget: this }
+      $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
+
+      if (e.isDefaultPrevented()) return
+
+      $this
+        .trigger('focus')
+        .attr('aria-expanded', 'true')
+
+      $parent
+        .toggleClass('open')
+        .trigger('shown.bs.dropdown', relatedTarget)
+    }
+
+    return false
+  }
+
+  Dropdown.prototype.keydown = function (e) {
+    if (!/(38|40|27|32)/.test(e.which)) return
+
+    var $this = $(this)
+
+    e.preventDefault()
+    e.stopPropagation()
+
+    if ($this.is('.disabled, :disabled')) return
+
+    var $parent  = getParent($this)
+    var isActive = $parent.hasClass('open')
+
+    if ((!isActive && e.which != 27) || (isActive && e.which == 27)) {
+      if (e.which == 27) $parent.find(toggle).trigger('focus')
+      return $this.trigger('click')
+    }
+
+    var desc = ' li:not(.divider):visible a'
+    var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
+
+    if (!$items.length) return
+
+    var index = $items.index(e.target)
+
+    if (e.which == 38 && index > 0)                 index--                        // up
+    if (e.which == 40 && index < $items.length - 1) index++                        // down
+    if (!~index)                                      index = 0
+
+    $items.eq(index).trigger('focus')
+  }
+
+  function clearMenus(e) {
+    if (e && e.which === 3) return
+    $(backdrop).remove()
+    $(toggle).each(function () {
+      var $this         = $(this)
+      var $parent       = getParent($this)
+      var relatedTarget = { relatedTarget: this }
+
+      if (!$parent.hasClass('open')) return
+
+      $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
+
+      if (e.isDefaultPrevented()) return
+
+      $this.attr('aria-expanded', 'false')
+      $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
+    })
+  }
+
+  function getParent($this) {
+    var selector = $this.attr('data-target')
+
+    if (!selector) {
+      selector = $this.attr('href')
+      selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
+    }
+
+    var $parent = selector && $(selector)
+
+    return $parent && $parent.length ? $parent : $this.parent()
+  }
+
+
+  // DROPDOWN PLUGIN DEFINITION
+  // ==========================
+
+  function Plugin(option) {
+    return this.each(function () {
+      var $this = $(this)
+      var data  = $this.data('bs.dropdown')
+
+      if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
+      if (typeof option == 'string') data[option].call($this)
+    })
+  }
+
+  var old = $.fn.dropdown
+
+  $.fn.dropdown             = Plugin
+  $.fn.dropdown.Constructor = Dropdown
+
+
+  // DROPDOWN NO CONFLICT
+  // ====================
+
+  $.fn.dropdown.noConflict = function () {
+    $.fn.dropdown = old
+    return this
+  }
+
+
+  // APPLY TO STANDARD DROPDOWN ELEMENTS
+  // ===================================
+
+  $(document)
+    .on('click.bs.dropdown.data-api', clearMenus)
+    .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
+    .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
+    .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
+    .on('keydown.bs.dropdown.data-api', '[role="menu"]', Dropdown.prototype.keydown)
+    .on('keydown.bs.dropdown.data-api', '[role="listbox"]', Dropdown.prototype.keydown)
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: modal.js v3.3.0
+ * http://getbootstrap.com/javascript/#modals
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // MODAL CLASS DEFINITION
+  // ======================
+
+  var Modal = function (element, options) {
+    this.options        = options
+    this.$body          = $(document.body)
+    this.$element       = $(element)
+    this.$backdrop      =
+    this.isShown        = null
+    this.scrollbarWidth = 0
+
+    if (this.options.remote) {
+      this.$element
+        .find('.modal-content')
+        .load(this.options.remote, $.proxy(function () {
+          this.$element.trigger('loaded.bs.modal')
+        }, this))
+    }
+  }
+
+  Modal.VERSION  = '3.3.0'
+
+  Modal.TRANSITION_DURATION = 300
+  Modal.BACKDROP_TRANSITION_DURATION = 150
+
+  Modal.DEFAULTS = {
+    backdrop: true,
+    keyboard: true,
+    show: true
+  }
+
+  Modal.prototype.toggle = function (_relatedTarget) {
+    return this.isShown ? this.hide() : this.show(_relatedTarget)
+  }
+
+  Modal.prototype.show = function (_relatedTarget) {
+    var that = this
+    var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
+
+    this.$element.trigger(e)
+
+    if (this.isShown || e.isDefaultPrevented()) return
+
+    this.isShown = true
+
+    this.checkScrollbar()
+    this.$body.addClass('modal-open')
+
+    this.setScrollbar()
+    this.escape()
+
+    this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
+
+    this.backdrop(function () {
+      var transition = $.support.transition && that.$element.hasClass('fade')
+
+      if (!that.$element.parent().length) {
+        that.$element.appendTo(that.$body) // don't move modals dom position
+      }
+
+      that.$element
+        .show()
+        .scrollTop(0)
+
+      if (transition) {
+        that.$element[0].offsetWidth // force reflow
+      }
+
+      that.$element
+        .addClass('in')
+        .attr('aria-hidden', false)
+
+      that.enforceFocus()
+
+      var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
+
+      transition ?
+        that.$element.find('.modal-dialog') // wait for modal to slide in
+          .one('bsTransitionEnd', function () {
+            that.$element.trigger('focus').trigger(e)
+          })
+          .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
+        that.$element.trigger('focus').trigger(e)
+    })
+  }
+
+  Modal.prototype.hide = function (e) {
+    if (e) e.preventDefault()
+
+    e = $.Event('hide.bs.modal')
+
+    this.$element.trigger(e)
+
+    if (!this.isShown || e.isDefaultPrevented()) return
+
+    this.isShown = false
+
+    this.escape()
+
+    $(document).off('focusin.bs.modal')
+
+    this.$element
+      .removeClass('in')
+      .attr('aria-hidden', true)
+      .off('click.dismiss.bs.modal')
+
+    $.support.transition && this.$element.hasClass('fade') ?
+      this.$element
+        .one('bsTransitionEnd', $.proxy(this.hideModal, this))
+        .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
+      this.hideModal()
+  }
+
+  Modal.prototype.enforceFocus = function () {
+    $(document)
+      .off('focusin.bs.modal') // guard against infinite focus loop
+      .on('focusin.bs.modal', $.proxy(function (e) {
+        if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
+          this.$element.trigger('focus')
+        }
+      }, this))
+  }
+
+  Modal.prototype.escape = function () {
+    if (this.isShown && this.options.keyboard) {
+      this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
+        e.which == 27 && this.hide()
+      }, this))
+    } else if (!this.isShown) {
+      this.$element.off('keydown.dismiss.bs.modal')
+    }
+  }
+
+  Modal.prototype.hideModal = function () {
+    var that = this
+    this.$element.hide()
+    this.backdrop(function () {
+      that.$body.removeClass('modal-open')
+      that.resetScrollbar()
+      that.$element.trigger('hidden.bs.modal')
+    })
+  }
+
+  Modal.prototype.removeBackdrop = function () {
+    this.$backdrop && this.$backdrop.remove()
+    this.$backdrop = null
+  }
+
+  Modal.prototype.backdrop = function (callback) {
+    var that = this
+    var animate = this.$element.hasClass('fade') ? 'fade' : ''
+
+    if (this.isShown && this.options.backdrop) {
+      var doAnimate = $.support.transition && animate
+
+      this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
+        .prependTo(this.$element)
+        .on('click.dismiss.bs.modal', $.proxy(function (e) {
+          if (e.target !== e.currentTarget) return
+          this.options.backdrop == 'static'
+            ? this.$element[0].focus.call(this.$element[0])
+            : this.hide.call(this)
+        }, this))
+
+      if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
+
+      this.$backdrop.addClass('in')
+
+      if (!callback) return
+
+      doAnimate ?
+        this.$backdrop
+          .one('bsTransitionEnd', callback)
+          .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
+        callback()
+
+    } else if (!this.isShown && this.$backdrop) {
+      this.$backdrop.removeClass('in')
+
+      var callbackRemove = function () {
+        that.removeBackdrop()
+        callback && callback()
+      }
+      $.support.transition && this.$element.hasClass('fade') ?
+        this.$backdrop
+          .one('bsTransitionEnd', callbackRemove)
+          .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
+        callbackRemove()
+
+    } else if (callback) {
+      callback()
+    }
+  }
+
+  Modal.prototype.checkScrollbar = function () {
+    this.scrollbarWidth = this.measureScrollbar()
+  }
+
+  Modal.prototype.setScrollbar = function () {
+    var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
+    if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
+  }
+
+  Modal.prototype.resetScrollbar = function () {
+    this.$body.css('padding-right', '')
+  }
+
+  Modal.prototype.measureScrollbar = function () { // thx walsh
+    if (document.body.clientWidth >= window.innerWidth) return 0
+    var scrollDiv = document.createElement('div')
+    scrollDiv.className = 'modal-scrollbar-measure'
+    this.$body.append(scrollDiv)
+    var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
+    this.$body[0].removeChild(scrollDiv)
+    return scrollbarWidth
+  }
+
+
+  // MODAL PLUGIN DEFINITION
+  // =======================
+
+  function Plugin(option, _relatedTarget) {
+    return this.each(function () {
+      var $this   = $(this)
+      var data    = $this.data('bs.modal')
+      var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
+
+      if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
+      if (typeof option == 'string') data[option](_relatedTarget)
+      else if (options.show) data.show(_relatedTarget)
+    })
+  }
+
+  var old = $.fn.modal
+
+  $.fn.modal             = Plugin
+  $.fn.modal.Constructor = Modal
+
+
+  // MODAL NO CONFLICT
+  // =================
+
+  $.fn.modal.noConflict = function () {
+    $.fn.modal = old
+    return this
+  }
+
+
+  // MODAL DATA-API
+  // ==============
+
+  $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
+    var $this   = $(this)
+    var href    = $this.attr('href')
+    var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
+    var option  = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
+
+    if ($this.is('a')) e.preventDefault()
+
+    $target.one('show.bs.modal', function (showEvent) {
+      if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
+      $target.one('hidden.bs.modal', function () {
+        $this.is(':visible') && $this.trigger('focus')
+      })
+    })
+    Plugin.call($target, option, this)
+  })
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: tooltip.js v3.3.0
+ * http://getbootstrap.com/javascript/#tooltip
+ * Inspired by the original jQuery.tipsy by Jason Frame
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // TOOLTIP PUBLIC CLASS DEFINITION
+  // ===============================
+
+  var Tooltip = function (element, options) {
+    this.type       =
+    this.options    =
+    this.enabled    =
+    this.timeout    =
+    this.hoverState =
+    this.$element   = null
+
+    this.init('tooltip', element, options)
+  }
+
+  Tooltip.VERSION  = '3.3.0'
+
+  Tooltip.TRANSITION_DURATION = 150
+
+  Tooltip.DEFAULTS = {
+    animation: true,
+    placement: 'top',
+    selector: false,
+    template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
+    trigger: 'hover focus',
+    title: '',
+    delay: 0,
+    html: false,
+    container: false,
+    viewport: {
+      selector: 'body',
+      padding: 0
+    }
+  }
+
+  Tooltip.prototype.init = function (type, element, options) {
+    this.enabled   = true
+    this.type      = type
+    this.$element  = $(element)
+    this.options   = this.getOptions(options)
+    this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
+
+    var triggers = this.options.trigger.split(' ')
+
+    for (var i = triggers.length; i--;) {
+      var trigger = triggers[i]
+
+      if (trigger == 'click') {
+        this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
+      } else if (trigger != 'manual') {
+        var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focusin'
+        var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
+
+        this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
+        this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
+      }
+    }
+
+    this.options.selector ?
+      (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
+      this.fixTitle()
+  }
+
+  Tooltip.prototype.getDefaults = function () {
+    return Tooltip.DEFAULTS
+  }
+
+  Tooltip.prototype.getOptions = function (options) {
+    options = $.extend({}, this.getDefaults(), this.$element.data(), options)
+
+    if (options.delay && typeof options.delay == 'number') {
+      options.delay = {
+        show: options.delay,
+        hide: options.delay
+      }
+    }
+
+    return options
+  }
+
+  Tooltip.prototype.getDelegateOptions = function () {
+    var options  = {}
+    var defaults = this.getDefaults()
+
+    this._options && $.each(this._options, function (key, value) {
+      if (defaults[key] != value) options[key] = value
+    })
+
+    return options
+  }
+
+  Tooltip.prototype.enter = function (obj) {
+    var self = obj instanceof this.constructor ?
+      obj : $(obj.currentTarget).data('bs.' + this.type)
+
+    if (self && self.$tip && self.$tip.is(':visible')) {
+      self.hoverState = 'in'
+      return
+    }
+
+    if (!self) {
+      self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
+      $(obj.currentTarget).data('bs.' + this.type, self)
+    }
+
+    clearTimeout(self.timeout)
+
+    self.hoverState = 'in'
+
+    if (!self.options.delay || !self.options.delay.show) return self.show()
+
+    self.timeout = setTimeout(function () {
+      if (self.hoverState == 'in') self.show()
+    }, self.options.delay.show)
+  }
+
+  Tooltip.prototype.leave = function (obj) {
+    var self = obj instanceof this.constructor ?
+      obj : $(obj.currentTarget).data('bs.' + this.type)
+
+    if (!self) {
+      self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
+      $(obj.currentTarget).data('bs.' + this.type, self)
+    }
+
+    clearTimeout(self.timeout)
+
+    self.hoverState = 'out'
+
+    if (!self.options.delay || !self.options.delay.hide) return self.hide()
+
+    self.timeout = setTimeout(function () {
+      if (self.hoverState == 'out') self.hide()
+    }, self.options.delay.hide)
+  }
+
+  Tooltip.prototype.show = function () {
+    var e = $.Event('show.bs.' + this.type)
+
+    if (this.hasContent() && this.enabled) {
+      this.$element.trigger(e)
+
+      var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
+      if (e.isDefaultPrevented() || !inDom) return
+      var that = this
+
+      var $tip = this.tip()
+
+      var tipId = this.getUID(this.type)
+
+      this.setContent()
+      $tip.attr('id', tipId)
+      this.$element.attr('aria-describedby', tipId)
+
+      if (this.options.animation) $tip.addClass('fade')
+
+      var placement = typeof this.options.placement == 'function' ?
+        this.options.placement.call(this, $tip[0], this.$element[0]) :
+        this.options.placement
+
+      var autoToken = /\s?auto?\s?/i
+      var autoPlace = autoToken.test(placement)
+      if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
+
+      $tip
+        .detach()
+        .css({ top: 0, left: 0, display: 'block' })
+        .addClass(placement)
+        .data('bs.' + this.type, this)
+
+      this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
+
+      var pos          = this.getPosition()
+      var actualWidth  = $tip[0].offsetWidth
+      var actualHeight = $tip[0].offsetHeight
+
+      if (autoPlace) {
+        var orgPlacement = placement
+        var $container   = this.options.container ? $(this.options.container) : this.$element.parent()
+        var containerDim = this.getPosition($container)
+
+        placement = placement == 'bottom' && pos.bottom + actualHeight > containerDim.bottom ? 'top'    :
+                    placement == 'top'    && pos.top    - actualHeight < containerDim.top    ? 'bottom' :
+                    placement == 'right'  && pos.right  + actualWidth  > containerDim.width  ? 'left'   :
+                    placement == 'left'   && pos.left   - actualWidth  < containerDim.left   ? 'right'  :
+                    placement
+
+        $tip
+          .removeClass(orgPlacement)
+          .addClass(placement)
+      }
+
+      var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
+
+      this.applyPlacement(calculatedOffset, placement)
+
+      var complete = function () {
+        var prevHoverState = that.hoverState
+        that.$element.trigger('shown.bs.' + that.type)
+        that.hoverState = null
+
+        if (prevHoverState == 'out') that.leave(that)
+      }
+
+      $.support.transition && this.$tip.hasClass('fade') ?
+        $tip
+          .one('bsTransitionEnd', complete)
+          .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
+        complete()
+    }
+  }
+
+  Tooltip.prototype.applyPlacement = function (offset, placement) {
+    var $tip   = this.tip()
+    var width  = $tip[0].offsetWidth
+    var height = $tip[0].offsetHeight
+
+    // manually read margins because getBoundingClientRect includes difference
+    var marginTop = parseInt($tip.css('margin-top'), 10)
+    var marginLeft = parseInt($tip.css('margin-left'), 10)
+
+    // we must check for NaN for ie 8/9
+    if (isNaN(marginTop))  marginTop  = 0
+    if (isNaN(marginLeft)) marginLeft = 0
+
+    offset.top  = offset.top  + marginTop
+    offset.left = offset.left + marginLeft
+
+    // $.fn.offset doesn't round pixel values
+    // so we use setOffset directly with our own function B-0
+    $.offset.setOffset($tip[0], $.extend({
+      using: function (props) {
+        $tip.css({
+          top: Math.round(props.top),
+          left: Math.round(props.left)
+        })
+      }
+    }, offset), 0)
+
+    $tip.addClass('in')
+
+    // check to see if placing tip in new offset caused the tip to resize itself
+    var actualWidth  = $tip[0].offsetWidth
+    var actualHeight = $tip[0].offsetHeight
+
+    if (placement == 'top' && actualHeight != height) {
+      offset.top = offset.top + height - actualHeight
+    }
+
+    var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
+
+    if (delta.left) offset.left += delta.left
+    else offset.top += delta.top
+
+    var isVertical          = /top|bottom/.test(placement)
+    var arrowDelta          = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
+    var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
+
+    $tip.offset(offset)
+    this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
+  }
+
+  Tooltip.prototype.replaceArrow = function (delta, dimension, isHorizontal) {
+    this.arrow()
+      .css(isHorizontal ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
+      .css(isHorizontal ? 'top' : 'left', '')
+  }
+
+  Tooltip.prototype.setContent = function () {
+    var $tip  = this.tip()
+    var title = this.getTitle()
+
+    $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
+    $tip.removeClass('fade in top bottom left right')
+  }
+
+  Tooltip.prototype.hide = function (callback) {
+    var that = this
+    var $tip = this.tip()
+    var e    = $.Event('hide.bs.' + this.type)
+
+    function complete() {
+      if (that.hoverState != 'in') $tip.detach()
+      that.$element
+        .removeAttr('aria-describedby')
+        .trigger('hidden.bs.' + that.type)
+      callback && callback()
+    }
+
+    this.$element.trigger(e)
+
+    if (e.isDefaultPrevented()) return
+
+    $tip.removeClass('in')
+
+    $.support.transition && this.$tip.hasClass('fade') ?
+      $tip
+        .one('bsTransitionEnd', complete)
+        .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
+      complete()
+
+    this.hoverState = null
+
+    return this
+  }
+
+  Tooltip.prototype.fixTitle = function () {
+    var $e = this.$element
+    if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
+      $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
+    }
+  }
+
+  Tooltip.prototype.hasContent = function () {
+    return this.getTitle()
+  }
+
+  Tooltip.prototype.getPosition = function ($element) {
+    $element   = $element || this.$element
+
+    var el     = $element[0]
+    var isBody = el.tagName == 'BODY'
+
+    var elRect    = el.getBoundingClientRect()
+    if (elRect.width == null) {
+      // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
+      elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
+    }
+    var elOffset  = isBody ? { top: 0, left: 0 } : $element.offset()
+    var scroll    = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
+    var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
+
+    return $.extend({}, elRect, scroll, outerDims, elOffset)
+  }
+
+  Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
+    return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2  } :
+           placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2  } :
+           placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
+        /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width   }
+
+  }
+
+  Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
+    var delta = { top: 0, left: 0 }
+    if (!this.$viewport) return delta
+
+    var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
+    var viewportDimensions = this.getPosition(this.$viewport)
+
+    if (/right|left/.test(placement)) {
+      var topEdgeOffset    = pos.top - viewportPadding - viewportDimensions.scroll
+      var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
+      if (topEdgeOffset < viewportDimensions.top) { // top overflow
+        delta.top = viewportDimensions.top - topEdgeOffset
+      } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
+        delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
+      }
+    } else {
+      var leftEdgeOffset  = pos.left - viewportPadding
+      var rightEdgeOffset = pos.left + viewportPadding + actualWidth
+      if (leftEdgeOffset < viewportDimensions.left) { // left overflow
+        delta.left = viewportDimensions.left - leftEdgeOffset
+      } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
+        delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
+      }
+    }
+
+    return delta
+  }
+
+  Tooltip.prototype.getTitle = function () {
+    var title
+    var $e = this.$element
+    var o  = this.options
+
+    title = $e.attr('data-original-title')
+      || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
+
+    return title
+  }
+
+  Tooltip.prototype.getUID = function (prefix) {
+    do prefix += ~~(Math.random() * 1000000)
+    while (document.getElementById(prefix))
+    return prefix
+  }
+
+  Tooltip.prototype.tip = function () {
+    return (this.$tip = this.$tip || $(this.options.template))
+  }
+
+  Tooltip.prototype.arrow = function () {
+    return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
+  }
+
+  Tooltip.prototype.enable = function () {
+    this.enabled = true
+  }
+
+  Tooltip.prototype.disable = function () {
+    this.enabled = false
+  }
+
+  Tooltip.prototype.toggleEnabled = function () {
+    this.enabled = !this.enabled
+  }
+
+  Tooltip.prototype.toggle = function (e) {
+    var self = this
+    if (e) {
+      self = $(e.currentTarget).data('bs.' + this.type)
+      if (!self) {
+        self = new this.constructor(e.currentTarget, this.getDelegateOptions())
+        $(e.currentTarget).data('bs.' + this.type, self)
+      }
+    }
+
+    self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
+  }
+
+  Tooltip.prototype.destroy = function () {
+    var that = this
+    clearTimeout(this.timeout)
+    this.hide(function () {
+      that.$element.off('.' + that.type).removeData('bs.' + that.type)
+    })
+  }
+
+
+  // TOOLTIP PLUGIN DEFINITION
+  // =========================
+
+  function Plugin(option) {
+    return this.each(function () {
+      var $this    = $(this)
+      var data     = $this.data('bs.tooltip')
+      var options  = typeof option == 'object' && option
+      var selector = options && options.selector
+
+      if (!data && option == 'destroy') return
+      if (selector) {
+        if (!data) $this.data('bs.tooltip', (data = {}))
+        if (!data[selector]) data[selector] = new Tooltip(this, options)
+      } else {
+        if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
+      }
+      if (typeof option == 'string') data[option]()
+    })
+  }
+
+  var old = $.fn.tooltip
+
+  $.fn.tooltip             = Plugin
+  $.fn.tooltip.Constructor = Tooltip
+
+
+  // TOOLTIP NO CONFLICT
+  // ===================
+
+  $.fn.tooltip.noConflict = function () {
+    $.fn.tooltip = old
+    return this
+  }
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: popover.js v3.3.0
+ * http://getbootstrap.com/javascript/#popovers
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // POPOVER PUBLIC CLASS DEFINITION
+  // ===============================
+
+  var Popover = function (element, options) {
+    this.init('popover', element, options)
+  }
+
+  if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
+
+  Popover.VERSION  = '3.3.0'
+
+  Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
+    placement: 'right',
+    trigger: 'click',
+    content: '',
+    template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
+  })
+
+
+  // NOTE: POPOVER EXTENDS tooltip.js
+  // ================================
+
+  Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
+
+  Popover.prototype.constructor = Popover
+
+  Popover.prototype.getDefaults = function () {
+    return Popover.DEFAULTS
+  }
+
+  Popover.prototype.setContent = function () {
+    var $tip    = this.tip()
+    var title   = this.getTitle()
+    var content = this.getContent()
+
+    $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
+    $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
+      this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
+    ](content)
+
+    $tip.removeClass('fade top bottom left right in')
+
+    // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
+    // this manually by checking the contents.
+    if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
+  }
+
+  Popover.prototype.hasContent = function () {
+    return this.getTitle() || this.getContent()
+  }
+
+  Popover.prototype.getContent = function () {
+    var $e = this.$element
+    var o  = this.options
+
+    return $e.attr('data-content')
+      || (typeof o.content == 'function' ?
+            o.content.call($e[0]) :
+            o.content)
+  }
+
+  Popover.prototype.arrow = function () {
+    return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
+  }
+
+  Popover.prototype.tip = function () {
+    if (!this.$tip) this.$tip = $(this.options.template)
+    return this.$tip
+  }
+
+
+  // POPOVER PLUGIN DEFINITION
+  // =========================
+
+  function Plugin(option) {
+    return this.each(function () {
+      var $this    = $(this)
+      var data     = $this.data('bs.popover')
+      var options  = typeof option == 'object' && option
+      var selector = options && options.selector
+
+      if (!data && option == 'destroy') return
+      if (selector) {
+        if (!data) $this.data('bs.popover', (data = {}))
+        if (!data[selector]) data[selector] = new Popover(this, options)
+      } else {
+        if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
+      }
+      if (typeof option == 'string') data[option]()
+    })
+  }
+
+  var old = $.fn.popover
+
+  $.fn.popover             = Plugin
+  $.fn.popover.Constructor = Popover
+
+
+  // POPOVER NO CONFLICT
+  // ===================
+
+  $.fn.popover.noConflict = function () {
+    $.fn.popover = old
+    return this
+  }
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: scrollspy.js v3.3.0
+ * http://getbootstrap.com/javascript/#scrollspy
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // SCROLLSPY CLASS DEFINITION
+  // ==========================
+
+  function ScrollSpy(element, options) {
+    var process  = $.proxy(this.process, this)
+
+    this.$body          = $('body')
+    this.$scrollElement = $(element).is('body') ? $(window) : $(element)
+    this.options        = $.extend({}, ScrollSpy.DEFAULTS, options)
+    this.selector       = (this.options.target || '') + ' .nav li > a'
+    this.offsets        = []
+    this.targets        = []
+    this.activeTarget   = null
+    this.scrollHeight   = 0
+
+    this.$scrollElement.on('scroll.bs.scrollspy', process)
+    this.refresh()
+    this.process()
+  }
+
+  ScrollSpy.VERSION  = '3.3.0'
+
+  ScrollSpy.DEFAULTS = {
+    offset: 10
+  }
+
+  ScrollSpy.prototype.getScrollHeight = function () {
+    return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
+  }
+
+  ScrollSpy.prototype.refresh = function () {
+    var offsetMethod = 'offset'
+    var offsetBase   = 0
+
+    if (!$.isWindow(this.$scrollElement[0])) {
+      offsetMethod = 'position'
+      offsetBase   = this.$scrollElement.scrollTop()
+    }
+
+    this.offsets = []
+    this.targets = []
+    this.scrollHeight = this.getScrollHeight()
+
+    var self     = this
+
+    this.$body
+      .find(this.selector)
+      .map(function () {
+        var $el   = $(this)
+        var href  = $el.data('target') || $el.attr('href')
+        var $href = /^#./.test(href) && $(href)
+
+        return ($href
+          && $href.length
+          && $href.is(':visible')
+          && [[$href[offsetMethod]().top + offsetBase, href]]) || null
+      })
+      .sort(function (a, b) { return a[0] - b[0] })
+      .each(function () {
+        self.offsets.push(this[0])
+        self.targets.push(this[1])
+      })
+  }
+
+  ScrollSpy.prototype.process = function () {
+    var scrollTop    = this.$scrollElement.scrollTop() + this.options.offset
+    var scrollHeight = this.getScrollHeight()
+    var maxScroll    = this.options.offset + scrollHeight - this.$scrollElement.height()
+    var offsets      = this.offsets
+    var targets      = this.targets
+    var activeTarget = this.activeTarget
+    var i
+
+    if (this.scrollHeight != scrollHeight) {
+      this.refresh()
+    }
+
+    if (scrollTop >= maxScroll) {
+      return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
+    }
+
+    if (activeTarget && scrollTop < offsets[0]) {
+      this.activeTarget = null
+      return this.clear()
+    }
+
+    for (i = offsets.length; i--;) {
+      activeTarget != targets[i]
+        && scrollTop >= offsets[i]
+        && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
+        && this.activate(targets[i])
+    }
+  }
+
+  ScrollSpy.prototype.activate = function (target) {
+    this.activeTarget = target
+
+    this.clear()
+
+    var selector = this.selector +
+        '[data-target="' + target + '"],' +
+        this.selector + '[href="' + target + '"]'
+
+    var active = $(selector)
+      .parents('li')
+      .addClass('active')
+
+    if (active.parent('.dropdown-menu').length) {
+      active = active
+        .closest('li.dropdown')
+        .addClass('active')
+    }
+
+    active.trigger('activate.bs.scrollspy')
+  }
+
+  ScrollSpy.prototype.clear = function () {
+    $(this.selector)
+      .parentsUntil(this.options.target, '.active')
+      .removeClass('active')
+  }
+
+
+  // SCROLLSPY PLUGIN DEFINITION
+  // ===========================
+
+  function Plugin(option) {
+    return this.each(function () {
+      var $this   = $(this)
+      var data    = $this.data('bs.scrollspy')
+      var options = typeof option == 'object' && option
+
+      if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
+      if (typeof option == 'string') data[option]()
+    })
+  }
+
+  var old = $.fn.scrollspy
+
+  $.fn.scrollspy             = Plugin
+  $.fn.scrollspy.Constructor = ScrollSpy
+
+
+  // SCROLLSPY NO CONFLICT
+  // =====================
+
+  $.fn.scrollspy.noConflict = function () {
+    $.fn.scrollspy = old
+    return this
+  }
+
+
+  // SCROLLSPY DATA-API
+  // ==================
+
+  $(window).on('load.bs.scrollspy.data-api', function () {
+    $('[data-spy="scroll"]').each(function () {
+      var $spy = $(this)
+      Plugin.call($spy, $spy.data())
+    })
+  })
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: tab.js v3.3.0
+ * http://getbootstrap.com/javascript/#tabs
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // TAB CLASS DEFINITION
+  // ====================
+
+  var Tab = function (element) {
+    this.element = $(element)
+  }
+
+  Tab.VERSION = '3.3.0'
+
+  Tab.TRANSITION_DURATION = 150
+
+  Tab.prototype.show = function () {
+    var $this    = this.element
+    var $ul      = $this.closest('ul:not(.dropdown-menu)')
+    var selector = $this.data('target')
+
+    if (!selector) {
+      selector = $this.attr('href')
+      selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
+    }
+
+    if ($this.parent('li').hasClass('active')) return
+
+    var $previous = $ul.find('.active:last a')
+    var hideEvent = $.Event('hide.bs.tab', {
+      relatedTarget: $this[0]
+    })
+    var showEvent = $.Event('show.bs.tab', {
+      relatedTarget: $previous[0]
+    })
+
+    $previous.trigger(hideEvent)
+    $this.trigger(showEvent)
+
+    if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
+
+    var $target = $(selector)
+
+    this.activate($this.closest('li'), $ul)
+    this.activate($target, $target.parent(), function () {
+      $previous.trigger({
+        type: 'hidden.bs.tab',
+        relatedTarget: $this[0]
+      })
+      $this.trigger({
+        type: 'shown.bs.tab',
+        relatedTarget: $previous[0]
+      })
+    })
+  }
+
+  Tab.prototype.activate = function (element, container, callback) {
+    var $active    = container.find('> .active')
+    var transition = callback
+      && $.support.transition
+      && (($active.length && $active.hasClass('fade')) || !!container.find('> .fade').length)
+
+    function next() {
+      $active
+        .removeClass('active')
+        .find('> .dropdown-menu > .active')
+          .removeClass('active')
+        .end()
+        .find('[data-toggle="tab"]')
+          .attr('aria-expanded', false)
+
+      element
+        .addClass('active')
+        .find('[data-toggle="tab"]')
+          .attr('aria-expanded', true)
+
+      if (transition) {
+        element[0].offsetWidth // reflow for transition
+        element.addClass('in')
+      } else {
+        element.removeClass('fade')
+      }
+
+      if (element.parent('.dropdown-menu')) {
+        element
+          .closest('li.dropdown')
+            .addClass('active')
+          .end()
+          .find('[data-toggle="tab"]')
+            .attr('aria-expanded', true)
+      }
+
+      callback && callback()
+    }
+
+    $active.length && transition ?
+      $active
+        .one('bsTransitionEnd', next)
+        .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
+      next()
+
+    $active.removeClass('in')
+  }
+
+
+  // TAB PLUGIN DEFINITION
+  // =====================
+
+  function Plugin(option) {
+    return this.each(function () {
+      var $this = $(this)
+      var data  = $this.data('bs.tab')
+
+      if (!data) $this.data('bs.tab', (data = new Tab(this)))
+      if (typeof option == 'string') data[option]()
+    })
+  }
+
+  var old = $.fn.tab
+
+  $.fn.tab             = Plugin
+  $.fn.tab.Constructor = Tab
+
+
+  // TAB NO CONFLICT
+  // ===============
+
+  $.fn.tab.noConflict = function () {
+    $.fn.tab = old
+    return this
+  }
+
+
+  // TAB DATA-API
+  // ============
+
+  var clickHandler = function (e) {
+    e.preventDefault()
+    Plugin.call($(this), 'show')
+  }
+
+  $(document)
+    .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
+    .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
+
+}(jQuery);
+
+/* ========================================================================
+ * Bootstrap: affix.js v3.3.0
+ * http://getbootstrap.com/javascript/#affix
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+  'use strict';
+
+  // AFFIX CLASS DEFINITION
+  // ======================
+
+  var Affix = function (element, options) {
+    this.options = $.extend({}, Affix.DEFAULTS, options)
+
+    this.$target = $(this.options.target)
+      .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
+      .on('click.bs.affix.data-api',  $.proxy(this.checkPositionWithEventLoop, this))
+
+    this.$element     = $(element)
+    this.affixed      =
+    this.unpin        =
+    this.pinnedOffset = null
+
+    this.checkPosition()
+  }
+
+  Affix.VERSION  = '3.3.0'
+
+  Affix.RESET    = 'affix affix-top affix-bottom'
+
+  Affix.DEFAULTS = {
+    offset: 0,
+    target: window
+  }
+
+  Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) {
+    var scrollTop    = this.$target.scrollTop()
+    var position     = this.$element.offset()
+    var targetHeight = this.$target.height()
+
+    if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false
+
+    if (this.affixed == 'bottom') {
+      if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom'
+      return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom'
+    }
+
+    var initializing   = this.affixed == null
+    var colliderTop    = initializing ? scrollTop : position.top
+    var colliderHeight = initializing ? targetHeight : height
+
+    if (offsetTop != null && colliderTop <= offsetTop) return 'top'
+    if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'
+
+    return false
+  }
+
+  Affix.prototype.getPinnedOffset = function () {
+    if (this.pinnedOffset) return this.pinnedOffset
+    this.$element.removeClass(Affix.RESET).addClass('affix')
+    var scrollTop = this.$target.scrollTop()
+    var position  = this.$element.offset()
+    return (this.pinnedOffset = position.top - scrollTop)
+  }
+
+  Affix.prototype.checkPositionWithEventLoop = function () {
+    setTimeout($.proxy(this.checkPosition, this), 1)
+  }
+
+  Affix.prototype.checkPosition = function () {
+    if (!this.$element.is(':visible')) return
+
+    var height       = this.$element.height()
+    var offset       = this.options.offset
+    var offsetTop    = offset.top
+    var offsetBottom = offset.bottom
+    var scrollHeight = $('body').height()
+
+    if (typeof offset != 'object')         offsetBottom = offsetTop = offset
+    if (typeof offsetTop == 'function')    offsetTop    = offset.top(this.$element)
+    if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
+
+    var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom)
+
+    if (this.affixed != affix) {
+      if (this.unpin != null) this.$element.css('top', '')
+
+      var affixType = 'affix' + (affix ? '-' + affix : '')
+      var e         = $.Event(affixType + '.bs.affix')
+
+      this.$element.trigger(e)
+
+      if (e.isDefaultPrevented()) return
+
+      this.affixed = affix
+      this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
+
+      this.$element
+        .removeClass(Affix.RESET)
+        .addClass(affixType)
+        .trigger(affixType.replace('affix', 'affixed') + '.bs.affix')
+    }
+
+    if (affix == 'bottom') {
+      this.$element.offset({
+        top: scrollHeight - height - offsetBottom
+      })
+    }
+  }
+
+
+  // AFFIX PLUGIN DEFINITION
+  // =======================
+
+  function Plugin(option) {
+    return this.each(function () {
+      var $this   = $(this)
+      var data    = $this.data('bs.affix')
+      var options = typeof option == 'object' && option
+
+      if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
+      if (typeof option == 'string') data[option]()
+    })
+  }
+
+  var old = $.fn.affix
+
+  $.fn.affix             = Plugin
+  $.fn.affix.Constructor = Affix
+
+
+  // AFFIX NO CONFLICT
+  // =================
+
+  $.fn.affix.noConflict = function () {
+    $.fn.affix = old
+    return this
+  }
+
+
+  // AFFIX DATA-API
+  // ==============
+
+  $(window).on('load', function () {
+    $('[data-spy="affix"]').each(function () {
+      var $spy = $(this)
+      var data = $spy.data()
+
+      data.offset = data.offset || {}
+
+      if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom
+      if (data.offsetTop    != null) data.offset.top    = data.offsetTop
+
+      Plugin.call($spy, data)
+    })
+  })
+
+}(jQuery);

File diff suppressed because it is too large
+ 5 - 0
course-design/libs/bootstrap.min.js


File diff suppressed because it is too large
+ 0 - 0
course-design/libs/d3.min.js


File diff suppressed because it is too large
+ 1 - 0
course-design/libs/jquery-1.11.1.min.js


File diff suppressed because it is too large
+ 4 - 0
course-design/libs/jquery-ui-1.9.2.min.js


File diff suppressed because it is too large
+ 0 - 0
course-design/libs/jquery.jsPlumb-1.7.2-min.js


+ 11214 - 0
course-design/libs/jquery.jsPlumb-1.7.2.js

@@ -0,0 +1,11214 @@
+/**
+* jsBezier-0.6
+*
+* Copyright (c) 2010 - 2013 Simon Porritt (simon.porritt@gmail.com)
+*
+* licensed under the MIT license.
+* 
+* a set of Bezier curve functions that deal with Beziers, used by jsPlumb, and perhaps useful for other people.  These functions work with Bezier
+* curves of arbitrary degree.
+*
+* - functions are all in the 'jsBezier' namespace.  
+* 
+* - all input points should be in the format {x:.., y:..}. all output points are in this format too.
+* 
+* - all input curves should be in the format [ {x:.., y:..}, {x:.., y:..}, {x:.., y:..}, {x:.., y:..} ]
+* 
+* - 'location' as used as an input here refers to a decimal in the range 0-1 inclusive, which indicates a point some proportion along the length
+* of the curve.  location as output has the same format and meaning.
+* 
+* 
+* Function List:
+* --------------
+* 
+* distanceFromCurve(point, curve)
+* 
+* 	Calculates the distance that the given point lies from the given Bezier.  Note that it is computed relative to the center of the Bezier,
+* so if you have stroked the curve with a wide pen you may wish to take that into account!  The distance returned is relative to the values 
+* of the curve and the point - it will most likely be pixels.
+* 
+* gradientAtPoint(curve, location)
+* 
+* 	Calculates the gradient to the curve at the given location, as a decimal between 0 and 1 inclusive.
+*
+* gradientAtPointAlongCurveFrom (curve, location)
+*
+*	Calculates the gradient at the point on the given curve that is 'distance' units from location. 
+* 
+* nearestPointOnCurve(point, curve) 
+* 
+*	Calculates the nearest point to the given point on the given curve.  The return value of this is a JS object literal, containing both the
+*point's coordinates and also the 'location' of the point (see above), for example:  { point:{x:551,y:150}, location:0.263365 }.
+* 
+* pointOnCurve(curve, location)
+* 
+* 	Calculates the coordinates of the point on the given Bezier curve at the given location.  
+* 		
+* pointAlongCurveFrom(curve, location, distance)
+* 
+* 	Calculates the coordinates of the point on the given curve that is 'distance' units from location.  'distance' should be in the same coordinate
+* space as that used to construct the Bezier curve.  For an HTML Canvas usage, for example, distance would be a measure of pixels.
+*
+* locationAlongCurveFrom(curve, location, distance)
+* 
+* 	Calculates the location on the given curve that is 'distance' units from location.  'distance' should be in the same coordinate
+* space as that used to construct the Bezier curve.  For an HTML Canvas usage, for example, distance would be a measure of pixels.
+* 
+* perpendicularToCurveAt(curve, location, length, distance)
+* 
+* 	Calculates the perpendicular to the given curve at the given location.  length is the length of the line you wish for (it will be centered
+* on the point at 'location'). distance is optional, and allows you to specify a point along the path from the given location as the center of
+* the perpendicular returned.  The return value of this is an array of two points: [ {x:...,y:...}, {x:...,y:...} ].  
+*  
+* 
+*/
+
+(function() {
+	
+	if(typeof Math.sgn == "undefined") {
+		Math.sgn = function(x) { return x == 0 ? 0 : x > 0 ? 1 :-1; };
+	}
+	
+	var Vectors = {
+			subtract 	: 	function(v1, v2) { return {x:v1.x - v2.x, y:v1.y - v2.y }; },
+			dotProduct	: 	function(v1, v2) { return (v1.x * v2.x)  + (v1.y * v2.y); },
+			square		:	function(v) { return Math.sqrt((v.x * v.x) + (v.y * v.y)); },
+			scale		:	function(v, s) { return {x:v.x * s, y:v.y * s }; }
+		},
+		
+		maxRecursion = 64, 
+		flatnessTolerance = Math.pow(2.0,-maxRecursion-1);
+
+	/**
+	 * Calculates the distance that the point lies from the curve.
+	 * 
+	 * @param point a point in the form {x:567, y:3342}
+	 * @param curve a Bezier curve in the form [{x:..., y:...}, {x:..., y:...}, {x:..., y:...}, {x:..., y:...}].  note that this is currently
+	 * hardcoded to assume cubiz beziers, but would be better off supporting any degree. 
+	 * @return a JS object literal containing location and distance, for example: {location:0.35, distance:10}.  Location is analogous to the location
+	 * argument you pass to the pointOnPath function: it is a ratio of distance travelled along the curve.  Distance is the distance in pixels from
+	 * the point to the curve. 
+	 */
+	var _distanceFromCurve = function(point, curve) {
+		var candidates = [],     
+	    	w = _convertToBezier(point, curve),
+	    	degree = curve.length - 1, higherDegree = (2 * degree) - 1,
+	    	numSolutions = _findRoots(w, higherDegree, candidates, 0),
+			v = Vectors.subtract(point, curve[0]), dist = Vectors.square(v), t = 0.0;
+
+	    for (var i = 0; i < numSolutions; i++) {
+			v = Vectors.subtract(point, _bezier(curve, degree, candidates[i], null, null));
+	    	var newDist = Vectors.square(v);
+	    	if (newDist < dist) {
+	            dist = newDist;
+	        	t = candidates[i];
+		    }
+	    }
+	    v = Vectors.subtract(point, curve[degree]);
+		newDist = Vectors.square(v);
+	    if (newDist < dist) {
+	        dist = newDist;
+	    	t = 1.0;
+	    }
+		return {location:t, distance:dist};
+	};
+	/**
+	 * finds the nearest point on the curve to the given point.
+	 */
+	var _nearestPointOnCurve = function(point, curve) {    
+		var td = _distanceFromCurve(point, curve);
+	    return {point:_bezier(curve, curve.length - 1, td.location, null, null), location:td.location};
+	};
+	var _convertToBezier = function(point, curve) {
+		var degree = curve.length - 1, higherDegree = (2 * degree) - 1,
+	    	c = [], d = [], cdTable = [], w = [],
+	    	z = [ [1.0, 0.6, 0.3, 0.1], [0.4, 0.6, 0.6, 0.4], [0.1, 0.3, 0.6, 1.0] ];	
+	    	
+	    for (var i = 0; i <= degree; i++) c[i] = Vectors.subtract(curve[i], point);
+	    for (var i = 0; i <= degree - 1; i++) { 
+			d[i] = Vectors.subtract(curve[i+1], curve[i]);
+			d[i] = Vectors.scale(d[i], 3.0);
+	    }
+	    for (var row = 0; row <= degree - 1; row++) {
+			for (var column = 0; column <= degree; column++) {
+				if (!cdTable[row]) cdTable[row] = [];
+		    	cdTable[row][column] = Vectors.dotProduct(d[row], c[column]);
+			}
+	    }
+	    for (i = 0; i <= higherDegree; i++) {
+			if (!w[i]) w[i] = [];
+			w[i].y = 0.0;
+			w[i].x = parseFloat(i) / higherDegree;
+	    }
+	    var n = degree, m = degree-1;
+	    for (var k = 0; k <= n + m; k++) {
+			var lb = Math.max(0, k - m),
+				ub = Math.min(k, n);
+			for (i = lb; i <= ub; i++) {
+		    	j = k - i;
+		    	w[i+j].y += cdTable[j][i] * z[j][i];
+			}
+	    }
+	    return w;
+	};
+	/**
+	 * counts how many roots there are.
+	 */
+	var _findRoots = function(w, degree, t, depth) {  
+	    var left = [], right = [],	
+	    	left_count, right_count,	
+	    	left_t = [], right_t = [];
+	    	
+	    switch (_getCrossingCount(w, degree)) {
+	       	case 0 : {	
+	       		return 0;	
+	       	}
+	       	case 1 : {	
+	       		if (depth >= maxRecursion) {
+	       			t[0] = (w[0].x + w[degree].x) / 2.0;
+	       			return 1;
+	       		}
+	       		if (_isFlatEnough(w, degree)) {
+	       			t[0] = _computeXIntercept(w, degree);
+	       			return 1;
+	       		}
+	       		break;
+	       	}
+	    }
+	    _bezier(w, degree, 0.5, left, right);
+	    left_count  = _findRoots(left,  degree, left_t, depth+1);
+	    right_count = _findRoots(right, degree, right_t, depth+1);
+	    for (var i = 0; i < left_count; i++) t[i] = left_t[i];
+	    for (var i = 0; i < right_count; i++) t[i+left_count] = right_t[i];    
+		return (left_count+right_count);
+	};
+	var _getCrossingCount = function(curve, degree) {
+	    var n_crossings = 0, sign, old_sign;		    	
+	    sign = old_sign = Math.sgn(curve[0].y);
+	    for (var i = 1; i <= degree; i++) {
+			sign = Math.sgn(curve[i].y);
+			if (sign != old_sign) n_crossings++;
+			old_sign = sign;
+	    }
+	    return n_crossings;
+	};
+	var _isFlatEnough = function(curve, degree) {
+	    var  error,
+	    	intercept_1, intercept_2, left_intercept, right_intercept,
+	    	a, b, c, det, dInv, a1, b1, c1, a2, b2, c2;
+	    a = curve[0].y - curve[degree].y;
+	    b = curve[degree].x - curve[0].x;
+	    c = curve[0].x * curve[degree].y - curve[degree].x * curve[0].y;
+	
+	    var max_distance_above = max_distance_below = 0.0;
+	    
+	    for (var i = 1; i < degree; i++) {
+	        var value = a * curve[i].x + b * curve[i].y + c;       
+	        if (value > max_distance_above)
+	            max_distance_above = value;
+	        else if (value < max_distance_below)
+	        	max_distance_below = value;
+	    }
+	    
+	    a1 = 0.0; b1 = 1.0; c1 = 0.0; a2 = a; b2 = b;
+	    c2 = c - max_distance_above;
+	    det = a1 * b2 - a2 * b1;
+	    dInv = 1.0/det;
+	    intercept_1 = (b1 * c2 - b2 * c1) * dInv;
+	    a2 = a; b2 = b; c2 = c - max_distance_below;
+	    det = a1 * b2 - a2 * b1;
+	    dInv = 1.0/det;
+	    intercept_2 = (b1 * c2 - b2 * c1) * dInv;
+	    left_intercept = Math.min(intercept_1, intercept_2);
+	    right_intercept = Math.max(intercept_1, intercept_2);
+	    error = right_intercept - left_intercept;
+	    return (error < flatnessTolerance)? 1 : 0;
+	};
+	var _computeXIntercept = function(curve, degree) {
+	    var XLK = 1.0, YLK = 0.0,
+	    	XNM = curve[degree].x - curve[0].x, YNM = curve[degree].y - curve[0].y,
+	    	XMK = curve[0].x - 0.0, YMK = curve[0].y - 0.0,
+	    	det = XNM*YLK - YNM*XLK, detInv = 1.0/det,
+	    	S = (XNM*YMK - YNM*XMK) * detInv; 
+	    return 0.0 + XLK * S;
+	};
+	var _bezier = function(curve, degree, t, left, right) {
+	    var temp = [[]];
+	    for (var j =0; j <= degree; j++) temp[0][j] = curve[j];
+	    for (var i = 1; i <= degree; i++) {	
+			for (var j =0 ; j <= degree - i; j++) {
+				if (!temp[i]) temp[i] = [];
+				if (!temp[i][j]) temp[i][j] = {};
+		    	temp[i][j].x = (1.0 - t) * temp[i-1][j].x + t * temp[i-1][j+1].x;
+		    	temp[i][j].y = (1.0 - t) * temp[i-1][j].y + t * temp[i-1][j+1].y;
+			}
+	    }    
+	    if (left != null) 
+	    	for (j = 0; j <= degree; j++) left[j]  = temp[j][0];
+	    if (right != null)
+			for (j = 0; j <= degree; j++) right[j] = temp[degree-j][j];
+	    
+	    return (temp[degree][0]);
+	};
+	
+	var _curveFunctionCache = {};
+	var _getCurveFunctions = function(order) {
+		var fns = _curveFunctionCache[order];
+		if (!fns) {
+			fns = [];			
+			var f_term = function() { return function(t) { return Math.pow(t, order); }; },
+				l_term = function() { return function(t) { return Math.pow((1-t), order); }; },
+				c_term = function(c) { return function(t) { return c; }; },
+				t_term = function() { return function(t) { return t; }; },
+				one_minus_t_term = function() { return function(t) { return 1-t; }; },
+				_termFunc = function(terms) {
+					return function(t) {
+						var p = 1;
+						for (var i = 0; i < terms.length; i++) p = p * terms[i](t);
+						return p;
+					};
+				};
+			
+			fns.push(new f_term());  // first is t to the power of the curve order		
+			for (var i = 1; i < order; i++) {
+				var terms = [new c_term(order)];
+				for (var j = 0 ; j < (order - i); j++) terms.push(new t_term());
+				for (var j = 0 ; j < i; j++) terms.push(new one_minus_t_term());
+				fns.push(new _termFunc(terms));
+			}
+			fns.push(new l_term());  // last is (1-t) to the power of the curve order
+		
+			_curveFunctionCache[order] = fns;
+		}
+			
+		return fns;
+	};
+	
+	
+	/**
+	 * calculates a point on the curve, for a Bezier of arbitrary order.
+	 * @param curve an array of control points, eg [{x:10,y:20}, {x:50,y:50}, {x:100,y:100}, {x:120,y:100}].  For a cubic bezier this should have four points.
+	 * @param location a decimal indicating the distance along the curve the point should be located at.  this is the distance along the curve as it travels, taking the way it bends into account.  should be a number from 0 to 1, inclusive.
+	 */
+	var _pointOnPath = function(curve, location) {		
+		var cc = _getCurveFunctions(curve.length - 1),
+			_x = 0, _y = 0;
+		for (var i = 0; i < curve.length ; i++) {
+			_x = _x + (curve[i].x * cc[i](location));
+			_y = _y + (curve[i].y * cc[i](location));
+		}
+		
+		return {x:_x, y:_y};
+	};
+	
+	var _dist = function(p1,p2) {
+		return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
+	};
+
+	var _isPoint = function(curve) {
+		return curve[0].x == curve[1].x && curve[0].y == curve[1].y;
+	};
+	
+	/**
+	 * finds the point that is 'distance' along the path from 'location'.  this method returns both the x,y location of the point and also
+	 * its 'location' (proportion of travel along the path); the method below - _pointAlongPathFrom - calls this method and just returns the
+	 * point.
+	 */
+	var _pointAlongPath = function(curve, location, distance) {
+
+		if (_isPoint(curve)) {
+			return {
+				point:curve[0],
+				location:location
+			};
+		}
+
+		var prev = _pointOnPath(curve, location), 
+			tally = 0, 
+			curLoc = location, 
+			direction = distance > 0 ? 1 : -1, 
+			cur = null;
+			
+		while (tally < Math.abs(distance)) {
+			curLoc += (0.005 * direction);
+			cur = _pointOnPath(curve, curLoc);
+			tally += _dist(cur, prev);	
+			prev = cur;
+		}
+		return {point:cur, location:curLoc};        	
+	};
+	
+	var _length = function(curve) {
+		if (_isPoint(curve)) return 0;
+
+		var prev = _pointOnPath(curve, 0),
+			tally = 0,
+			curLoc = 0,
+			direction = 1,
+			cur = null;
+			
+		while (curLoc < 1) {
+			curLoc += (0.005 * direction);
+			cur = _pointOnPath(curve, curLoc);
+			tally += _dist(cur, prev);	
+			prev = cur;
+		}
+		return tally;
+	};
+	
+	/**
+	 * finds the point that is 'distance' along the path from 'location'.  
+	 */
+	var _pointAlongPathFrom = function(curve, location, distance) {
+		return _pointAlongPath(curve, location, distance).point;
+	};
+
+	/**
+	 * finds the location that is 'distance' along the path from 'location'.  
+	 */
+	var _locationAlongPathFrom = function(curve, location, distance) {
+		return _pointAlongPath(curve, location, distance).location;
+	};
+	
+	/**
+	 * returns the gradient of the curve at the given location, which is a decimal between 0 and 1 inclusive.
+	 * 
+	 * thanks // http://bimixual.org/AnimationLibrary/beziertangents.html
+	 */
+	var _gradientAtPoint = function(curve, location) {
+		var p1 = _pointOnPath(curve, location),	
+			p2 = _pointOnPath(curve.slice(0, curve.length - 1), location),
+			dy = p2.y - p1.y, dx = p2.x - p1.x;
+		return dy == 0 ? Infinity : Math.atan(dy / dx);		
+	};
+	
+	/**
+	returns the gradient of the curve at the point which is 'distance' from the given location.
+	if this point is greater than location 1, the gradient at location 1 is returned.
+	if this point is less than location 0, the gradient at location 0 is returned.
+	*/
+	var _gradientAtPointAlongPathFrom = function(curve, location, distance) {
+		var p = _pointAlongPath(curve, location, distance);
+		if (p.location > 1) p.location = 1;
+		if (p.location < 0) p.location = 0;		
+		return _gradientAtPoint(curve, p.location);		
+	};
+
+	/**
+	 * calculates a line that is 'length' pixels long, perpendicular to, and centered on, the path at 'distance' pixels from the given location.
+	 * if distance is not supplied, the perpendicular for the given location is computed (ie. we set distance to zero).
+	 */
+	var _perpendicularToPathAt = function(curve, location, length, distance) {
+		distance = distance == null ? 0 : distance;
+		var p = _pointAlongPath(curve, location, distance),
+			m = _gradientAtPoint(curve, p.location),
+			_theta2 = Math.atan(-1 / m),
+			y =  length / 2 * Math.sin(_theta2),
+			x =  length / 2 * Math.cos(_theta2);
+		return [{x:p.point.x + x, y:p.point.y + y}, {x:p.point.x - x, y:p.point.y - y}];
+	};
+	
+	var jsBezier = window.jsBezier = {
+		distanceFromCurve : _distanceFromCurve,
+		gradientAtPoint : _gradientAtPoint,
+		gradientAtPointAlongCurveFrom : _gradientAtPointAlongPathFrom,
+		nearestPointOnCurve : _nearestPointOnCurve,
+		pointOnCurve : _pointOnPath,		
+		pointAlongCurveFrom : _pointAlongPathFrom,
+		perpendicularToCurveAt : _perpendicularToPathAt,
+		locationAlongCurveFrom:_locationAlongPathFrom,
+		getLength:_length
+	};
+})();
+
+/**
+ * Biltong v0.2
+ *
+ * Various geometry functions written as part of jsPlumb and perhaps useful for others.
+ *
+ * Copyright (c) 2014 Simon Porritt
+ *
+ * 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.
+ */
+;(function() {
+
+	
+	"use strict";
+
+	var Biltong = this.Biltong = {};
+
+	var _isa = function(a) { return Object.prototype.toString.call(a) === "[object Array]"; },
+		_pointHelper = function(p1, p2, fn) {
+		    p1 = _isa(p1) ? p1 : [p1.x, p1.y];
+		    p2 = _isa(p2) ? p2 : [p2.x, p2.y];    
+		    return fn(p1, p2);
+		},
+		/**
+		* @name Biltong.gradient
+		* @function
+		* @desc Calculates the gradient of a line between the two points.
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Float} The gradient of a line between the two points.
+		*/
+		_gradient = Biltong.gradient = function(p1, p2) {
+		    return _pointHelper(p1, p2, function(_p1, _p2) { 
+		        if (_p2[0] == _p1[0])
+		            return _p2[1] > _p1[1] ? Infinity : -Infinity;
+		        else if (_p2[1] == _p1[1]) 
+		            return _p2[0] > _p1[0] ? 0 : -0;
+		        else 
+		            return (_p2[1] - _p1[1]) / (_p2[0] - _p1[0]); 
+		    });		
+		},
+		/**
+		* @name Biltong.normal
+		* @function
+		* @desc Calculates the gradient of a normal to a line between the two points.
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Float} The gradient of a normal to a line between the two points.
+		*/
+		_normal = Biltong.normal = function(p1, p2) {
+		    return -1 / _gradient(p1, p2);
+		},
+		/**
+		* @name Biltong.lineLength
+		* @function
+		* @desc Calculates the length of a line between the two points.
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Float} The length of a line between the two points.
+		*/
+		_lineLength = Biltong.lineLength = function(p1, p2) {
+		    return _pointHelper(p1, p2, function(_p1, _p2) {
+		        return Math.sqrt(Math.pow(_p2[1] - _p1[1], 2) + Math.pow(_p2[0] - _p1[0], 2));			
+		    });
+		},
+		/**
+		* @name Biltong.quadrant
+		* @function
+		* @desc Calculates the quadrant in which the angle between the two points lies. 
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Integer} The quadrant - 1 for upper right, 2 for lower right, 3 for lower left, 4 for upper left.
+		*/
+		_quadrant = Biltong.quadrant = function(p1, p2) {
+		    return _pointHelper(p1, p2, function(_p1, _p2) {
+		        if (_p2[0] > _p1[0]) {
+		            return (_p2[1] > _p1[1]) ? 2 : 1;
+		        }
+		        else if (_p2[0] == _p1[0]) {
+		            return _p2[1] > _p1[1] ? 2 : 1;    
+		        }
+		        else {
+		            return (_p2[1] > _p1[1]) ? 3 : 4;
+		        }
+		    });
+		},
+		/**
+		* @name Biltong.theta
+		* @function
+		* @desc Calculates the angle between the two points. 
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Float} The angle between the two points.
+		*/
+		_theta = Biltong.theta = function(p1, p2) {
+		    return _pointHelper(p1, p2, function(_p1, _p2) {
+		        var m = _gradient(_p1, _p2),
+		            t = Math.atan(m),
+		            s = _quadrant(_p1, _p2);
+		        if ((s == 4 || s== 3)) t += Math.PI;
+		        if (t < 0) t += (2 * Math.PI);
+		    
+		        return t;
+		    });
+		},
+		/**
+		* @name Biltong.intersects
+		* @function
+		* @desc Calculates whether or not the two rectangles intersect.
+		* @param {Rectangle} r1 First rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}`
+		* @param {Rectangle} r2 Second rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}`
+		* @return {Boolean} True if the rectangles intersect, false otherwise.
+		*/
+		_intersects = Biltong.intersects = function(r1, r2) {
+		    var x1 = r1.x, x2 = r1.x + r1.w, y1 = r1.y, y2 = r1.y + r1.h,
+		        a1 = r2.x, a2 = r2.x + r2.w, b1 = r2.y, b2 = r2.y + r2.h;
+		
+			return  ( (x1 <= a1 && a1 <= x2) && (y1 <= b1 && b1 <= y2) ) ||
+			        ( (x1 <= a2 && a2 <= x2) && (y1 <= b1 && b1 <= y2) ) ||
+			        ( (x1 <= a1 && a1 <= x2) && (y1 <= b2 && b2 <= y2) ) ||
+			        ( (x1 <= a2 && a1 <= x2) && (y1 <= b2 && b2 <= y2) ) ||	
+			        ( (a1 <= x1 && x1 <= a2) && (b1 <= y1 && y1 <= b2) ) ||
+			        ( (a1 <= x2 && x2 <= a2) && (b1 <= y1 && y1 <= b2) ) ||
+			        ( (a1 <= x1 && x1 <= a2) && (b1 <= y2 && y2 <= b2) ) ||
+			        ( (a1 <= x2 && x1 <= a2) && (b1 <= y2 && y2 <= b2) );
+		},
+		/**
+		* @name Biltong.encloses
+		* @function
+		* @desc Calculates whether or not r2 is completely enclosed by r1.
+		* @param {Rectangle} r1 First rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}`
+		* @param {Rectangle} r2 Second rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}`
+		* @param {Boolean} [allowSharedEdges=false] If true, the concept of enclosure allows for one or more edges to be shared by the two rectangles.
+		* @return {Boolean} True if r1 encloses r2, false otherwise.
+		*/
+		_encloses = Biltong.encloses = function(r1, r2, allowSharedEdges) {
+			var x1 = r1.x, x2 = r1.x + r1.w, y1 = r1.y, y2 = r1.y + r1.h,
+		        a1 = r2.x, a2 = r2.x + r2.w, b1 = r2.y, b2 = r2.y + r2.h,
+				c = function(v1, v2, v3, v4) { return allowSharedEdges ? v1 <= v2 && v3>= v4 : v1 < v2 && v3 > v4; };
+				
+			return c(x1,a1,x2,a2) && c(y1,b1,y2,b2);
+		},
+		_segmentMultipliers = [null, [1, -1], [1, 1], [-1, 1], [-1, -1] ],
+		_inverseSegmentMultipliers = [null, [-1, -1], [-1, 1], [1, 1], [1, -1] ],
+		/**
+		* @name Biltong.pointOnLine
+		* @function
+		* @desc Calculates a point on the line from `fromPoint` to `toPoint` that is `distance` units along the length of the line.
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Point} Point on the line, in the form `{ x:..., y:... }`.
+		*/
+		_pointOnLine = Biltong.pointOnLine = function(fromPoint, toPoint, distance) {
+		    var m = _gradient(fromPoint, toPoint),
+		        s = _quadrant(fromPoint, toPoint),
+		        segmentMultiplier = distance > 0 ? _segmentMultipliers[s] : _inverseSegmentMultipliers[s],
+		        theta = Math.atan(m),
+		        y = Math.abs(distance * Math.sin(theta)) * segmentMultiplier[1],
+		        x =  Math.abs(distance * Math.cos(theta)) * segmentMultiplier[0];
+		    return { x:fromPoint.x + x, y:fromPoint.y + y };
+		},
+		/**
+		* @name Biltong.perpendicularLineTo
+		* @function
+		* @desc Calculates a line of length `length` that is perpendicular to the line from `fromPoint` to `toPoint` and passes through `toPoint`.
+		* @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties.
+		* @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties.
+		* @return {Line} Perpendicular line, in the form `[ { x:..., y:... }, { x:..., y:... } ]`.
+		*/        
+		_perpendicularLineTo = Biltong.perpendicularLineTo = function(fromPoint, toPoint, length) {
+		    var m = _gradient(fromPoint, toPoint),
+		        theta2 = Math.atan(-1 / m),
+		        y =  length / 2 * Math.sin(theta2),
+		        x =  length / 2 * Math.cos(theta2);
+		    return [{x:toPoint.x + x, y:toPoint.y + y}, {x:toPoint.x - x, y:toPoint.y - y}];
+		};	
+}).call(this);
+;(function() {
+
+	"use strict";
+
+	var Sniff = {
+		android:navigator.userAgent.toLowerCase().indexOf("android") > -1
+	};
+
+	var matchesSelector = function(el, selector, ctx) {
+			ctx = ctx || el.parentNode;
+			var possibles = ctx.querySelectorAll(selector);
+			for (var i = 0; i < possibles.length; i++) {
+				if (possibles[i] === el) {
+					return true;
+				}
+			}
+			return false;
+		},
+		_gel = function(el) { return typeof el == "string" ? document.getElementById(el) : el; },
+		_t = function(e) { return e.srcElement || e.target; },
+		_d = function(l, fn) {
+			for (var i = 0, j = l.length; i < j; i++) {
+				if (l[i] == fn) break;
+			}
+			if (i < l.length) l.splice(i, 1);
+		},
+		guid = 1,
+		//
+		// this function generates a guid for every handler, sets it on the handler, then adds
+		// it to the associated object's map of handlers for the given event. this is what enables us 
+		// to unbind all events of some type, or all events (the second of which can be requested by the user, 
+		// but it also used by Mottle when an element is removed.)
+		_store = function(obj, event, fn) {
+			var g = guid++;
+			obj.__ta = obj.__ta || {};
+			obj.__ta[event] = obj.__ta[event] || {};
+			// store each handler with a unique guid.
+			obj.__ta[event][g] = fn;
+			// set the guid on the handler.
+			fn.__tauid = g;
+			return g;
+		},
+		_unstore = function(obj, event, fn) {
+			obj.__ta && obj.__ta[event] && delete obj.__ta[event][fn.__tauid];
+			// a handler might have attached extra functions, so we unbind those too.
+			if (fn.__taExtra) {
+				for (var i = 0; i < fn.__taExtra.length; i++) {
+					_unbind(obj, fn.__taExtra[i][0], fn.__taExtra[i][1]);
+				}
+				fn.__taExtra.length = 0;
+			}
+			// a handler might have attached an unstore callback
+			fn.__taUnstore && fn.__taUnstore();
+		},
+		_curryChildFilter = function(children, obj, fn, evt) {
+			if (children == null) return fn;
+			else {
+				var c = children.split(","),
+					_fn = function(e) {
+						_fn.__tauid = fn.__tauid;
+						var t = _t(e);
+						for (var i = 0; i < c.length; i++) {
+							if (matchesSelector(t, c[i], obj)) {
+								fn.apply(t, arguments);
+							}
+						}
+					};
+				registerExtraFunction(fn, evt, _fn);
+				return _fn;
+			}
+		},
+		//
+		// registers an 'extra' function on some event listener function we were given - a function that we
+		// created and bound to the element as part of our housekeeping, and which we want to unbind and remove
+		// whenever the given function is unbound.
+		registerExtraFunction = function(fn, evt, newFn) {
+			fn.__taExtra = fn.__taExtra || [];
+			fn.__taExtra.push([evt, newFn]);
+		},
+		DefaultHandler = function(obj, evt, fn, children) {
+			// TODO: this was here originally because i wanted to handle devices that are both touch AND mouse. however this can cause certain of the helper
+			// functions to be bound twice, as - for example - on a nexus 4, both a mouse event and a touch event are fired.  the use case i had in mind
+			// was a device such as an Asus touch pad thing, which has a touch pad but can also be controlled with a mouse.
+			//if (isMouseDevice)
+			//	_bind(obj, evt, _curryChildFilter(children, obj, fn, evt), fn);
+			
+			if (isTouchDevice && touchMap[evt]) {
+				_bind(obj, touchMap[evt], _curryChildFilter(children, obj, fn, touchMap[evt]), fn);
+			}
+			else
+				_bind(obj, evt, _curryChildFilter(children, obj, fn, evt), fn);
+		},
+		SmartClickHandler = function(obj, evt, fn, children) {
+			if (obj.__taSmartClicks == null) {
+				var down = function(e) { obj.__tad = _pageLocation(e); },
+					up = function(e) { obj.__tau = _pageLocation(e); },
+					click = function(e) {
+						if (obj.__tad && obj.__tau && obj.__tad[0] === obj.__tau[0] && obj.__tad[1] === obj.__tau[1]) {
+							for (var i = 0; i < obj.__taSmartClicks.length; i++)
+								obj.__taSmartClicks[i].apply(_t(e), [ e ]);
+						}
+					};
+				DefaultHandler(obj, "mousedown", down, children);
+				DefaultHandler(obj, "mouseup", up, children);
+				DefaultHandler(obj, "click", click, children);
+				obj.__taSmartClicks = [];
+			}
+			
+			// store in the list of callbacks
+			obj.__taSmartClicks.push(fn);
+			// the unstore function removes this function from the object's listener list for this type.
+			fn.__taUnstore = function() {
+				_d(obj.__taSmartClicks, fn);
+			};
+		},
+		_tapProfiles = {
+			"tap":{touches:1, taps:1},
+			"dbltap":{touches:1, taps:2},
+			"contextmenu":{touches:2, taps:1}
+		},
+		TapHandler = function(clickThreshold, dblClickThreshold) {
+			return function(obj, evt, fn, children) {
+				// if event is contextmenu, for devices which are mouse only, we want to
+				// use the default bind. 
+				if (evt == "contextmenu" && isMouseDevice)
+					DefaultHandler(obj, evt, fn, children);
+				else {
+                    // the issue here is that this down handler gets registered only for the
+                    // child nodes in the first registration. in fact it should be registered with
+                    // no child selector and then on down we should cycle through the regustered
+                    // functions to see if one of them matches. on mouseup we should execute ALL of
+                    // the functions whose children are either null or match the element.
+					if (obj.__taTapHandler == null) {
+						var tt = obj.__taTapHandler = {
+							tap:[],
+							dbltap:[],
+							contextmenu:[],
+							down:false,
+							taps:0,
+                            downSelectors:[]
+						};
+						var down = function(e) {
+                                var target = e.srcElement || e.target;
+                                for (var i = 0; i < tt.downSelectors.length; i++) {
+                                    if (tt.downSelectors[i] == null || matchesSelector(target, tt.downSelectors[i], obj)) {
+                                        tt.down = true;
+                                        setTimeout(clearSingle, clickThreshold);
+                                        setTimeout(clearDouble, dblClickThreshold);
+                                        break; // we only need one match on mousedown
+                                    }
+                                }
+							},
+							up = function(e) {
+								if (tt.down) {
+                                    var target = e.srcElement || e.target;
+									tt.taps++;
+									var tc = _touchCount(e);
+									for (var eventId in _tapProfiles) {
+										var p = _tapProfiles[eventId];
+										if (p.touches === tc && (p.taps === 1 || p.taps === tt.taps)) {
+											for (var i = 0; i < tt[eventId].length; i++) {
+                                                if (tt[eventId][i][1] == null || matchesSelector(target, tt[eventId][i][1], obj))
+												    tt[eventId][i][0].apply(_t(e), [ e ]);
+											}
+										}
+									}
+								}
+							},
+							clearSingle = function() {
+								tt.down = false;
+							},
+							clearDouble = function() {
+								tt.taps = 0;
+							};
+						
+						DefaultHandler(obj, "mousedown", down/*, children*/);
+						DefaultHandler(obj, "mouseup", up/*, children*/);
+					}
+                    // add this child selector (it can be null, that's fine).
+                    obj.__taTapHandler.downSelectors.push(children);
+
+					obj.__taTapHandler[evt].push([fn, children]);
+					// the unstore function removes this function from the object's listener list for this type.
+					fn.__taUnstore = function() {
+						_d(obj.__taTapHandler[evt], fn);
+					};
+				}
+			};
+		},
+		meeHelper = function(type, evt, obj, target) {
+			for (var i in obj.__tamee[type]) {
+				obj.__tamee[type][i].apply(target, [ evt ]);
+			}
+		},
+		MouseEnterExitHandler = function() {
+			var activeElements = [];
+			return function(obj, evt, fn, children) {
+				if (!obj.__tamee) {
+					// __tamee holds a flag saying whether the mouse is currently "in" the element, and a list of
+					// both mouseenter and mouseexit functions.
+					obj.__tamee = { over:false, mouseenter:[], mouseexit:[] };
+					// register over and out functions
+					var over = function(e) {
+							var t = _t(e);
+							if ( (children== null && (t == obj && !obj.__tamee.over)) || (matchesSelector(t, children, obj) && (t.__tamee == null || !t.__tamee.over)) ) {
+								meeHelper("mouseenter", e, obj, t);
+								t.__tamee = t.__tamee || {};
+								t.__tamee.over = true;
+								activeElements.push(t);
+							}
+						},
+						out = function(e) {
+							var t = _t(e);
+							// is the current target one of the activeElements? and is the 
+							// related target NOT a descendant of it?
+							for (var i = 0; i < activeElements.length; i++) {
+								if (t == activeElements[i] && !matchesSelector((e.relatedTarget || e.toElement), "*", t)) {
+									t.__tamee.over = false;
+									activeElements.splice(i, 1);
+									meeHelper("mouseexit", e, obj, t);
+								}
+							}
+						};
+						
+					_bind(obj, "mouseover", _curryChildFilter(children, obj, over, "mouseover"), over);
+					_bind(obj, "mouseout", _curryChildFilter(children, obj, out, "mouseout"), out);
+				}
+
+				fn.__taUnstore = function() {
+					delete obj.__tamee[evt][fn.__tauid];
+				};
+
+				_store(obj, evt, fn);
+				obj.__tamee[evt][fn.__tauid] = fn;
+			};
+		},
+		isTouchDevice = "ontouchstart" in document.documentElement,
+		isMouseDevice = "onmousedown" in document.documentElement,
+		touchMap = { "mousedown":"touchstart", "mouseup":"touchend", "mousemove":"touchmove" },
+		touchstart="touchstart",touchend="touchend",touchmove="touchmove",
+		ta_down = "__MottleDown", ta_up = "__MottleUp", 
+		ta_context_down = "__MottleContextDown", ta_context_up = "__MottleContextUp",
+		iev = (function() {
+			var rv = -1; 
+			if (navigator.appName == 'Microsoft Internet Explorer') {
+				var ua = navigator.userAgent,
+					re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+				if (re.exec(ua) != null)
+					rv = parseFloat(RegExp.$1);
+			}
+			return rv;
+		})(),
+		isIELT9 = iev > -1 && iev < 9, 
+		_genLoc = function(e, prefix) {
+			if (e == null) return [ 0, 0 ];
+			var ts = _touches(e), t = _getTouch(ts, 0);
+			return [t[prefix + "X"], t[prefix + "Y"]];
+		},
+		_pageLocation = function(e) {
+			if (e == null) return [ 0, 0 ];
+			if (isIELT9) {
+				return [ e.clientX + document.documentElement.scrollLeft, e.clientY + document.documentElement.scrollTop ];
+			}
+			else {
+				return _genLoc(e, "page");
+			}
+		},
+		_screenLocation = function(e) {
+			return _genLoc(e, "screen");
+		},
+		_clientLocation = function(e) {
+			return _genLoc(e, "client");
+		},
+		_getTouch = function(touches, idx) { return touches.item ? touches.item(idx) : touches[idx]; },
+		_touches = function(e) {
+			return e.touches && e.touches.length > 0 ? e.touches : 
+				   e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches :
+				   e.targetTouches && e.targetTouches.length > 0 ? e.targetTouches :
+				   [ e ];
+		},
+		_touchCount = function(e) { return _touches(e).length; },
+		//http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
+		_bind = function( obj, type, fn, originalFn) {
+			_store(obj, type, fn);
+			originalFn.__tauid = fn.__tauid;
+			if (obj.addEventListener)
+				obj.addEventListener( type, fn, false );
+			else if (obj.attachEvent) {
+				var key = type + fn.__tauid;
+				obj["e" + key] = fn;
+				// TODO look at replacing with .call(..)
+				obj[key] = function() { 
+					obj["e"+key] && obj["e"+key]( window.event ); 
+				};
+				obj.attachEvent( "on"+type, obj[key] );
+			}
+		},
+		_unbind = function( obj, type, fn) {
+			if (fn == null) return;
+			_each(obj, function() {
+				var _el = _gel(this);
+				_unstore(_el, type, fn);
+				// it has been bound if there is a tauid. otherwise it was not bound and we can ignore it.
+				if (fn.__tauid != null) {
+					if (_el.removeEventListener)
+						_el.removeEventListener( type, fn, false );
+					else if (this.detachEvent) {
+						var key = type + fn.__tauid;
+						_el[key] && _el.detachEvent( "on"+type, _el[key] );
+						_el[key] = null;
+						_el["e"+key] = null;
+					}
+				}
+			});
+		},
+		_devNull = function() {},
+		_each = function(obj, fn) {
+			if (obj == null) return;
+			// if a list (or list-like), use it. if a string, get a list 
+			// by running the string through querySelectorAll. else, assume 
+			// it's an Element.
+			obj = (typeof obj !== "string") && (obj.tagName == null && obj.length != null) ? obj : typeof obj === "string" ? document.querySelectorAll(obj) : [ obj ];
+			for (var i = 0; i < obj.length; i++)
+				fn.apply(obj[i]);
+		};
+
+	/**
+	* Event handler.  Offers support for abstracting out the differences
+	* between touch and mouse devices, plus "smart click" functionality
+	* (don't fire click if the mouse has moved betweeb mousedown and mouseup),
+	* and synthesized click/tap events.
+	* @class Mottle
+	* @constructor
+	* @param {Object} params Constructor params
+	* @param {Integer} [params.clickThreshold=150] Threshold, in milliseconds beyond which a touchstart followed by a touchend is not considered to be a click.
+	* @param {Integer} [params.dblClickThreshold=350] Threshold, in milliseconds beyond which two successive tap events are not considered to be a click.
+	* @param {Boolean} [params.smartClicks=false] If true, won't fire click events if the mouse has moved between mousedown and mouseup. Note that this functionality
+	* requires that Mottle consume the mousedown event, and so may not be viable in all use cases.
+	*/
+	this.Mottle = function(params) {
+		params = params || {};
+		var self = this, 
+			clickThreshold = params.clickThreshold || 150,
+			dblClickThreshold = params.dblClickThreshold || 350,
+			mouseEnterExitHandler = new MouseEnterExitHandler(),
+			tapHandler = new TapHandler(clickThreshold, dblClickThreshold),
+			_smartClicks = params.smartClicks,
+			_doBind = function(obj, evt, fn, children) {
+				if (fn == null) return;
+				_each(obj, function() {
+					var _el = _gel(this);
+					if (_smartClicks && evt === "click")
+						SmartClickHandler(_el, evt, fn, children);
+					else if (evt === "tap" || evt === "dbltap" || evt === "contextmenu") {
+						tapHandler(_el, evt, fn, children);
+					}
+					else if (evt === "mouseenter" || evt == "mouseexit")
+						mouseEnterExitHandler(_el, evt, fn, children);
+					else 
+						DefaultHandler(_el, evt, fn, children);
+				});
+			};
+
+		/**
+		* Removes an element from the DOM, and unregisters all event handlers for it. You should use this
+		* to ensure you don't leak memory.
+		* @method remove
+		* @param {String|Element} el Element, or id of the element, to remove.
+		* @return {Mottle} The current Mottle instance; you can chain this method.
+		*/
+		this.remove = function(el) {
+			_each(el, function() {
+				var _el = _gel(this);
+				if (_el.__ta) {
+					for (var evt in _el.__ta) {
+						for (var h in _el.__ta[evt]) {
+							_unbind(_el, evt, _el.__ta[evt][h]);
+						}
+					}
+				}
+				_el.parentNode && _el.parentNode.removeChild(_el);
+			});
+			return this;
+		};
+
+		/**
+		* Register an event handler, optionally as a delegate for some set of descendant elements. Note
+		* that this method takes either 3 or 4 arguments - if you supply 3 arguments it is assumed you have 
+		* omitted the `children` parameter, and that the event handler should be bound directly to the given element.
+		* @method on
+		* @param {Element[]|Element|String} el Either an Element, or a CSS spec for a list of elements, or an array of Elements.
+		* @param {String} [children] Comma-delimited list of selectors identifying allowed children.
+		* @param {String} event Event ID.
+		* @param {Function} fn Event handler function.
+		* @return {Mottle} The current Mottle instance; you can chain this method.
+		*/
+		this.on = function(el, event, children, fn) {
+			var _el = arguments[0],
+				_c = arguments.length == 4 ? arguments[2] : null,
+				_e = arguments[1],
+				_f = arguments[arguments.length - 1];
+
+			_doBind(_el, _e, _f, _c);
+			return this;
+		};	
+
+		/**
+		* Cancel delegate event handling for the given function. Note that unlike with 'on' you do not supply
+		* a list of child selectors here: it removes event delegation from all of the child selectors for which the
+		* given function was registered (if any).
+		* @method off
+		* @param {Element[]|Element|String} el Element - or ID of element - from which to remove event listener.
+		* @param {String} event Event ID.
+		* @param {Function} fn Event handler function.
+		* @return {Mottle} The current Mottle instance; you can chain this method.
+		*/
+		this.off = function(el, evt, fn) {
+			_unbind(el, evt, fn);
+			return this;
+		};
+
+		/**
+		* Triggers some event for a given element.
+		* @method trigger
+		* @param {Element} el Element for which to trigger the event.
+		* @param {String} event Event ID.
+		* @param {Event} originalEvent The original event. Should be optional of course, but currently is not, due
+		* to the jsPlumb use case that caused this method to be added.
+		* @param {Object} [payload] Optional object to set as `payload` on the generated event; useful for message passing.
+		* @return {Mottle} The current Mottle instance; you can chain this method.
+		*/
+		this.trigger = function(el, event, originalEvent, payload) {
+			var eventToBind = (isTouchDevice && touchMap[event]) ? touchMap[event] : event;
+			var pl = _pageLocation(originalEvent), sl = _screenLocation(originalEvent), cl = _clientLocation(originalEvent);
+			_each(el, function() {
+				var _el = _gel(this), evt;
+				originalEvent = originalEvent || {
+					screenX:sl[0],
+					screenY:sl[1],
+					clientX:cl[0],
+					clientY:cl[1]
+				};
+
+				var _decorate = function(_evt) {
+					if (payload) _evt.payload = payload;
+				};
+
+				var eventGenerators = {
+					"TouchEvent":function(evt) {
+						var t = document.createTouch(window, _el, 0, pl[0], pl[1], 
+									sl[0], sl[1],
+									cl[0], cl[1],
+									0,0,0,0);
+
+						evt.initTouchEvent(eventToBind, true, true, window, 0, 
+							sl[0], sl[1],
+							cl[0], cl[1],
+							false, false, false, false, document.createTouchList(t));
+					},
+					"MouseEvents":function(evt) {
+						evt.initMouseEvent(eventToBind, true, true, window, 0,
+							sl[0], sl[1],
+							cl[0], cl[1],
+							false, false, false, false, 1, _el);
+						
+						if (Sniff.android) {
+							// Android's touch events are not standard.
+							var t = document.createTouch(window, _el, 0, pl[0], pl[1], 
+										sl[0], sl[1],
+										cl[0], cl[1],
+										0,0,0,0);
+
+							evt.touches = evt.targetTouches = evt.changedTouches = document.createTouchList(t);
+						}
+					}
+				};
+
+				if (document.createEvent) {
+					var ite = (isTouchDevice && touchMap[event] && !Sniff.android), evtName = ite ? "TouchEvent" : "MouseEvents";
+					evt = document.createEvent(evtName);
+					eventGenerators[evtName](evt);
+					_decorate(evt);
+					_el.dispatchEvent(evt);
+				}
+				else if (document.createEventObject) {
+					evt = document.createEventObject();
+					evt.eventType = evt.eventName = eventToBind;
+					evt.screenX = sl[0];
+					evt.screenY = sl[1];
+					evt.clientX = cl[0];
+					evt.clientY = cl[1];
+					_decorate(evt);
+					_el.fireEvent('on' + eventToBind, evt);
+				}
+			});
+			return this;
+		}
+	};
+
+	/**
+	* Static method to assist in 'consuming' an element: uses `stopPropagation` where available, or sets `e.returnValue=false` where it is not.
+	* @method Mottle.consume
+	* @param {Event} e Event to consume
+	* @param {Boolean} [doNotPreventDefault=false] If true, does not call `preventDefault()` on the event.
+	*/
+	Mottle.consume = function(e, doNotPreventDefault) {
+		if (e.stopPropagation)
+			e.stopPropagation();
+		else 
+			e.returnValue = false;
+
+		if (!doNotPreventDefault && e.preventDefault)
+			 e.preventDefault();
+	};
+
+	/**
+	* Gets the page location corresponding to the given event. For touch events this means get the page location of the first touch.
+	* @method Mottle.pageLocation
+	* @param {Event} e Event to get page location for.
+	* @return {Integer[]} [left, top] for the given event.
+	*/
+	Mottle.pageLocation = _pageLocation;
+
+}).call(this);
+
+/*
+ * jsPlumb
+ *
+ * Title:jsPlumb 1.7.2
+ *
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.
+ *
+ * This file contains utility functions that run in both browsers and headless.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ *
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ *
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+
+;(function() {
+
+  var _isa = function(a) { return Object.prototype.toString.call(a) === "[object Array]"; },
+      _isnum = function(n) { return Object.prototype.toString.call(n) === "[object Number]"; },
+      _iss = function(s) { return typeof s === "string"; },
+      _isb = function(s) { return typeof s === "boolean"; },
+      _isnull = function(s) { return s == null; },
+      _iso = function(o) { return o == null ? false : Object.prototype.toString.call(o) === "[object Object]"; },
+      _isd = function(o) { return Object.prototype.toString.call(o) === "[object Date]"; },
+      _isf = function(o) { return Object.prototype.toString.call(o) === "[object Function]"; },
+      _ise = function(o) {
+          for (var i in o) { if (o.hasOwnProperty(i)) return false; }
+          return true;
+      },
+      pointHelper = function(p1, p2, fn) {
+          p1 = _isa(p1) ? p1 : [p1.x, p1.y];
+          p2 = _isa(p2) ? p2 : [p2.x, p2.y];
+          return fn(p1, p2);
+      };
+
+  var root = this;
+  var exports = root.jsPlumbUtil = {
+        isArray : _isa,
+        isString : _iss,
+        isBoolean: _isb,
+        isNull : _isnull,
+        isObject : _iso,
+        isDate : _isd,
+        isFunction: _isf,
+        isEmpty:_ise,
+        isNumber:_isnum,
+        clone : function(a) {
+            if (_iss(a)) return "" + a;
+            else if (_isb(a)) return !!a;
+            else if (_isd(a)) return new Date(a.getTime());
+            else if (_isf(a)) return a;
+            else if (_isa(a)) {
+                var b = [];
+                for (var i = 0; i < a.length; i++)
+                    b.push(this.clone(a[i]));
+                return b;
+            }
+            else if (_iso(a)) {
+                var c = {};
+                for (var j in a)
+                    c[j] = this.clone(a[j]);
+                return c;
+            }
+            else return a;
+        },
+        merge : function(a, b, collations) {
+            // first change the collations array - if present - into a lookup table, because its faster.
+            var cMap = {}, ar, i;
+            collations = collations || [];
+            for (i = 0; i < collations.length; i++)
+                cMap[collations[i]] = true;
+
+            var c = this.clone(a);
+            for (i in b) {
+                if (c[i] == null)
+                    c[i] = b[i];
+                else if (_iss(b[i]) || _isb(b[i])) {
+                    if (!cMap[i]) c[i] = b[i]; // if we dont want to collate, just copy it in.
+                    else {
+                        ar = [];
+                        // if c's object is also an array we can keep its values.
+                        ar.push.apply(ar, _isa(c[i]) ? c[i] :  [ c[i] ] );
+                        ar.push.apply(ar, _isa(b[i]) ? b[i] :  [ b[i] ] );
+                        c[i] = ar;
+                    }
+                }
+                else {
+                    if (_isa(b[i])) {
+                        ar = [];
+                        // if c's object is also an array we can keep its values.
+                        if (_isa(c[i])) ar.push.apply(ar, c[i]);
+                        ar.push.apply(ar, b[i]);
+                        c[i] = ar;
+                    }
+                    else if(_iso(b[i])) {
+                        // overwite c's value with an object if it is not already one.
+                        if (!_iso(c[i]))
+                            c[i] = {};
+                        for (var j in b[i])
+                            c[i][j] = b[i][j];
+                    }
+                }
+            }
+            return c;
+        },
+        replace:function(inObj, path, value) {
+            if (inObj == null) return;
+            var q = inObj, t = q;
+            path.replace(/([^\.])+/g, function(term, lc, pos, str) {
+                var array = term.match(/([^\[0-9]+){1}(\[)([0-9+])/),
+                    last = pos + term.length >= str.length,
+                    _getArray = function() {
+                        return t[array[1]] || (function() {  t[array[1]] = []; return t[array[1]]; })();
+                    };
+
+                if (last) {
+                    // set term = value on current t, creating term as array if necessary.
+                    if (array)
+                        _getArray()[array[3]] = value;
+                    else
+                        t[term] = value;
+                }
+                else {
+                    // set to current t[term], creating t[term] if necessary.
+                    if (array) {
+                        var a = _getArray();
+                        t = a[array[3]] || (function() { a[array[3]] = {}; return a[array[3]]; })();
+                    }
+                    else
+                        t = t[term] || (function() { t[term] = {}; return t[term]; })();
+                }
+            });
+
+            return inObj;
+        },
+        //
+        // chain a list of functions, supplied by [ object, method name, args ], and return on the first
+        // one that returns the failValue. if none return the failValue, return the successValue.
+        //
+        functionChain : function(successValue, failValue, fns) {
+            for (var i = 0; i < fns.length; i++) {
+                var o = fns[i][0][fns[i][1]].apply(fns[i][0], fns[i][2]);
+                if (o === failValue) {
+                    return o;
+                }
+            }
+            return successValue;
+        },
+        // take the given model and expand out any parameters.
+        populate : function(model, values) {
+            // for a string, see if it has parameter matches, and if so, try to make the substitutions.
+            var getValue = function(fromString) {
+                    var matches = fromString.match(/(\${.*?})/g);
+                    if (matches != null) {
+                        for (var i = 0; i < matches.length; i++) {
+                            var val = values[matches[i].substring(2, matches[i].length - 1)] || "";
+                            if (val != null) {
+                                fromString = fromString.replace(matches[i], val);
+                            }
+                        }
+                    }
+                    return fromString;
+                },
+                // process one entry.
+                _one = function(d) {
+                    if (d != null) {
+                        if (_iss(d)) {
+                            return getValue(d);
+                        }
+                        else if (_isa(d)) {
+                            var r = [];
+                            for (var i = 0; i < d.length; i++)
+                                r.push(_one(d[i]));
+                            return r;
+                        }
+                        else if (_iso(d)) {
+                            var s = {};
+                            for (var j in d) {
+                                s[j] = _one(d[j]);
+                            }
+                            return s;
+                        }
+                        else {
+                            return d;
+                        }
+                    }
+                };
+
+            return _one(model);
+        },
+        convertStyle : function(s, ignoreAlpha) {
+            // TODO: jsPlumb should support a separate 'opacity' style member.
+            if ("transparent" === s) return s;
+            var o = s,
+                pad = function(n) { return n.length == 1 ? "0" + n : n; },
+                hex = function(k) { return pad(Number(k).toString(16)); },
+                pattern = /(rgb[a]?\()(.*)(\))/;
+            if (s.match(pattern)) {
+                var parts = s.match(pattern)[2].split(",");
+                o = "#" + hex(parts[0]) + hex(parts[1]) + hex(parts[2]);
+                if (!ignoreAlpha && parts.length == 4)
+                    o = o + hex(parts[3]);
+            }
+            return o;
+        },
+        findWithFunction : function(a, f) {
+            if (a)
+                for (var i = 0; i < a.length; i++) if (f(a[i])) return i;
+            return -1;
+          },
+		indexOf : function(l, v) {
+			return l.indexOf ? l.indexOf(v) : exports.findWithFunction(l, function(_v) { return _v == v; });
+		},
+		removeWithFunction : function(a, f) {
+			var idx = exports.findWithFunction(a, f);
+			if (idx > -1) a.splice(idx, 1);
+			return idx != -1;
+		},
+		remove : function(l, v) {
+			var idx = exports.indexOf(l, v);
+			if (idx > -1) l.splice(idx, 1);
+			return idx != -1;
+		},
+        // TODO support insert index
+        addWithFunction : function(list, item, hashFunction) {
+            if (exports.findWithFunction(list, hashFunction) == -1) list.push(item);
+        },
+        addToList : function(map, key, value, insertAtStart) {
+            var l = map[key];
+            if (l == null) {
+                l = [];
+				        map[key] = l;
+            }
+            l[insertAtStart ? "unshift" : "push"](value);
+            return l;
+        },
+        //
+        // extends the given obj (which can be an array) with the given constructor function, prototype functions, and
+        // class members, any of which may be null.
+        //
+        extend : function(child, parent, _protoFn) {
+			       var i;
+            parent = _isa(parent) ? parent : [ parent ];
+
+            for (i = 0; i < parent.length; i++) {
+                for (var j in parent[i].prototype) {
+                    if(parent[i].prototype.hasOwnProperty(j)) {
+                        child.prototype[j] = parent[i].prototype[j];
+                    }
+                }
+            }
+
+            var _makeFn = function(name, protoFn) {
+                return function() {
+                    for (i = 0; i < parent.length; i++) {
+                        if (parent[i].prototype[name])
+                            parent[i].prototype[name].apply(this, arguments);
+                    }
+                    return protoFn.apply(this, arguments);
+                };
+            };
+
+			var _oneSet = function(fns) {
+				for (var k in fns) {
+					child.prototype[k] = _makeFn(k, fns[k]);
+				}
+			};
+
+			if (arguments.length > 2) {
+				for (i = 2; i < arguments.length; i++)
+					_oneSet(arguments[i]);
+			}
+
+            return child;
+        },
+        uuid : function() {
+            return ('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+                var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
+                return v.toString(16);
+            }));
+        },
+        logEnabled : true,
+        log : function() {
+            if (exports.logEnabled && typeof console != "undefined") {
+                try {
+                    var msg = arguments[arguments.length - 1];
+                    console.log(msg);
+                }
+                catch (e) {}
+            }
+        },
+
+        /**
+        * Wraps one function with another, creating a placeholder for the
+        * wrapped function if it was null. this is used to wrap the various
+        * drag/drop event functions - to allow jsPlumb to be notified of
+        * important lifecycle events without imposing itself on the user's
+        * drag/drop functionality.
+        * @method jsPlumbUtil.wrap
+        * @param {Function} wrappedFunction original function to wrap; may be null.
+        * @param {Function} newFunction function to wrap the original with.
+        * @param {Object} [returnOnThisValue] Optional. Indicates that the wrappedFunction should
+        * not be executed if the newFunction returns a value matching 'returnOnThisValue'.
+        * note that this is a simple comparison and only works for primitives right now.
+        */
+        wrap : function(wrappedFunction, newFunction, returnOnThisValue) {
+            wrappedFunction = wrappedFunction || function() { };
+            newFunction = newFunction || function() { };
+            return function() {
+                var r = null;
+                try {
+                    r = newFunction.apply(this, arguments);
+                } catch (e) {
+                    exports.log("jsPlumb function failed : " + e);
+                }
+                if (returnOnThisValue == null || (r !== returnOnThisValue)) {
+                    try {
+                        r = wrappedFunction.apply(this, arguments);
+                    } catch (e) {
+                        exports.log("wrapped function failed : " + e);
+                    }
+                }
+                return r;
+            };
+        }
+    };
+
+  exports.EventGenerator = function() {
+		var _listeners = {},
+			eventsSuspended = false,
+			// this is a list of events that should re-throw any errors that occur during their dispatch. it is current private.
+			eventsToDieOn = { "ready":true };
+
+		this.bind = function(event, listener, insertAtStart) {
+			exports.addToList(_listeners, event, listener, insertAtStart);
+			return this;
+		};
+
+		this.fire = function(event, value, originalEvent) {
+			if (!eventsSuspended && _listeners[event]) {
+				var l = _listeners[event].length, i = 0, _gone = false, ret = null;
+				if (!this.shouldFireEvent || this.shouldFireEvent(event, value, originalEvent)) {
+					while (!_gone && i < l && ret !== false) {
+						// doing it this way rather than catching and then possibly re-throwing means that an error propagated by this
+						// method will have the whole call stack available in the debugger.
+						if (eventsToDieOn[event])
+							_listeners[event][i].apply(this, [ value, originalEvent]);
+						else {
+							try {
+								ret = _listeners[event][i].apply(this, [ value, originalEvent ]);
+							} catch (e) {
+								exports.log("jsPlumb: fire failed for event " + event + " : " + e);
+							}
+						}
+						i++;
+						if (_listeners == null || _listeners[event] == null)
+							_gone = true;
+					}
+				}
+			}
+			return this;
+		};
+
+		this.unbind = function(event) {
+			if (event)
+				delete _listeners[event];
+			else {
+				_listeners = {};
+			}
+			return this;
+		};
+
+		this.getListener = function(forEvent) { return _listeners[forEvent]; };
+		this.setSuspendEvents = function(val) { eventsSuspended = val; };
+		this.isSuspendEvents = function() { return eventsSuspended; };
+		this.cleanupListeners = function() {
+			for (var i in _listeners) {
+				_listeners[i] = null;
+			}
+		};
+	};
+
+	exports.EventGenerator.prototype = {
+		cleanup:function() {
+			this.cleanupListeners();
+		}
+	};
+
+    // thanks MDC
+    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FFunction%2Fbind
+    if (!Function.prototype.bind) {
+      Function.prototype.bind = function (oThis) {
+        if (typeof this !== "function") {
+          // closest thing possible to the ECMAScript 5 internal IsCallable function
+          throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
+        }
+
+        var aArgs = Array.prototype.slice.call(arguments, 1),
+            fToBind = this,
+            fNOP = function () {},
+            fBound = function () {
+              return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
+                                   aArgs.concat(Array.prototype.slice.call(arguments)));
+            };
+
+        fNOP.prototype = this.prototype;
+        fBound.prototype = new fNOP();
+
+        return fBound;
+      };
+    }
+
+}).call(this);
+
+/*
+ * jsPlumb
+ *
+ * Title:jsPlumb 1.7.2
+ *
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.
+ *
+ * This file contains utility functions that run browsers only.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ *
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ *
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+ ;(function() {
+
+  "use strict";
+
+   var root = this;
+   var exports = root.jsPlumbUtil;
+
+   exports.ieVersion = /MSIE\s([\d.]+)/.test(navigator.userAgent) ? (new Number(RegExp.$1)) : -1;
+
+   exports.oldIE = exports.ieVersion > -1 && exports.ieVersion < 9;
+
+   exports.matchesSelector = function(el, selector, ctx) {
+       ctx = ctx || el.parentNode;
+       var possibles = ctx.querySelectorAll(selector);
+       for (var i = 0; i < possibles.length; i++) {
+           if (possibles[i] === el)
+               return true;
+       }
+       return false;
+   };
+
+   exports.consume = function(e, doNotPreventDefault) {
+       if (e.stopPropagation)
+           e.stopPropagation();
+       else
+           e.returnValue = false;
+
+       if (!doNotPreventDefault && e.preventDefault)
+            e.preventDefault();
+   };
+
+   /*
+    * Function: sizeElement
+    * Helper to size and position an element. You would typically use
+    * this when writing your own Connector or Endpoint implementation.
+    *
+    * Parameters:
+    *  x - [int] x position for the element origin
+    *  y - [int] y position for the element origin
+    *  w - [int] width of the element
+    *  h - [int] height of the element
+    *
+    */
+   exports.sizeElement = function(el, x, y, w, h) {
+       if (el) {
+           el.style.height = h + "px";
+           el.height = h;
+           el.style.width = w + "px";
+           el.width = w;
+           el.style.left = x + "px";
+           el.style.top = y + "px";
+       }
+   };
+
+
+ }).call(this);
+
+/*
+ * jsPlumb
+ *
+ * Title:jsPlumb 1.7.2
+ *
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.
+ *
+ * This file contains the base functionality for DOM type adapters.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ *
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ *
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+;(function() {
+
+  var root = this;
+
+	var svgAvailable = !!window.SVGAngle || document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"),
+		vmlAvailable = function() {
+	        if (vmlAvailable.vml === undefined) {
+	            var a = document.body.appendChild(document.createElement('div'));
+	        	a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
+	        	var b = a.firstChild;
+	        	if (b != null && b.style != null) {
+	            	b.style.behavior = "url(#default#VML)";
+	            	vmlAvailable.vml = b ? typeof b.adj == "object": true;
+	            }
+	            else
+	            	vmlAvailable.vml = false;
+	        	a.parentNode.removeChild(a);
+	        }
+	        return vmlAvailable.vml;
+		},
+		// TODO: remove this once we remove all library adapter versions and have only vanilla jsplumb: this functionality
+		// comes from Mottle.
+		iev = (function() {
+			var rv = -1;
+			if (navigator.appName == 'Microsoft Internet Explorer') {
+				var ua = navigator.userAgent,
+					re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+				if (re.exec(ua) != null)
+					rv = parseFloat(RegExp.$1);
+			}
+			return rv;
+		})(),
+		isIELT9 = iev > -1 && iev < 9,
+		_genLoc = function(e, prefix) {
+			if (e == null) return [ 0, 0 ];
+			var ts = _touches(e), t = _getTouch(ts, 0);
+			return [t[prefix + "X"], t[prefix + "Y"]];
+		},
+		_pageLocation = function(e) {
+			if (e == null) return [ 0, 0 ];
+			if (isIELT9) {
+				return [ e.clientX + document.documentElement.scrollLeft, e.clientY + document.documentElement.scrollTop ];
+			}
+			else {
+				return _genLoc(e, "page");
+			}
+		},
+		_screenLocation = function(e) {
+			return _genLoc(e, "screen");
+		},
+		_clientLocation = function(e) {
+			return _genLoc(e, "client");
+		},
+		_getTouch = function(touches, idx) { return touches.item ? touches.item(idx) : touches[idx]; },
+		_touches = function(e) {
+			return e.touches && e.touches.length > 0 ? e.touches :
+				   e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches :
+				   e.targetTouches && e.targetTouches.length > 0 ? e.targetTouches :
+				   [ e ];
+		};
+
+    /**
+		Manages dragging for some instance of jsPlumb.
+	*/
+	var DragManager = function(_currentInstance) {
+		var _draggables = {}, _dlist = [], _delements = {}, _elementsWithEndpoints = {},
+			// elementids mapped to the draggable to which they belong.
+			_draggablesForElements = {};
+
+        /**
+            register some element as draggable.  right now the drag init stuff is done elsewhere, and it is
+            possible that will continue to be the case.
+        */
+		this.register = function(el) {
+            var id = _currentInstance.getId(el),
+                parentOffset = jsPlumbAdapter.getOffset(el, _currentInstance);
+
+            if (!_draggables[id]) {
+                _draggables[id] = el;
+                _dlist.push(el);
+                _delements[id] = {};
+            }
+
+			// look for child elements that have endpoints and register them against this draggable.
+			var _oneLevel = function(p, startOffset) {
+				if (p) {
+					for (var i = 0; i < p.childNodes.length; i++) {
+						if (p.childNodes[i].nodeType != 3 && p.childNodes[i].nodeType != 8) {
+							var cEl = jsPlumb.getElementObject(p.childNodes[i]),
+								cid = _currentInstance.getId(p.childNodes[i], null, true);
+							if (cid && _elementsWithEndpoints[cid] && _elementsWithEndpoints[cid] > 0) {
+								var cOff = jsPlumbAdapter.getOffset(cEl, _currentInstance);
+								_delements[id][cid] = {
+									id:cid,
+									offset:{
+										left:cOff.left - parentOffset.left,
+										top:cOff.top - parentOffset.top
+									}
+								};
+								_draggablesForElements[cid] = id;
+							}
+							_oneLevel(p.childNodes[i]);
+						}
+					}
+				}
+			};
+
+			_oneLevel(el);
+		};
+
+		// refresh the offsets for child elements of this element.
+		this.updateOffsets = function(elId) {
+			if (elId != null) {
+				var domEl = jsPlumb.getDOMElement(elId),
+					id = _currentInstance.getId(domEl),
+					children = _delements[id],
+					parentOffset = jsPlumbAdapter.getOffset(domEl, _currentInstance);
+
+				if (children) {
+					for (var i in children) {
+						var cel = jsPlumb.getElementObject(i),
+							cOff = jsPlumbAdapter.getOffset(cel, _currentInstance);
+
+						_delements[id][i] = {
+							id:i,
+							offset:{
+								left:cOff.left - parentOffset.left,
+								top:cOff.top - parentOffset.top
+							}
+						};
+						_draggablesForElements[i] = id;
+					}
+				}
+			}
+		};
+
+		/**
+			notification that an endpoint was added to the given el.  we go up from that el's parent
+			node, looking for a parent that has been registered as a draggable. if we find one, we add this
+			el to that parent's list of elements to update on drag (if it is not there already)
+		*/
+		this.endpointAdded = function(el, id) {
+
+            id = id || _currentInstance.getId(el);
+
+			var b = document.body,
+				p = el.parentNode;
+
+			_elementsWithEndpoints[id] = _elementsWithEndpoints[id] ? _elementsWithEndpoints[id] + 1 : 1;
+
+			while (p != null && p != b) {
+				var pid = _currentInstance.getId(p, null, true);
+				if (pid && _draggables[pid]) {
+					var pLoc = jsPlumbAdapter.getOffset(p, _currentInstance);
+
+					if (_delements[pid][id] == null) {
+                        var cLoc = jsPlumbAdapter.getOffset(el, _currentInstance);
+						_delements[pid][id] = {
+							id:id,
+							offset:{
+								left:cLoc.left - pLoc.left,
+								top:cLoc.top - pLoc.top
+							}
+						};
+						_draggablesForElements[id] = pid;
+					}
+					break;
+				}
+				p = p.parentNode;
+			}
+		};
+
+		this.endpointDeleted = function(endpoint) {
+			if (_elementsWithEndpoints[endpoint.elementId]) {
+				_elementsWithEndpoints[endpoint.elementId]--;
+				if (_elementsWithEndpoints[endpoint.elementId] <= 0) {
+					for (var i in _delements) {
+						if (_delements[i]) {
+                            delete _delements[i][endpoint.elementId];
+                            delete _draggablesForElements[endpoint.elementId];
+                        }
+					}
+				}
+			}
+		};
+
+		this.changeId = function(oldId, newId) {
+			_delements[newId] = _delements[oldId];
+			_delements[oldId] = {};
+			_draggablesForElements[newId] = _draggablesForElements[oldId];
+			_draggablesForElements[oldId] = null;
+		};
+
+		this.getElementsForDraggable = function(id) {
+			return _delements[id];
+		};
+
+		this.elementRemoved = function(elementId) {
+			var elId = _draggablesForElements[elementId];
+			if (elId) {
+				delete _delements[elId][elementId];
+				delete _draggablesForElements[elementId];
+			}
+		};
+
+		this.reset = function() {
+			_draggables = {};
+			_dlist = [];
+			_delements = {};
+			_elementsWithEndpoints = {};
+		};
+
+		//
+		// notification drag ended. We check automatically if need to update some
+		// ancestor's offsets.
+		//
+		this.dragEnded = function(el) {
+			var id = _currentInstance.getId(el),
+				ancestor = _draggablesForElements[id];
+
+			if (ancestor) this.updateOffsets(ancestor);
+		};
+
+		this.setParent = function(el, elId, p, pId) {
+			var current = _draggablesForElements[elId];
+			if (current) {
+				if (!_delements[pId])
+					_delements[pId] = {};
+				_delements[pId][elId] = _delements[current][elId];
+				delete _delements[current][elId];
+				var pLoc = jsPlumbAdapter.getOffset(p, _currentInstance),
+					cLoc = jsPlumbAdapter.getOffset(el, _currentInstance);
+				_delements[pId][elId].offset = {
+					left:cLoc.left - pLoc.left,
+					top:cLoc.top - pLoc.top
+				};
+				_draggablesForElements[elId] = pId;
+			}
+		};
+
+		this.getDragAncestor = function(el) {
+			var de = jsPlumb.getDOMElement(el),
+				id = _currentInstance.getId(de),
+				aid = _draggablesForElements[id];
+
+			if (aid) 
+				return jsPlumb.getDOMElement(aid);
+			else
+				return null;
+		};
+
+	};
+
+    // for those browsers that dont have it.  they still don't have it! but at least they won't crash.
+	if (!window.console)
+		window.console = { time:function(){}, timeEnd:function(){}, group:function(){}, groupEnd:function(){}, log:function(){} };
+
+
+	// TODO: katavorio default helper uses this stuff.  should i extract to a support lib?
+	var trim = function(str) {
+			return str == null ? null : (str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''));
+		},
+		_setClassName = function(el, cn) {
+			cn = trim(cn);
+			if (typeof el.className.baseVal != "undefined")  // SVG
+				el.className.baseVal = cn;
+			else
+				el.className = cn;
+		},
+		_getClassName = function(el) {
+			return (typeof el.className.baseVal == "undefined") ? el.className : el.className.baseVal;
+		},
+		_classManip = function(el, add, clazz) {
+
+			// TODO if classList exists, use it.
+
+			var classesToAddOrRemove = jsPlumbUtil.isArray(clazz) ? clazz : clazz.split(/\s+/),
+				className = _getClassName(el),
+				curClasses = className.split(/\s+/);
+
+			for (var i = 0; i < classesToAddOrRemove.length; i++) {
+				if (add) {
+					if (jsPlumbUtil.indexOf(curClasses, classesToAddOrRemove[i]) == -1)
+						curClasses.push(classesToAddOrRemove[i]);
+				}
+				else {
+					var idx = jsPlumbUtil.indexOf(curClasses, classesToAddOrRemove[i]);
+					if (idx != -1)
+						curClasses.splice(idx, 1);
+				}
+			}
+			_setClassName(el, curClasses.join(" "));
+		},
+        _classManipNew = function(el, classesToAdd, classesToRemove) {
+
+            // TODO if classList exists, use it.
+
+            classesToAdd = classesToAdd == null ? [] : jsPlumbUtil.isArray(classesToAdd) ? classesToAdd : classesToAdd.split(/\s+/);
+            classesToRemove= classesToRemove== null ? [] : jsPlumbUtil.isArray(classesToRemove) ? classesToRemove: classesToRemove.split(/\s+/);
+
+            var className = _getClassName(el),
+                curClasses = className.split(/\s+/);
+
+            var _oneSet = function(add, classes) {
+                for (var i = 0; i < classes.length; i++) {
+                    if (add) {
+                        if (jsPlumbUtil.indexOf(curClasses, classes[i]) == -1)
+                            curClasses.push(classes[i]);
+                    }
+                    else {
+                        var idx = jsPlumbUtil.indexOf(curClasses, classes[i]);
+                        if (idx != -1)
+                            curClasses.splice(idx, 1);
+                    }
+                }
+            };
+
+            _oneSet(true, classesToAdd);
+            _oneSet(false, classesToRemove);
+
+            _setClassName(el, curClasses.join(" "));
+        },
+		_each = function(spec, fn) {
+			if (spec == null) return;
+			if (typeof spec === "string")
+				fn(jsPlumb.getDOMElement(spec));
+			else if (spec.length != null) {
+				for (var i = 0; i < spec.length; i++)
+					fn(jsPlumb.getDOMElement(spec[i]));
+			}
+			else
+				fn(spec); // assume it's an element.
+		};
+
+    window.jsPlumbAdapter = {
+
+        headless:false,
+
+        pageLocation:_pageLocation,
+        screenLocation:_screenLocation,
+        clientLocation:_clientLocation,
+
+        getAttribute:function(el, attName) {
+        	return el.getAttribute(attName);
+        },
+
+        setAttribute:function(el, a, v) {
+        	el.setAttribute(a, v);
+        },
+
+        appendToRoot : function(node) {
+            document.body.appendChild(node);
+        },
+        getRenderModes : function() {
+            return [ "svg", "vml" ];
+        },
+        isRenderModeAvailable : function(m) {
+            return {
+                "svg":svgAvailable,
+                "vml":vmlAvailable()
+            }[m];
+        },
+        getDragManager : function(_jsPlumb) {
+            return new DragManager(_jsPlumb);
+        },
+        setRenderMode : function(mode) {
+            var renderMode;
+
+            if (mode) {
+				mode = mode.toLowerCase();
+
+                var svgAvailable = this.isRenderModeAvailable("svg"),
+                    vmlAvailable = this.isRenderModeAvailable("vml");
+
+                // now test we actually have the capability to do this.
+                if (mode === "svg") {
+                    if (svgAvailable) renderMode = "svg";
+                    else if (vmlAvailable) renderMode = "vml";
+                }
+                else if (vmlAvailable) renderMode = "vml";
+            }
+
+			return renderMode;
+        },
+		addClass:function(el, clazz) {
+			_each(el, function(e) {
+				_classManipNew(e, clazz);
+			});
+		},
+		hasClass:function(el, clazz) {
+			el = jsPlumb.getDOMElement(el);
+			if (el.classList) return el.classList.contains(clazz);
+			else {
+				return _getClassName(el).indexOf(clazz) != -1;
+			}
+		},
+		removeClass:function(el, clazz) {
+			_each(el, function(e) {
+				_classManipNew(e, null, clazz);
+			});
+		},
+        updateClasses:function(el, toAdd, toRemove) {
+            _each(el, function(e) {
+                _classManipNew(e, toAdd, toRemove);
+            });
+        },
+		setClass:function(el, clazz) {
+			_each(el, function(e) {
+				_setClassName(e, clazz);
+			});
+		},
+		setPosition:function(el, p) {
+			el.style.left = p.left + "px";
+			el.style.top = p.top + "px";
+		},
+		getPosition:function(el) {
+			var _one = function(prop) {
+				var v = el.style[prop];
+				return v ? v.substring(0, v.length - 2) : 0;
+			};
+			return {
+				left:_one("left"),
+				top:_one("top")
+			};
+		},
+		getOffset:function(el, _instance, relativeToRoot) {
+			el = jsPlumb.getDOMElement(el);
+			var container = _instance.getContainer();
+			var l = el.offsetLeft, t = el.offsetTop, op = (relativeToRoot  || (container != null && el.offsetParent != container)) ?  el.offsetParent : null;
+			while (op != null) {
+				l += op.offsetLeft;
+				t += op.offsetTop;
+				op = relativeToRoot ? op.offsetParent :
+					op.offsetParent == container ? null : op.offsetParent;
+			}
+			return {
+				left:l, top:t
+			};
+		},
+		//
+		// return x+y proportion of the given element's size corresponding to the location of the given event.
+		//
+    getPositionOnElement:function(evt, el, zoom) {
+      var box = typeof el.getBoundingClientRect !== "undefined" ? el.getBoundingClientRect() : { left:0, top:0, width:0, height:0 },
+				  body = document.body,
+    			docElem = document.documentElement,
+    			offPar = el.offsetParent,
+    			scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop,
+				  scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft,
+				  clientTop = docElem.clientTop || body.clientTop || 0,
+				  clientLeft = docElem.clientLeft || body.clientLeft || 0,
+				  pst = 0,//offPar ? offPar.scrollTop : 0,
+				  psl = 0,//offPar ? offPar.scrollLeft : 0,
+				  top  = box.top +  scrollTop - clientTop + (pst * zoom),
+				  left = box.left + scrollLeft - clientLeft + (psl * zoom),
+				  cl = jsPlumbAdapter.pageLocation(evt),
+				  w = box.width || (el.offsetWidth * zoom),
+				  h = box.height || (el.offsetHeight * zoom),
+				  x = (cl[0] - left) / w,
+				  y = (cl[1] - top) / h;
+
+			 return [ x, y ];
+     },
+
+     /**
+    * Gets the absolute position of some element as read from the left/top properties in its style.
+    * @method getAbsolutePosition
+    * @param {Element} el The element to retrieve the absolute coordinates from. **Note** this is a DOM element, not a selector from the underlying library.
+    * @return [Float, Float] [left, top] pixel values.
+    */
+    getAbsolutePosition : function(el) {
+        var _one = function(s) {
+            var ss = el.style[s];
+            if (ss) return parseFloat(ss.substring(0, ss.length - 2));
+        };
+        return [ _one("left"), _one("top") ];
+    },
+
+    /**
+    * Sets the absolute position of some element by setting the left/top properties in its style.
+    * @method setAbsolutePosition
+    * @param {Element} el The element to set the absolute coordinates on. **Note** this is a DOM element, not a selector from the underlying library.
+    * @param {Float[]} xy x and y coordinates
+	  * @param {Float[]} [animateFrom] Optional previous xy to animate from.
+    */
+    setAbsolutePosition : function(el, xy, animateFrom, animateOptions) {
+		  if (animateFrom) {
+			     root.jsPlumb.animate(el, {
+				     left: "+=" + (xy[0] - animateFrom[0]),
+				     top: "+=" + (xy[1] - animateFrom[1])
+			     }, animateOptions);
+		  }
+		  else {
+			  el.style.left = xy[0] + "px";
+			  el.style.top = xy[1] + "px";
+		  }
+    }
+
+
+
+
+    };
+
+}).call(this);
+
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the core code.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+;(function() {
+	
+	"use strict";
+			
+    var _ju = jsPlumbUtil,
+    	_getOffset = function(el, _instance, relativeToRoot) {
+            return jsPlumbAdapter.getOffset(el, _instance, relativeToRoot);
+        },
+		
+		/**
+		 * creates a timestamp, using milliseconds since 1970, but as a string.
+		 */
+		_timestamp = function() { return "" + (new Date()).getTime(); },
+
+		// helper method to update the hover style whenever it, or paintStyle, changes.
+		// we use paintStyle as the foundation and merge hoverPaintStyle over the
+		// top.
+		_updateHoverStyle = function(component) {
+			if (component._jsPlumb.paintStyle && component._jsPlumb.hoverPaintStyle) {
+				var mergedHoverStyle = {};
+				jsPlumb.extend(mergedHoverStyle, component._jsPlumb.paintStyle);
+				jsPlumb.extend(mergedHoverStyle, component._jsPlumb.hoverPaintStyle);
+				delete component._jsPlumb.hoverPaintStyle;
+				// we want the fillStyle of paintStyle to override a gradient, if possible.
+				if (mergedHoverStyle.gradient && component._jsPlumb.paintStyle.fillStyle)
+					delete mergedHoverStyle.gradient;
+				component._jsPlumb.hoverPaintStyle = mergedHoverStyle;
+			}
+		},		
+		//events = [ "click", "dblclick", "mouseenter", "mouseout", "mousemove", "mousedown", "mouseup", "contextmenu" ],
+        events = [ "click", "dblclick", "mouseover", "mouseout", "mousemove", "mousedown", "mouseup", "contextmenu" ],
+		eventFilters = { "mouseout":"mouseleave", "mouseexit":"mouseleave" },
+		_updateAttachedElements = function(component, state, timestamp, sourceElement) {
+			var affectedElements = component.getAttachedElements();
+			if (affectedElements) {
+				for (var i = 0, j = affectedElements.length; i < j; i++) {
+					if (!sourceElement || sourceElement != affectedElements[i])
+						affectedElements[i].setHover(state, true, timestamp);			// tell the attached elements not to inform their own attached elements.
+				}
+			}
+		},
+		_splitType = function(t) { return t == null ? null : t.split(" "); },		
+		_applyTypes = function(component, params, doNotRepaint) {
+			if (component.getDefaultType) {
+				var td = component.getTypeDescriptor();
+					
+				var o = _ju.merge({}, component.getDefaultType());
+				for (var i = 0, j = component._jsPlumb.types.length; i < j; i++)
+					o = _ju.merge(o, component._jsPlumb.instance.getType(component._jsPlumb.types[i], td), [ "cssClass" ]);
+					
+				if (params) {
+					o = _ju.populate(o, params);
+				}
+			
+				component.applyType(o, doNotRepaint);					
+				if (!doNotRepaint) component.repaint();
+			}
+		},		
+
+// ------------------------------ BEGIN jsPlumbUIComponent --------------------------------------------
+
+		jsPlumbUIComponent = window.jsPlumbUIComponent = function(params) {
+
+			jsPlumbUtil.EventGenerator.apply(this, arguments);
+
+			var self = this, 
+				a = arguments, 				 				
+				idPrefix = self.idPrefix,
+				id = idPrefix + (new Date()).getTime();
+
+			this._jsPlumb = { 
+				instance: params._jsPlumb,
+				parameters:params.parameters || {},
+				paintStyle:null,
+				hoverPaintStyle:null,
+				paintStyleInUse:null,
+				hover:false,
+				beforeDetach:params.beforeDetach,
+				beforeDrop:params.beforeDrop,
+				overlayPlacements : [],
+				hoverClass: params.hoverClass || params._jsPlumb.Defaults.HoverClass,
+				types:[]
+			};
+
+			this.getId = function() { return id; };	
+			
+			// all components can generate events
+			
+			if (params.events) {
+				for (var i in params.events)
+					self.bind(i, params.events[i]);
+			}
+
+			// all components get this clone function.
+			// TODO issue 116 showed a problem with this - it seems 'a' that is in
+			// the clone function's scope is shared by all invocations of it, the classic
+			// JS closure problem.  for now, jsPlumb does a version of this inline where 
+			// it used to call clone.  but it would be nice to find some time to look
+			// further at this.
+			this.clone = function() {
+				var o = {};//new Object();
+				this.constructor.apply(o, a);
+				return o;
+			}.bind(this);				
+						
+			// user can supply a beforeDetach callback, which will be executed before a detach
+			// is performed; returning false prevents the detach.			
+			this.isDetachAllowed = function(connection) {
+				var r = true;
+				if (this._jsPlumb.beforeDetach) {
+					try { 
+						r = this._jsPlumb.beforeDetach(connection); 
+					}
+					catch (e) { _ju.log("jsPlumb: beforeDetach callback failed", e); }
+				}
+				return r;
+			};
+			
+			// user can supply a beforeDrop callback, which will be executed before a dropped
+			// connection is confirmed. user can return false to reject connection.			
+			this.isDropAllowed = function(sourceId, targetId, scope, connection, dropEndpoint, source, target) {
+					var r = this._jsPlumb.instance.checkCondition("beforeDrop", { 
+						sourceId:sourceId, 
+						targetId:targetId, 
+						scope:scope,
+						connection:connection,
+						dropEndpoint:dropEndpoint,
+						source:source, target:target
+					});
+					if (this._jsPlumb.beforeDrop) {
+						try { 
+							r = this._jsPlumb.beforeDrop({ 
+								sourceId:sourceId, 
+								targetId:targetId, 
+								scope:scope, 
+								connection:connection,
+								dropEndpoint:dropEndpoint,
+								source:source, target:target
+							}); 
+						}
+						catch (e) { _ju.log("jsPlumb: beforeDrop callback failed", e); }
+					}
+					return r;
+				};													
+
+		    var boundListeners = [],
+		    	bindAListener = function(obj, type, fn) {
+			    	boundListeners.push([obj, type, fn]);
+			    	obj.bind(type, fn);
+			    },
+		    	domListeners = [];
+
+			// sets the component associated with listener events. for instance, an overlay delegates
+			// its events back to a connector. but if the connector is swapped on the underlying connection,
+			// then this component must be changed. This is called by setConnector in the Connection class.
+			this.setListenerComponent = function(c) {
+				for (var i = 0; i < domListeners.length; i++)
+					domListeners[i][3] = c;
+			};
+
+
+
+		    
+		};
+
+		var _removeTypeCssHelper = function(component, typeIndex) {
+			var typeId = component._jsPlumb.types[typeIndex],
+				type = component._jsPlumb.instance.getType(typeId, component.getTypeDescriptor());
+
+			if (type != null) {
+
+				if (type.cssClass && component.canvas)
+					component._jsPlumb.instance.removeClass(component.canvas, type.cssClass);
+			}
+		};
+
+		jsPlumbUtil.extend(jsPlumbUIComponent, jsPlumbUtil.EventGenerator, {
+			
+			getParameter : function(name) { 
+				return this._jsPlumb.parameters[name]; 
+			},
+			
+			setParameter : function(name, value) { 
+				this._jsPlumb.parameters[name] = value; 
+			},
+			
+			getParameters : function() { 
+				return this._jsPlumb.parameters; 
+			},			
+			
+			setParameters : function(p) { 
+				this._jsPlumb.parameters = p; 
+			},			
+			
+			addClass : function(clazz) {
+			    jsPlumbAdapter.addClass(this.canvas, clazz);
+			},
+						
+			removeClass : function(clazz) {
+			    jsPlumbAdapter.removeClass(this.canvas, clazz);
+			},
+
+            updateClasses : function(classesToAdd, classesToRemove) {
+                jsPlumbAdapter.updateClasses(this.canvas, classesToAdd, classesToRemove);
+            },
+			
+			setType : function(typeId, params, doNotRepaint) {	
+				this.clearTypes();			
+				this._jsPlumb.types = _splitType(typeId) || [];
+				_applyTypes(this, params, doNotRepaint);									
+			},
+			
+			getType : function() {
+				return this._jsPlumb.types;
+			},
+			
+			reapplyTypes : function(params, doNotRepaint) {
+				_applyTypes(this, params, doNotRepaint);
+			},
+			
+			hasType : function(typeId) {
+				return jsPlumbUtil.indexOf(this._jsPlumb.types, typeId) != -1;
+			},
+			
+			addType : function(typeId, params, doNotRepaint) {
+				var t = _splitType(typeId), _cont = false;
+				if (t != null) {
+					for (var i = 0, j = t.length; i < j; i++) {
+						if (!this.hasType(t[i])) {
+							this._jsPlumb.types.push(t[i]);
+							_cont = true;						
+						}
+					}
+					if (_cont) _applyTypes(this, params, doNotRepaint);
+				}
+			},
+			
+			removeType : function(typeId, doNotRepaint) {
+				var t = _splitType(typeId), _cont = false, _one = function(tt) {
+						var idx = _ju.indexOf(this._jsPlumb.types, tt);
+						if (idx != -1) {
+							// remove css class if necessary
+							_removeTypeCssHelper(this, idx);
+							this._jsPlumb.types.splice(idx, 1);
+							return true;
+						}
+						return false;
+					}.bind(this);
+				
+				if (t != null) {
+					for (var i = 0,j = t.length; i < j; i++) {
+						_cont = _one(t[i]) || _cont;
+					}
+					if (_cont) _applyTypes(this, null, doNotRepaint);
+				}
+			},
+			clearTypes : function(doNotRepaint) {
+				var i = this._jsPlumb.types.length;
+				for (var j = 0; j < i; j++) {
+					_removeTypeCssHelper(this, 0);
+					this._jsPlumb.types.splice(0, 1);
+				}
+				_applyTypes(this, {}, doNotRepaint);
+			},
+			
+			toggleType : function(typeId, params, doNotRepaint) {
+				var t = _splitType(typeId);
+				if (t != null) {
+					for (var i = 0, j = t.length; i < j; i++) {
+						var idx = jsPlumbUtil.indexOf(this._jsPlumb.types, t[i]);
+						if (idx != -1) {
+							_removeTypeCssHelper(this, idx);
+							this._jsPlumb.types.splice(idx, 1);
+						}
+						else
+							this._jsPlumb.types.push(t[i]);
+					}
+						
+					_applyTypes(this, params, doNotRepaint);
+				}
+			},
+			applyType : function(t, doNotRepaint) {
+				this.setPaintStyle(t.paintStyle, doNotRepaint);				
+				this.setHoverPaintStyle(t.hoverPaintStyle, doNotRepaint);
+				if (t.parameters){
+					for (var i in t.parameters)
+						this.setParameter(i, t.parameters[i]);
+				}
+			},
+			setPaintStyle : function(style, doNotRepaint) {
+//		    	this._jsPlumb.paintStyle = jsPlumb.extend({}, style);
+// TODO figure out if we want components to clone paintStyle so as not to share it.
+				this._jsPlumb.paintStyle = style;
+		    	this._jsPlumb.paintStyleInUse = this._jsPlumb.paintStyle;
+		    	_updateHoverStyle(this);
+		    	if (!doNotRepaint) this.repaint();
+		    },
+		    getPaintStyle : function() {
+		    	return this._jsPlumb.paintStyle;
+		    },
+		    setHoverPaintStyle : function(style, doNotRepaint) {		    	
+		    	//this._jsPlumb.hoverPaintStyle = jsPlumb.extend({}, style);
+// TODO figure out if we want components to clone paintStyle so as not to share it.		    	
+		    	this._jsPlumb.hoverPaintStyle = style;
+		    	_updateHoverStyle(this);
+		    	if (!doNotRepaint) this.repaint();
+		    },
+		    getHoverPaintStyle : function() {
+		    	return this._jsPlumb.hoverPaintStyle;
+		    },
+			destroy:function() {
+				this.cleanupListeners(); // this is on EventGenerator
+				this.clone = null;
+				this._jsPlumb = null;
+			},
+			
+			isHover : function() { return this._jsPlumb.hover; },
+			
+			setHover : function(hover, ignoreAttachedElements, timestamp) {
+				// while dragging, we ignore these events.  this keeps the UI from flashing and
+		    	// swishing and whatevering.
+				if (this._jsPlumb && !this._jsPlumb.instance.currentlyDragging && !this._jsPlumb.instance.isHoverSuspended()) {
+		    
+			    	this._jsPlumb.hover = hover;
+                        
+                    if (this.canvas != null) {
+                        if (this._jsPlumb.instance.hoverClass != null) {
+                        	var method = hover ? "addClass" : "removeClass";
+							this._jsPlumb.instance[method](this.canvas, this._jsPlumb.instance.hoverClass);
+                        }
+                        if (this._jsPlumb.hoverClass != null) {
+							this._jsPlumb.instance[method](this.canvas, this._jsPlumb.hoverClass);
+                        }
+                    }
+		   		 	if (this._jsPlumb.hoverPaintStyle != null) {
+						this._jsPlumb.paintStyleInUse = hover ? this._jsPlumb.hoverPaintStyle : this._jsPlumb.paintStyle;
+						if (!this._jsPlumb.instance.isSuspendDrawing()) {
+							timestamp = timestamp || _timestamp();
+							this.repaint({timestamp:timestamp, recalc:false});
+						}
+					}
+					// get the list of other affected elements, if supported by this component.
+					// for a connection, its the endpoints.  for an endpoint, its the connections! surprise.
+					if (this.getAttachedElements && !ignoreAttachedElements)
+						_updateAttachedElements(this, hover, _timestamp(), this);
+				}
+		    }
+		});
+
+// ------------------------------ END jsPlumbUIComponent --------------------------------------------
+
+// ------------------------------ BEGIN OverlayCapablejsPlumbUIComponent --------------------------------------------
+
+		var _internalLabelOverlayId = "__label",
+			// helper to get the index of some overlay
+			_getOverlayIndex = function(component, id) {
+				var idx = -1;
+				for (var i = 0, j = component._jsPlumb.overlays.length; i < j; i++) {
+					if (id === component._jsPlumb.overlays[i].id) {
+						idx = i;
+						break;
+					}
+				}
+				return idx;
+			},
+			// this is a shortcut helper method to let people add a label as
+			// overlay.
+			_makeLabelOverlay = function(component, params) {
+
+				var _params = {
+					cssClass:params.cssClass,
+					labelStyle : component.labelStyle,
+					id:_internalLabelOverlayId,
+					component:component,
+					_jsPlumb:component._jsPlumb.instance  // TODO not necessary, since the instance can be accessed through the component.
+				},
+				mergedParams = jsPlumb.extend(_params, params);
+
+				return new jsPlumb.Overlays[component._jsPlumb.instance.getRenderMode()].Label( mergedParams );
+			},
+			_processOverlay = function(component, o) {
+				var _newOverlay = null;
+				if (_ju.isArray(o)) {	// this is for the shorthand ["Arrow", { width:50 }] syntax
+					// there's also a three arg version:
+					// ["Arrow", { width:50 }, {location:0.7}] 
+					// which merges the 3rd arg into the 2nd.
+					var type = o[0], 
+						// make a copy of the object so as not to mess up anyone else's reference...
+						p = jsPlumb.extend({component:component, _jsPlumb:component._jsPlumb.instance}, o[1]);
+					if (o.length == 3) jsPlumb.extend(p, o[2]);
+					_newOverlay = new jsPlumb.Overlays[component._jsPlumb.instance.getRenderMode()][type](p);
+				} else if (o.constructor == String) {
+					_newOverlay = new jsPlumb.Overlays[component._jsPlumb.instance.getRenderMode()][o]({component:component, _jsPlumb:component._jsPlumb.instance});
+				} else {
+					_newOverlay = o;
+				}										
+					
+				component._jsPlumb.overlays.push(_newOverlay);
+			},
+			_calculateOverlaysToAdd = function(component, params) {
+				var defaultKeys = component.defaultOverlayKeys || [], o = params.overlays,
+					checkKey = function(k) {
+						return component._jsPlumb.instance.Defaults[k] || jsPlumb.Defaults[k] || [];
+					};
+				
+				if (!o) o = [];
+
+				for (var i = 0, j = defaultKeys.length; i < j; i++)
+					o.unshift.apply(o, checkKey(defaultKeys[i]));
+				
+				return o;
+			},		
+			OverlayCapableJsPlumbUIComponent = window.OverlayCapableJsPlumbUIComponent = function(params) {
+
+				jsPlumbUIComponent.apply(this, arguments);
+				this._jsPlumb.overlays = [];			
+
+				var _overlays = _calculateOverlaysToAdd(this, params);
+				if (_overlays) {
+					for (var i = 0, j = _overlays.length; i < j; i++) {
+						_processOverlay(this, _overlays[i]);
+					}
+				}
+				
+				if (params.label) {
+					var loc = params.labelLocation || this.defaultLabelLocation || 0.5,
+						labelStyle = params.labelStyle || this._jsPlumb.instance.Defaults.LabelStyle;
+
+					this._jsPlumb.overlays.push(_makeLabelOverlay(this, {
+						label:params.label,
+						location:loc,
+						labelStyle:labelStyle
+					}));
+				}		
+
+				this.setListenerComponent = function(c) {
+					if (this._jsPlumb) {
+						for (var i = 0; i < this._jsPlumb.overlays.length; i++)
+							this._jsPlumb.overlays[i].setListenerComponent(c);
+					}
+				};
+			};
+
+		jsPlumbUtil.extend(OverlayCapableJsPlumbUIComponent, jsPlumbUIComponent, {
+			applyType : function(t, doNotRepaint) {			
+				this.removeAllOverlays(doNotRepaint);
+				if (t.overlays) {
+					for (var i = 0, j = t.overlays.length; i < j; i++)
+						this.addOverlay(t.overlays[i], true);
+				}
+			},
+			setHover : function(hover, ignoreAttachedElements) {
+				if (this._jsPlumb && !this._jsPlumb.instance.isConnectionBeingDragged()) {
+	                for (var i = 0, j = this._jsPlumb.overlays.length; i < j; i++) {
+						this._jsPlumb.overlays[i][hover ? "addClass":"removeClass"](this._jsPlumb.instance.hoverClass);
+					}
+				}
+            },
+            addOverlay : function(overlay, doNotRepaint) { 
+				_processOverlay(this, overlay); 
+				if (!doNotRepaint) this.repaint();
+			},
+			getOverlay : function(id) {
+				var idx = _getOverlayIndex(this, id);
+				return idx >= 0 ? this._jsPlumb.overlays[idx] : null;
+			},			
+			getOverlays : function() {
+				return this._jsPlumb.overlays;
+			},			
+			hideOverlay : function(id) {
+				var o = this.getOverlay(id);
+				if (o) o.hide();
+			},
+			hideOverlays : function() {
+				for (var i = 0, j = this._jsPlumb.overlays.length; i < j; i++)
+					this._jsPlumb.overlays[i].hide();
+			},
+			showOverlay : function(id) {
+				var o = this.getOverlay(id);
+				if (o) o.show();
+			},
+			showOverlays : function() {
+				for (var i = 0, j = this._jsPlumb.overlays.length; i < j; i++)
+					this._jsPlumb.overlays[i].show();
+			},
+			removeAllOverlays : function(doNotRepaint) {
+				for (var i = 0, j = this._jsPlumb.overlays.length; i < j; i++) {
+					if (this._jsPlumb.overlays[i].cleanup) this._jsPlumb.overlays[i].cleanup();
+				}
+
+				this._jsPlumb.overlays.splice(0, this._jsPlumb.overlays.length);
+				this._jsPlumb.overlayPositions = null;
+				if (!doNotRepaint)
+					this.repaint();
+			},
+			removeOverlay : function(overlayId) {
+				var idx = _getOverlayIndex(this, overlayId);
+				if (idx != -1) {
+					var o = this._jsPlumb.overlays[idx];
+					if (o.cleanup) o.cleanup();
+					this._jsPlumb.overlays.splice(idx, 1);
+					if (this._jsPlumb.overlayPositions)  
+						delete this._jsPlumb.overlayPositions[overlayId];
+				}
+			},
+			removeOverlays : function() {
+				for (var i = 0, j = arguments.length; i < j; i++)
+					this.removeOverlay(arguments[i]);
+			},
+			moveParent:function(newParent) {
+				if (this.bgCanvas) {
+				    this.bgCanvas.parentNode.removeChild(this.bgCanvas);
+				    newParent.appendChild(this.bgCanvas);
+				}
+				
+				this.canvas.parentNode.removeChild(this.canvas);
+				newParent.appendChild(this.canvas);
+
+				for (var i = 0; i < this._jsPlumb.overlays.length; i++) {
+				    if (this._jsPlumb.overlays[i].isAppendedAtTopLevel) {
+				        this._jsPlumb.overlays[i].canvas.parentNode.removeChild(this._jsPlumb.overlays[i].canvas);
+				        newParent.appendChild(this._jsPlumb.overlays[i].canvas);  
+				    }
+				}
+			},
+			getLabel : function() {
+				var lo = this.getOverlay(_internalLabelOverlayId);
+				return lo != null ? lo.getLabel() : null;
+			},		
+			getLabelOverlay : function() {
+				return this.getOverlay(_internalLabelOverlayId);
+			},
+			setLabel : function(l) {
+				var lo = this.getOverlay(_internalLabelOverlayId);
+				if (!lo) {
+					var params = l.constructor == String || l.constructor == Function ? { label:l } : l;
+					lo = _makeLabelOverlay(this, params);	
+					this._jsPlumb.overlays.push(lo);
+				}
+				else {
+					if (l.constructor == String || l.constructor == Function) lo.setLabel(l);
+					else {
+						if (l.label) lo.setLabel(l.label);
+						if (l.location) lo.setLocation(l.location);
+					}
+				}
+				
+				if (!this._jsPlumb.instance.isSuspendDrawing()) 
+					this.repaint();
+			},
+			cleanup:function() {
+				for (var i = 0; i < this._jsPlumb.overlays.length; i++) {
+					this._jsPlumb.overlays[i].cleanup();
+					this._jsPlumb.overlays[i].destroy();
+				}
+				this._jsPlumb.overlays.length = 0;
+				this._jsPlumb.overlayPositions = null;
+			},
+			setVisible:function(v) {
+				this[v ? "showOverlays" : "hideOverlays"]();
+			},
+			setAbsoluteOverlayPosition:function(overlay, xy) {
+				this._jsPlumb.overlayPositions = this._jsPlumb.overlayPositions || {};
+				this._jsPlumb.overlayPositions[overlay.id] = xy;
+			},
+			getAbsoluteOverlayPosition:function(overlay) {
+				return this._jsPlumb.overlayPositions ? this._jsPlumb.overlayPositions[overlay.id] : null;
+			}
+		});		
+
+// ------------------------------ END OverlayCapablejsPlumbUIComponent --------------------------------------------
+		
+		var _jsPlumbInstanceIndex = 0,
+			getInstanceIndex = function() {
+				var i = _jsPlumbInstanceIndex + 1;
+				_jsPlumbInstanceIndex++;
+				return i;
+			};
+
+		var jsPlumbInstance = window.jsPlumbInstance = function(_defaults) {
+				
+			this.Defaults = {
+				Anchor : "Bottom",
+				Anchors : [ null, null ],
+	            ConnectionsDetachable : true,
+	            ConnectionOverlays : [ ],
+	            Connector : "Bezier",
+				Container : null,
+				DoNotThrowErrors:false,
+				DragOptions : { },
+				DropOptions : { },
+				Endpoint : "Dot",
+				EndpointOverlays : [ ],
+				Endpoints : [ null, null ],
+				EndpointStyle : { fillStyle : "#456" },
+				EndpointStyles : [ null, null ],
+				EndpointHoverStyle : null,
+				EndpointHoverStyles : [ null, null ],
+				HoverPaintStyle : null,
+				LabelStyle : { color : "black" },
+				LogEnabled : false,
+				Overlays : [ ],
+				MaxConnections : 1, 
+				PaintStyle : { lineWidth : 4, strokeStyle : "#456" },
+				ReattachConnections:false,
+				RenderMode : "svg",
+				Scope : "jsPlumb_DefaultScope"
+			};
+			if (_defaults) jsPlumb.extend(this.Defaults, _defaults);
+		
+			this.logEnabled = this.Defaults.LogEnabled;
+			this._connectionTypes = {};
+			this._endpointTypes = {};
+
+			jsPlumbUtil.EventGenerator.apply(this);
+
+			var _currentInstance = this,
+				_instanceIndex = getInstanceIndex(),
+				_bb = _currentInstance.bind,
+				_initialDefaults = {},
+	            _zoom = 1,
+	            _info = function(el) {
+	            	var _el = _currentInstance.getDOMElement(el);	
+	            	return { el:_el, id:(jsPlumbUtil.isString(el) && _el == null) ? el : _getId(_el) };
+	            };
+            
+	        this.getInstanceIndex = function() { return _instanceIndex; };
+
+        	this.setZoom = function(z, repaintEverything) {
+        		if (!jsPlumbUtil.oldIE) {
+	            	_zoom = z;
+					_currentInstance.fire("zoom", _zoom);
+	            	if (repaintEverything) _currentInstance.repaintEverything();
+	            }
+	            return !jsPlumbUtil.oldIE;
+
+        	};
+        	this.getZoom = function() { return _zoom; };
+                        
+			for (var i in this.Defaults)
+				_initialDefaults[i] = this.Defaults[i];
+
+			var _container;
+			this.setContainer = function(c) {
+
+                // TODO if a _container already exists, unbind delegations from it
+
+				c = this.getDOMElement(c);
+				this.select().each(function(conn) {
+					conn.moveParent(c);
+				});
+				this.selectEndpoints().each(function(ep) {
+					ep.moveParent(c);
+				});
+				_container = c;
+
+                var _oneDelegateHandler = function(id, e) {
+                    var t = e.srcElement || e.target,
+                        jp = (t && t.parentNode ? t.parentNode._jsPlumb : null) || (t ? t._jsPlumb : null) || (t && t.parentNode && t.parentNode.parentNode ? t.parentNode.parentNode._jsPlumb : null);
+                    if (jp) {
+                        jp.fire(id, jp, e);
+                        // jsplumb also fires every event coming from components
+                        _currentInstance.fire(id, jp, e);
+                    }
+                };
+
+                // delegate one event on the container to jsplumb elements. it might be possible to
+                // abstract this out: each of endpoint, connection and overlay could register themselves with
+                // jsplumb as "component types" or whatever, and provide a suitable selector. this would be
+                // done by the renderer (although admittedly from 2.0 onwards we're not supporting vml anymore)
+                var _oneDelegate = function(id) {
+                    // connections.
+                    _currentInstance.on(_container, id, "._jsPlumb_connector, ._jsPlumb_connector > *", function(e) { _oneDelegateHandler(id, e); });
+                    // endpoints. note they can have an enclosing div, or not.
+                    _currentInstance.on(_container, id, "._jsPlumb_endpoint, ._jsPlumb_endpoint > *, ._jsPlumb_endpoint svg *", function(e) { _oneDelegateHandler(id, e); });
+                    // overlays
+                    _currentInstance.on(_container, id, "._jsPlumb_overlay, ._jsPlumb_overlay *", function(e) { _oneDelegateHandler(id, e); });
+                };
+
+                for (var i = 0; i < events.length; i++)
+                    _oneDelegate(events[i]);
+
+			};
+			this.getContainer = function() {
+				return _container;
+			};
+			
+			this.bind = function(event, fn) {		
+				if ("ready" === event && initialized) fn();
+				else _bb.apply(_currentInstance,[event, fn]);
+			};
+
+			_currentInstance.importDefaults = function(d) {
+				for (var i in d) {
+					_currentInstance.Defaults[i] = d[i];
+				}
+				if (d.Container)
+					_currentInstance.setContainer(d.Container);
+
+				return _currentInstance;
+			};		
+			
+			_currentInstance.restoreDefaults = function() {
+				_currentInstance.Defaults = jsPlumb.extend({}, _initialDefaults);
+				return _currentInstance;
+			};
+
+            //_currentInstance.floatingConnections = {};ctions = {};
+		
+		    var log = null,
+		        initialized = false,
+		        // TODO remove from window scope       
+		        connections = [],
+		        // map of element id -> endpoint lists. an element can have an arbitrary
+		        // number of endpoints on it, and not all of them have to be connected
+		        // to anything.         
+		        endpointsByElement = {},
+		        endpointsByUUID = {},
+                // SP new
+                managedElements = {},
+		        offsets = {},
+		        offsetTimestamps = {},
+
+		        draggableStates = {},		
+		        connectionBeingDragged = false,
+		        sizes = [],
+		        _suspendDrawing = false,
+		        _suspendedAt = null,
+		        DEFAULT_SCOPE = this.Defaults.Scope,
+		        renderMode = null,  // will be set in init()		
+		        _curIdStamp = 1,
+		        _idstamp = function() { return "" + _curIdStamp++; },							
+		
+				//
+				// appends an element to some other element, which is calculated as follows:
+				// 
+				// 1. if Container exists, use that element.
+				// 2. if the 'parent' parameter exists, use that.
+				// 3. otherwise just use the root element (for DOM usage, the document body).
+				// 
+				//
+				_appendElement = function(el, parent) {
+					if (_container)
+						_container.appendChild(el);
+					else if (!parent)
+						this.appendToRoot(el);
+					else
+						this.getDOMElement(parent).appendChild(el);
+                }.bind(this),
+
+			//
+			// Draws an endpoint and its connections. this is the main entry point into drawing connections as well
+			// as endpoints, since jsPlumb is endpoint-centric under the hood.
+			// 
+			// @param element element to draw (of type library specific element object)
+			// @param ui UI object from current library's event system. optional.
+			// @param timestamp timestamp for this paint cycle. used to speed things up a little by cutting down the amount of offset calculations we do.
+			// @param clearEdits defaults to false; indicates that mouse edits for connectors should be cleared
+			///
+			_draw = function(element, ui, timestamp, clearEdits) {
+
+				// TODO is it correct to filter by headless at this top level? how would a headless adapter ever repaint?
+				if (!jsPlumbAdapter.headless && !_suspendDrawing) {
+					var id = _getId(element),
+						repaintEls = _currentInstance.dragManager.getElementsForDraggable(id);			    
+
+					if (timestamp == null) timestamp = _timestamp();
+
+					// update the offset of everything _before_ we try to draw anything.
+					var o = _updateOffset( { elId : id, offset : ui, recalc : false, timestamp : timestamp });
+
+					if (repaintEls) {
+						for (var i in repaintEls) {
+							// TODO this seems to cause a lag, but we provide the offset, so in theory it 
+							// should not.  is the timestamp failing?
+							_updateOffset( { 
+								elId : repaintEls[i].id, 
+								offset : {
+									left:o.o.left + repaintEls[i].offset.left,
+									top:o.o.top + repaintEls[i].offset.top
+								}, 
+								recalc : false, 
+								timestamp : timestamp 
+							});
+						}
+					}	
+
+					_currentInstance.anchorManager.redraw(id, ui, timestamp, null, clearEdits);
+					
+					if (repaintEls) {
+						for (var j in repaintEls) {
+							_currentInstance.anchorManager.redraw(repaintEls[j].id, ui, timestamp, repaintEls[j].offset, clearEdits, true);			    	
+						}
+					}		
+				}
+			},
+
+			//
+			// executes the given function against the given element if the first
+			// argument is an object, or the list of elements, if the first argument
+			// is a list. the function passed in takes (element, elementId) as
+			// arguments.
+			//
+			_elementProxy = function(element, fn) {
+				var retVal = null, el, id, del;
+				if (_ju.isArray(element)) {
+					retVal = [];
+					for ( var i = 0, j = element.length; i < j; i++) {
+						el = _currentInstance.getElementObject(element[i]);
+						del = _currentInstance.getDOMElement(el);
+						id = _currentInstance.getAttribute(del, "id");
+						retVal.push(fn.apply(_currentInstance, [del, id])); // append return values to what we will return
+					}
+				} else {
+					el = _currentInstance.getDOMElement(element);
+					id = _currentInstance.getId(el);
+					retVal = fn.apply(_currentInstance, [el, id]);
+				}
+				return retVal;
+			},				
+
+			//
+			// gets an Endpoint by uuid.
+			//
+			_getEndpoint = function(uuid) { return endpointsByUUID[uuid]; },
+
+		/**
+		 * inits a draggable if it's not already initialised.
+		 * TODO: somehow abstract this to the adapter, because the concept of "draggable" has no
+		 * place on the server.
+		 */
+		_initDraggableIfNecessary = function(element, isDraggable, dragOptions, id) {
+			// TODO move to DragManager?
+			if (!jsPlumbAdapter.headless) {
+				var _draggable = isDraggable == null ? false : isDraggable;
+				if (_draggable) {
+					if (jsPlumb.isDragSupported(element, _currentInstance) && !jsPlumb.isAlreadyDraggable(element, _currentInstance)) {
+						var options = dragOptions || _currentInstance.Defaults.DragOptions;
+						options = jsPlumb.extend( {}, options); // make a copy.
+						var dragEvent = jsPlumb.dragEvents.drag,
+							stopEvent = jsPlumb.dragEvents.stop,
+							startEvent = jsPlumb.dragEvents.start,
+							_del = _currentInstance.getDOMElement(element),
+							_ancestor = _currentInstance.dragManager.getDragAncestor(_del),
+							_noOffset = {left:0, top:0},
+							_ancestorOffset = _noOffset,
+							_started = false;
+
+                        _manage(id, element);
+
+						options[startEvent] = _ju.wrap(options[startEvent], function() {
+							_ancestorOffset = _ancestor != null ? jsPlumbAdapter.getOffset(_ancestor, _currentInstance) : _noOffset;								
+							_currentInstance.setHoverSuspended(true);							
+							_currentInstance.select({source:element}).addClass(_currentInstance.elementDraggingClass + " " + _currentInstance.sourceElementDraggingClass, true);
+							_currentInstance.select({target:element}).addClass(_currentInstance.elementDraggingClass + " " + _currentInstance.targetElementDraggingClass, true);
+							_currentInstance.setConnectionBeingDragged(true);
+							if (options.canDrag) return dragOptions.canDrag();
+						}, false);
+	
+						options[dragEvent] = _ju.wrap(options[dragEvent], function() {
+							// TODO: here we could actually use getDragObject, and then compute it ourselves,
+							// since every adapter does the same thing. but i'm not sure why YUI's getDragObject
+							// differs from getUIPosition so much						
+							var ui = _currentInstance.getUIPosition(arguments, _currentInstance.getZoom());
+							// adjust by ancestor offset if there is one: this is for the case that a draggable
+							// is contained inside some other element that is not the Container.
+							ui.left += _ancestorOffset.left;
+							ui.top += _ancestorOffset.top;	
+							_draw(element, ui, null, true);
+							if (_started) _currentInstance.addClass(element, "jsPlumb_dragged");							
+							_started = true;
+						});
+						options[stopEvent] = _ju.wrap(options[stopEvent], function() {
+							var ui = _currentInstance.getUIPosition(arguments, _currentInstance.getZoom(), true);
+							_draw(element, ui);
+							_started = false;
+							_currentInstance.removeClass(element, "jsPlumb_dragged");
+							_currentInstance.setHoverSuspended(false);							
+							_currentInstance.select({source:element}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.sourceElementDraggingClass, true);
+							_currentInstance.select({target:element}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.targetElementDraggingClass, true);
+							_currentInstance.setConnectionBeingDragged(false);
+							_currentInstance.dragManager.dragEnded(element);
+						});
+						var elId = _getId(element); // need ID
+						draggableStates[elId] = true;  
+						var draggable = draggableStates[elId];
+						options.disabled = draggable == null ? false : !draggable;
+						_currentInstance.initDraggable(element, options);
+						_currentInstance.dragManager.register(element);
+					}
+				}
+			}
+		},
+
+        _scopeMatch = function(e1, e2) {
+            var s1 = e1.scope.split(/\s/), s2 = e2.scope.split(/\s/);
+            for (var i = 0; i < s1.length; i++)
+                for (var j = 0; j < s2.length; j++)
+                    if (s2[j] == s1[i]) return true;
+
+            return false;
+        },
+		
+		/*
+		* prepares a final params object that can be passed to _newConnection, taking into account defaults, events, etc.
+		*/
+		_prepareConnectionParams = function(params, referenceParams) {
+			var _p = jsPlumb.extend( { }, params);
+			if (referenceParams) jsPlumb.extend(_p, referenceParams);
+			
+			// hotwire endpoints passed as source or target to sourceEndpoint/targetEndpoint, respectively.
+			if (_p.source) {
+				if (_p.source.endpoint) 
+					_p.sourceEndpoint = _p.source;
+				else
+					_p.source = _currentInstance.getDOMElement(_p.source);
+			}
+			if (_p.target) {
+				if (_p.target.endpoint) 
+					_p.targetEndpoint = _p.target;
+				else
+					_p.target = _currentInstance.getDOMElement(_p.target);
+			}
+			
+			// test for endpoint uuids to connect
+			if (params.uuids) {
+				_p.sourceEndpoint = _getEndpoint(params.uuids[0]);
+				_p.targetEndpoint = _getEndpoint(params.uuids[1]);
+			}						
+
+			// now ensure that if we do have Endpoints already, they're not full.
+			// source:
+			if (_p.sourceEndpoint && _p.sourceEndpoint.isFull()) {
+				_ju.log(_currentInstance, "could not add connection; source endpoint is full");
+				return;
+			}
+
+			// target:
+			if (_p.targetEndpoint && _p.targetEndpoint.isFull()) {
+				_ju.log(_currentInstance, "could not add connection; target endpoint is full");
+				return;
+			}
+			
+			// if source endpoint mandates connection type and nothing specified in our params, use it.
+			if (!_p.type && _p.sourceEndpoint)
+				_p.type = _p.sourceEndpoint.connectionType;
+			
+			// copy in any connectorOverlays that were specified on the source endpoint.
+			// it doesnt copy target endpoint overlays.  i'm not sure if we want it to or not.
+			if (_p.sourceEndpoint && _p.sourceEndpoint.connectorOverlays) {
+				_p.overlays = _p.overlays || [];
+				for (var i = 0, j = _p.sourceEndpoint.connectorOverlays.length; i < j; i++) {
+					_p.overlays.push(_p.sourceEndpoint.connectorOverlays[i]);
+				}
+			}		
+            
+            // pointer events
+            if (!_p["pointer-events"] && _p.sourceEndpoint && _p.sourceEndpoint.connectorPointerEvents)
+                _p["pointer-events"] = _p.sourceEndpoint.connectorPointerEvents;
+
+            var _mergeOverrides = function(def, values) {
+            	var m = jsPlumb.extend({}, def);
+            	for (var i in values) {
+            		if (values[i]) m[i] = values[i];
+            	}
+            	return m;
+            };
+
+            var _addEndpoint = function(el, def, idx) {
+            	return _currentInstance.addEndpoint(el, _mergeOverrides(def, {
+            		anchor:_p.anchors ? _p.anchors[idx] : _p.anchor,
+            		endpoint:_p.endpoints ? _p.endpoints[idx] : _p.endpoint,
+            		paintStyle:_p.endpointStyles ? _p.endpointStyles[idx] : _p.endpointStyle,
+            		hoverPaintStyle:_p.endpointHoverStyles ? _p.endpointHoverStyles[idx] : _p.endpointHoverStyle
+            	}));
+            };
+									
+			// check for makeSource/makeTarget specs.
+
+            var _oneElementDef = function(type, idx, defs) {
+                if (_p[type] && !_p[type].endpoint && !_p[type + "Endpoint"] && !_p.newConnection) {
+                    var tid = _getId(_p[type]), tep = defs[tid];
+
+                    if (tep) {
+                        // if not enabled, return.
+                        if (!tep.enabled) return false;
+
+                        var newEndpoint = tep.endpoint != null && tep.endpoint._jsPlumb ? tep.endpoint : _addEndpoint(_p[type], tep.def, idx);
+                        if (tep.uniqueEndpoint) tep.endpoint = newEndpoint;
+                        if (newEndpoint.isFull()) return false;
+                        _p[type + "Endpoint"] = newEndpoint;
+                        newEndpoint._doNotDeleteOnDetach = false; // reset.
+                        newEndpoint._deleteOnDetach = true;
+                    }
+                }
+            };
+
+            if (_oneElementDef("source", 0, this.sourceEndpointDefinitions) === false) return;
+            if (_oneElementDef("target", 1, this.targetEndpointDefinitions) === false) return;
+
+            // last, ensure scopes match
+            if (_p.sourceEndpoint && _p.targetEndpoint)
+                if (!_scopeMatch(_p.sourceEndpoint, _p.targetEndpoint)) _p = null;
+			
+			return _p;
+		}.bind(_currentInstance),
+		
+		_newConnection = function(params) {
+			var connectionFunc = _currentInstance.Defaults.ConnectionType || _currentInstance.getDefaultConnectionType();
+			
+			params._jsPlumb = _currentInstance;
+            params.newConnection = _newConnection;
+            params.newEndpoint = _newEndpoint;
+            params.endpointsByUUID = endpointsByUUID;             
+            params.endpointsByElement = endpointsByElement;  
+            params.finaliseConnection = _finaliseConnection;
+			var con = new connectionFunc(params);
+			con.id = "con_" + _idstamp();
+
+            // if the connection is draggable, then maybe we need to tell the target endpoint to init the
+            // dragging code. it won't run again if it already configured to be draggable.
+            if (con.isDetachable()) {
+            	con.endpoints[0].initDraggable();
+            	con.endpoints[1].initDraggable();
+            }
+
+			return con;
+		},
+		
+		//
+		// adds the connection to the backing model, fires an event if necessary and then redraws
+		//
+		_finaliseConnection = _currentInstance.finaliseConnection = function(jpc, params, originalEvent, doInformAnchorManager) {
+            params = params || {};
+			// add to list of connections (by scope).
+            if (!jpc.suspendedEndpoint)
+			    connections.push(jpc);
+
+			// turn off isTemporarySource on the source endpoint (only viable on first draw)
+			jpc.endpoints[0].isTemporarySource = false;
+			
+            // always inform the anchor manager
+            // except that if jpc has a suspended endpoint it's not true to say the
+            // connection is new; it has just (possibly) moved. the question is whether
+            // to make that call here or in the anchor manager.  i think perhaps here.
+            if (jpc.suspendedEndpoint == null || doInformAnchorManager)
+            	_currentInstance.anchorManager.newConnection(jpc);
+
+			// force a paint
+			_draw(jpc.source);
+			
+			// fire an event
+			if (!params.doNotFireConnectionEvent && params.fireEvent !== false) {
+			
+				var eventArgs = {
+					connection:jpc,
+					source : jpc.source, target : jpc.target,
+					sourceId : jpc.sourceId, targetId : jpc.targetId,
+					sourceEndpoint : jpc.endpoints[0], targetEndpoint : jpc.endpoints[1]
+				};
+			
+				_currentInstance.fire("connection", eventArgs, originalEvent);
+			}
+		},
+
+		/*
+			factory method to prepare a new endpoint.  this should always be used instead of creating Endpoints
+			manually, since this method attaches event listeners and an id.
+		*/
+		_newEndpoint = function(params, id) {
+            var endpointFunc = _currentInstance.Defaults.EndpointType || jsPlumb.Endpoint;
+            var _p = jsPlumb.extend({}, params);
+            _p._jsPlumb = _currentInstance;
+            _p.newConnection = _newConnection;
+            _p.newEndpoint = _newEndpoint;
+            _p.endpointsByUUID = endpointsByUUID;
+            _p.endpointsByElement = endpointsByElement;
+            _p.fireDetachEvent = fireDetachEvent;
+            _p.elementId = id || _getId(_p.source);
+            var ep = new endpointFunc(_p);
+            ep.id = "ep_" + _idstamp();
+            _manage(_p.elementId, _p.source);
+            if (!jsPlumbAdapter.headless)
+                _currentInstance.dragManager.endpointAdded(_p.source, id);
+
+			return ep;
+		},
+		
+		/*
+		 * performs the given function operation on all the connections found
+		 * for the given element id; this means we find all the endpoints for
+		 * the given element, and then for each endpoint find the connectors
+		 * connected to it. then we pass each connection in to the given
+		 * function.		 
+		 */
+		_operation = function(elId, func, endpointFunc) {
+			var endpoints = endpointsByElement[elId];
+			if (endpoints && endpoints.length) {
+				for ( var i = 0, ii = endpoints.length; i < ii; i++) {
+					for ( var j = 0, jj = endpoints[i].connections.length; j < jj; j++) {
+						var retVal = func(endpoints[i].connections[j]);
+						// if the function passed in returns true, we exit.
+						// most functions return false.
+						if (retVal) return;
+					}
+					if (endpointFunc) endpointFunc(endpoints[i]);
+				}
+			}
+		},	
+		
+		_setDraggable = function(element, draggable) {
+			return _elementProxy(element, function(el, id) {
+				draggableStates[id] = draggable;
+				if (this.isDragSupported(el)) {
+					this.setElementDraggable(el, draggable);
+				}
+			});
+		},
+		/*
+		 * private method to do the business of hiding/showing.
+		 * 
+		 * @param el
+		 *            either Id of the element in question or a library specific
+		 *            object for the element.
+		 * @param state
+		 *            String specifying a value for the css 'display' property
+		 *            ('block' or 'none').
+		 */
+		_setVisible = function(el, state, alsoChangeEndpoints) {
+			state = state === "block";
+			var endpointFunc = null;
+			if (alsoChangeEndpoints) {
+				if (state) endpointFunc = function(ep) {
+					ep.setVisible(true, true, true);
+				};
+				else endpointFunc = function(ep) {
+					ep.setVisible(false, true, true);
+				};
+			}
+			var info = _info(el);
+			_operation(info.id, function(jpc) {
+				if (state && alsoChangeEndpoints) {		
+					// this test is necessary because this functionality is new, and i wanted to maintain backwards compatibility.
+					// this block will only set a connection to be visible if the other endpoint in the connection is also visible.
+					var oidx = jpc.sourceId === info.id ? 1 : 0;
+					if (jpc.endpoints[oidx].isVisible()) jpc.setVisible(true);
+				}
+				else  // the default behaviour for show, and what always happens for hide, is to just set the visibility without getting clever.
+					jpc.setVisible(state);
+			}, endpointFunc);
+		},
+		/*
+		 * toggles the draggable state of the given element(s).
+		 * el is either an id, or an element object, or a list of ids/element objects.
+		 */
+		_toggleDraggable = function(el) {
+			return _elementProxy(el, function(el, elId) {
+				var state = draggableStates[elId] == null ? false : draggableStates[elId];
+				state = !state;
+				draggableStates[elId] = state;
+				this.setDraggable(el, state);
+				return state;
+            }.bind(this));
+		},
+		/**
+		 * private method to do the business of toggling hiding/showing.
+		 */
+		_toggleVisible = function(elId, changeEndpoints) {
+			var endpointFunc = null;
+			if (changeEndpoints) {
+				endpointFunc = function(ep) {
+					var state = ep.isVisible();
+					ep.setVisible(!state);
+				};
+			}
+			_operation(elId, function(jpc) {
+				var state = jpc.isVisible();
+				jpc.setVisible(!state);				
+			}, endpointFunc);
+			// todo this should call _elementProxy, and pass in the
+			// _operation(elId, f) call as a function. cos _toggleDraggable does
+			// that.
+		},
+
+		// TODO comparison performance
+		_getCachedData = function(elId) {
+			var o = offsets[elId];
+			if (!o) 
+                return _updateOffset({elId:elId});
+			else
+                return {o:o, s:sizes[elId]};
+		},
+
+		/**
+		 * gets an id for the given element, creating and setting one if
+		 * necessary.  the id is of the form
+		 *
+		 *	jsPlumb_<instance index>_<index in instance>
+		 *
+		 * where "index in instance" is a monotonically increasing integer that starts at 0,
+		 * for each instance.  this method is used not only to assign ids to elements that do not
+		 * have them but also to connections and endpoints.
+		 */
+		_getId = function(element, uuid, doNotCreateIfNotFound) {
+			if (jsPlumbUtil.isString(element)) return element;			
+			if (element == null) return null;			
+			var id = _currentInstance.getAttribute(element, "id");
+			if (!id || id === "undefined") {
+				// check if fixed uuid parameter is given
+				if (arguments.length == 2 && arguments[1] !== undefined)
+					id = uuid;
+				else if (arguments.length == 1 || (arguments.length == 3 && !arguments[2]))
+					id = "jsPlumb_" + _instanceIndex + "_" + _idstamp();
+				
+                if (!doNotCreateIfNotFound) _currentInstance.setAttribute(element, "id", id);
+			}
+			return id;
+		};
+
+		this.setConnectionBeingDragged = function(v) {
+			connectionBeingDragged = v;
+		};
+		this.isConnectionBeingDragged = function() {
+			return connectionBeingDragged;
+		};
+    
+		this.connectorClass = "_jsPlumb_connector";            		
+		this.hoverClass = "_jsPlumb_hover";            		
+		this.endpointClass = "_jsPlumb_endpoint";		
+		this.endpointConnectedClass = "_jsPlumb_endpoint_connected";		
+		this.endpointFullClass = "_jsPlumb_endpoint_full";		
+		this.endpointDropAllowedClass = "_jsPlumb_endpoint_drop_allowed";		
+		this.endpointDropForbiddenClass = "_jsPlumb_endpoint_drop_forbidden";		
+		this.overlayClass = "_jsPlumb_overlay";				
+		this.draggingClass = "_jsPlumb_dragging";		
+		this.elementDraggingClass = "_jsPlumb_element_dragging";			
+		this.sourceElementDraggingClass = "_jsPlumb_source_element_dragging";
+		this.targetElementDraggingClass = "_jsPlumb_target_element_dragging";
+		this.endpointAnchorClassPrefix = "_jsPlumb_endpoint_anchor";
+		this.hoverSourceClass = "_jsPlumb_source_hover";	
+		this.hoverTargetClass = "_jsPlumb_target_hover";
+		this.dragSelectClass = "_jsPlumb_drag_select";
+
+		this.Anchors = {};		
+		this.Connectors = {  "svg":{}, "vml":{} };				
+		this.Endpoints = { "svg":{}, "vml":{} };
+		this.Overlays = { "svg":{}, "vml":{}};		
+		this.ConnectorRenderers = {};				
+		this.SVG = "svg";
+		this.VML = "vml";				
+
+// --------------------------- jsPlumbInstance public API ---------------------------------------------------------
+
+
+        this.addEndpoint = function(el, params, referenceParams) {
+            referenceParams = referenceParams || {};
+            var p = jsPlumb.extend({}, referenceParams);
+            jsPlumb.extend(p, params);
+            p.endpoint = p.endpoint || _currentInstance.Defaults.Endpoint;
+            p.paintStyle = p.paintStyle || _currentInstance.Defaults.EndpointStyle;
+
+            var results = [],
+                inputs = (_ju.isArray(el) || (el.length != null && !_ju.isString(el))) ? el : [ el ];
+
+            for (var i = 0, j = inputs.length; i < j; i++) {
+                p.source = _currentInstance.getDOMElement(inputs[i]);
+                _ensureContainer(p.source);
+
+                var id = _getId(p.source), e = _newEndpoint(p, id);
+
+                // SP new. here we have introduced a class-wide element manager, which is responsible
+                // for getting object dimensions and width/height, and for updating these values only
+                // when necessary (after a drag, or on a forced refresh call).
+                var myOffset = _manage(id, p.source).info.o;
+                _ju.addToList(endpointsByElement, id, e);
+
+                if (!_suspendDrawing) {
+                    e.paint({
+                        anchorLoc: e.anchor.compute({ xy: [ myOffset.left, myOffset.top ], wh: sizes[id], element: e, timestamp: _suspendedAt }),
+                        timestamp: _suspendedAt
+                    });
+                }
+
+                results.push(e);
+                e._doNotDeleteOnDetach = true; // mark this as being added via addEndpoint.
+            }
+
+            return results.length == 1 ? results[0] : results;
+        };
+
+		this.addEndpoints = function(el, endpoints, referenceParams) {
+			var results = [];
+			for ( var i = 0, j = endpoints.length; i < j; i++) {
+				var e = _currentInstance.addEndpoint(el, endpoints[i], referenceParams);
+				if (_ju.isArray(e))
+					Array.prototype.push.apply(results, e);
+				else results.push(e);
+			}
+			return results;
+		};
+		
+		this.animate = function(el, properties, options) {
+			options = options || {};
+			var ele = _currentInstance.getElementObject(el),
+				del = _currentInstance.getDOMElement(el),
+				id = _getId(del),
+				stepFunction = jsPlumb.animEvents.step,
+				completeFunction = jsPlumb.animEvents.complete;
+
+			options[stepFunction] = _ju.wrap(options[stepFunction], function() {
+				_currentInstance.revalidate(id);
+			});
+
+			// onComplete repaints, just to make sure everything looks good at the end of the animation.
+			options[completeFunction] = _ju.wrap(options[completeFunction], function() {
+				_currentInstance.revalidate(id);
+			});
+
+			_currentInstance.doAnimate(ele, properties, options);
+		};
+		
+		/**
+		* checks for a listener for the given condition, executing it if found, passing in the given value.
+		* condition listeners would have been attached using "bind" (which is, you could argue, now overloaded, since
+		* firing click events etc is a bit different to what this does).  i thought about adding a "bindCondition"
+		* or something, but decided against it, for the sake of simplicity. jsPlumb will never fire one of these
+		* condition events anyway.
+		*/
+		this.checkCondition = function(conditionName, value) {
+			var l = _currentInstance.getListener(conditionName),
+				r = true;
+				
+			if (l && l.length > 0) {
+				try {
+					for (var i = 0, j = l.length; i < j; i++) {
+						r = r && l[i](value); 
+					}
+				}
+				catch (e) { 
+					_ju.log(_currentInstance, "cannot check condition [" + conditionName + "]" + e); 
+				}
+			}
+			return r;
+		};
+		
+		this.connect = function(params, referenceParams) {
+			// prepare a final set of parameters to create connection with
+			var _p = _prepareConnectionParams(params, referenceParams), jpc;
+			// TODO probably a nicer return value if the connection was not made.  _prepareConnectionParams
+			// will return null (and log something) if either endpoint was full.  what would be nicer is to 
+			// create a dedicated 'error' object.
+			if (_p) {
+                if (_p.source == null && _p.sourceEndpoint == null) {
+                    jsPlumbUtil.log("Cannot establish connection - source does not exist");
+                    return;
+                }
+                if (_p.target == null && _p.targetEndpoint == null) {
+                    jsPlumbUtil.log("Cannot establish connection - target does not exist");
+                    return;
+                }
+				_ensureContainer(_p.source);
+				// create the connection.  it is not yet registered 
+				jpc = _newConnection(_p);
+				// now add it the model, fire an event, and redraw
+				_finaliseConnection(jpc, _p);										
+			}
+			return jpc;
+		};		
+		
+		var stTypes = [
+			{ el:"source", elId:"sourceId", epDefs:"sourceEndpointDefinitions" },
+			{ el:"target", elId:"targetId", epDefs:"targetEndpointDefinitions" }
+		];
+		
+		var _set = function(c, el, idx, doNotRepaint) {
+			var ep, _st = stTypes[idx], cId = c[_st.elId], cEl = c[_st.el], sid, sep,
+				oldEndpoint = c.endpoints[idx];
+			
+			var evtParams = {
+				index:idx,
+				originalSourceId:idx === 0 ? cId : c.sourceId,
+				newSourceId:c.sourceId,
+				originalTargetId:idx == 1 ? cId : c.targetId,
+				newTargetId:c.targetId,
+				connection:c
+			};
+
+			if (el.constructor == jsPlumb.Endpoint) { // TODO here match the current endpoint class; users can change it {
+				ep = el;
+				ep.addConnection(c);
+			}
+			else {
+				sid = _getId(el);
+				sep = this[_st.epDefs][sid];
+
+				if (sid === c[_st.elId]) 
+					ep = null;  // dont change source/target if the element is already the one given.
+				else if (sep) {
+					if (!sep.enabled) return;
+					ep = sep.endpoint != null && sep.endpoint._jsPlumb ? sep.endpoint : this.addEndpoint(el, sep.def);
+					if (sep.uniqueEndpoint) sep.endpoint = ep;
+					ep._doNotDeleteOnDetach = false;
+					ep._deleteOnDetach = true;
+					ep.addConnection(c);
+				}
+				else {
+					ep = c.makeEndpoint(idx === 0, el, sid);
+					ep._doNotDeleteOnDetach = false;
+					ep._deleteOnDetach = true;
+				}
+			}
+			
+			if (ep != null) {
+				oldEndpoint.detachFromConnection(c);
+				c.endpoints[idx] = ep;
+				c[_st.el] = ep.element;
+				c[_st.elId] = ep.elementId;			
+				evtParams[idx === 0 ? "newSourceId" : "newTargetId"] = ep.elementId;
+
+				fireMoveEvent(evtParams);
+				
+				if (!doNotRepaint)
+					c.repaint();
+			}
+
+			return evtParams;
+			
+		}.bind(this);
+
+		this.setSource = function(connection, el, doNotRepaint) { 
+			var p = _set(connection, el, 0, doNotRepaint); 
+			this.anchorManager.sourceChanged(p.originalSourceId, p.newSourceId, connection);
+		};
+		this.setTarget = function(connection, el, doNotRepaint) { 
+			var p = _set(connection, el, 1, doNotRepaint); 
+			this.anchorManager.updateOtherEndpoint(p.originalSourceId, p.originalTargetId, p.newTargetId, connection);
+		};
+		
+		this.deleteEndpoint = function(object, dontUpdateHover) {
+			var endpoint = (typeof object === "string") ? endpointsByUUID[object] : object;
+			if (endpoint) {		
+				_currentInstance.deleteObject({ endpoint:endpoint, dontUpdateHover:dontUpdateHover });
+			}
+			return _currentInstance;
+		};		
+		
+		this.deleteEveryEndpoint = function() {
+			var _is = _currentInstance.setSuspendDrawing(true);
+			for ( var id in endpointsByElement) {
+				var endpoints = endpointsByElement[id];
+				if (endpoints && endpoints.length) {
+					for ( var i = 0, j = endpoints.length; i < j; i++) {
+                        _currentInstance.deleteEndpoint(endpoints[i], true);
+					}
+				}
+			}			
+			endpointsByElement = {};
+            // SP new
+            managedElements = {};
+			endpointsByUUID = {};
+			_currentInstance.anchorManager.reset();
+			_currentInstance.dragManager.reset();							
+			if(!_is) _currentInstance.setSuspendDrawing(false);
+			return _currentInstance;
+		};
+
+		var fireDetachEvent = function(jpc, doFireEvent, originalEvent) {
+            // may have been given a connection, or in special cases, an object
+            var connType =  _currentInstance.Defaults.ConnectionType || _currentInstance.getDefaultConnectionType(),
+                argIsConnection = jpc.constructor == connType,
+                params = argIsConnection ? {
+                    connection:jpc,
+				    source : jpc.source, target : jpc.target,
+				    sourceId : jpc.sourceId, targetId : jpc.targetId,
+				    sourceEndpoint : jpc.endpoints[0], targetEndpoint : jpc.endpoints[1]
+                } : jpc;
+
+			if (doFireEvent)
+				_currentInstance.fire("connectionDetached", params, originalEvent);
+			
+            _currentInstance.anchorManager.connectionDetached(params);
+		};	
+
+		var fireMoveEvent = _currentInstance.fireMoveEvent = function(params, evt) {
+			_currentInstance.fire("connectionMoved", params, evt);
+		};
+
+		this.unregisterEndpoint = function(endpoint) {
+			//if (endpoint._jsPlumb == null) return;
+			if (endpoint._jsPlumb.uuid) endpointsByUUID[endpoint._jsPlumb.uuid] = null;				
+			_currentInstance.anchorManager.deleteEndpoint(endpoint);			
+			// TODO at least replace this with a removeWithFunction call.			
+			for (var e in endpointsByElement) {
+				var endpoints = endpointsByElement[e];
+				if (endpoints) {
+					var newEndpoints = [];
+					for (var i = 0, j = endpoints.length; i < j; i++)
+						if (endpoints[i] != endpoint) newEndpoints.push(endpoints[i]);
+					
+					endpointsByElement[e] = newEndpoints;
+				}
+				if(endpointsByElement[e].length <1){
+					delete endpointsByElement[e];
+				}
+			}
+		};
+				
+		this.detach = function() {
+
+            if (arguments.length === 0) return;
+            var connType =  _currentInstance.Defaults.ConnectionType || _currentInstance.getDefaultConnectionType(),
+                firstArgIsConnection = arguments[0].constructor == connType,
+                params = arguments.length == 2 ? firstArgIsConnection ? (arguments[1] || {}) : arguments[0] : arguments[0],
+                fireEvent = (params.fireEvent !== false),
+                forceDetach = params.forceDetach,
+                conn = firstArgIsConnection ? arguments[0] : params.connection;
+                                                    
+				if (conn) {             
+                    if (forceDetach || jsPlumbUtil.functionChain(true, false, [
+                            [ conn.endpoints[0], "isDetachAllowed", [ conn ] ],    
+                            [ conn.endpoints[1], "isDetachAllowed", [ conn ] ],
+                            [ conn, "isDetachAllowed", [ conn ] ],
+                            [ _currentInstance, "checkCondition", [ "beforeDetach", conn ] ] ])) {
+                        
+                        conn.endpoints[0].detach(conn, false, true, fireEvent); 
+                    }
+                }
+                else {
+					var _p = jsPlumb.extend( {}, params); // a backwards compatibility hack: source should be thought of as 'params' in this case.
+					// test for endpoint uuids to detach
+					if (_p.uuids) {
+						_getEndpoint(_p.uuids[0]).detachFrom(_getEndpoint(_p.uuids[1]), fireEvent);
+					} else if (_p.sourceEndpoint && _p.targetEndpoint) {
+						_p.sourceEndpoint.detachFrom(_p.targetEndpoint);
+					} else {
+						var sourceId = _getId(_currentInstance.getDOMElement(_p.source)),
+						    targetId = _getId(_currentInstance.getDOMElement(_p.target));
+						_operation(sourceId, function(jpc) {
+						    if ((jpc.sourceId == sourceId && jpc.targetId == targetId) || (jpc.targetId == sourceId && jpc.sourceId == targetId)) {
+							    if (_currentInstance.checkCondition("beforeDetach", jpc)) {
+                                    jpc.endpoints[0].detach(jpc, false, true, fireEvent);
+								}
+							}
+						});
+					}
+				}
+		};
+
+		this.detachAllConnections = function(el, params) {
+            params = params || {};
+            el = _currentInstance.getDOMElement(el);
+			var id = _getId(el),
+                endpoints = endpointsByElement[id];
+			if (endpoints && endpoints.length) {
+				for ( var i = 0, j = endpoints.length; i < j; i++) {
+					endpoints[i].detachAll(params.fireEvent !== false);
+				}
+			}
+			return _currentInstance;
+		};
+
+		this.detachEveryConnection = function(params) {
+            params = params || {};
+            _currentInstance.doWhileSuspended(function() {
+				for ( var id in endpointsByElement) {
+					var endpoints = endpointsByElement[id];
+					if (endpoints && endpoints.length) {
+						for ( var i = 0, j = endpoints.length; i < j; i++) {
+							endpoints[i].detachAll(params.fireEvent !== false);
+						}
+					}
+				}
+				connections.length = 0;
+			});
+			return _currentInstance;
+		};
+
+		/// not public.  but of course its exposed. how to change this.
+		this.deleteObject = function(params) {
+			var result = {
+					endpoints : {}, 
+					connections : {},
+					endpointCount:0,
+					connectionCount:0
+				},
+				fireEvent = params.fireEvent !== false,
+				deleteAttachedObjects = params.deleteAttachedObjects !== false;
+
+			var unravelConnection = function(connection) {
+				if(connection != null && result.connections[connection.id] == null) {
+					if (!params.dontUpdateHover && connection._jsPlumb != null) connection.setHover(false);
+					result.connections[connection.id] = connection;
+					result.connectionCount++;
+					if (deleteAttachedObjects) {
+						for (var j = 0; j < connection.endpoints.length; j++) {
+							if (connection.endpoints[j]._deleteOnDetach)
+								unravelEndpoint(connection.endpoints[j]);
+						}
+					}					
+				}
+			};
+			var unravelEndpoint = function(endpoint) {
+				if(endpoint != null && result.endpoints[endpoint.id] == null) {
+					if (!params.dontUpdateHover && endpoint._jsPlumb != null) endpoint.setHover(false);
+					result.endpoints[endpoint.id] = endpoint;
+					result.endpointCount++;
+
+					if (deleteAttachedObjects) {
+						for (var i = 0; i < endpoint.connections.length; i++) {
+							var c = endpoint.connections[i];
+							unravelConnection(c);
+						}
+					}
+				}
+			};
+
+			if (params.connection) 
+				unravelConnection(params.connection);
+			else unravelEndpoint(params.endpoint);
+
+			// loop through connections
+			for (var i in result.connections) {
+				var c = result.connections[i];
+				if (c._jsPlumb) {
+					jsPlumbUtil.removeWithFunction(connections, function(_c) {
+						return c.id == _c.id;
+					});
+					fireDetachEvent(c, fireEvent, params.originalEvent);
+					
+					c.endpoints[0].detachFromConnection(c);
+					c.endpoints[1].detachFromConnection(c);
+					// sp was ere
+					c.cleanup();
+					c.destroy();
+				}
+			}
+
+			// loop through endpoints
+			for (var j in result.endpoints) {
+				var e = result.endpoints[j];	
+				if (e._jsPlumb) {
+					_currentInstance.unregisterEndpoint(e);
+					// FIRE some endpoint deleted event?
+					e.cleanup();
+					e.destroy();
+				}
+			}	
+
+			return result;
+		};
+ 
+		this.draggable = function(el, options) {
+			var i,j,info;
+			// allows for array or jquery selector
+			if (typeof el == 'object' && el.length) {
+				for (i = 0, j = el.length; i < j; i++) {
+					info = _info(el[i]);
+					if (info.el) _initDraggableIfNecessary(info.el, true, options, info.id);
+				}
+			}
+			else {				
+				//ele = _currentInstance.getDOMElement(el);
+                info = _info(el);
+				if (info.el) _initDraggableIfNecessary(info.el, true, options, info.id);
+			}
+			return _currentInstance;
+		};
+
+		// helpers for select/selectEndpoints
+		var _setOperation = function(list, func, args, selector) {
+				for (var i = 0, j = list.length; i < j; i++) {
+					list[i][func].apply(list[i], args);
+				}	
+				return selector(list);
+			},
+			_getOperation = function(list, func, args) {
+				var out = [];
+				for (var i = 0, j = list.length; i < j; i++) {
+					out.push([ list[i][func].apply(list[i], args), list[i] ]);
+				}	
+				return out;
+			},
+			setter = function(list, func, selector) {
+				return function() {
+					return _setOperation(list, func, arguments, selector);
+				};
+			},
+			getter = function(list, func) {
+				return function() {
+					return _getOperation(list, func, arguments);
+				};	
+			},
+			prepareList = function(input, doNotGetIds) {
+				var r = [];
+				if (input) {
+					if (typeof input == 'string') {
+						if (input === "*") return input;
+						r.push(input);
+					}
+					else {
+						if (doNotGetIds) r = input;
+						else { 
+							if (input.length) {
+								for (var i = 0, j = input.length; i < j; i++)
+									r.push(_info(input[i]).id);
+							}
+							else
+								r.push(_info(input).id);
+						}	
+					}
+				}
+				return r;
+			},
+			filterList = function(list, value, missingIsFalse) {
+				if (list === "*") return true;
+				return list.length > 0 ? jsPlumbUtil.indexOf(list, value) != -1 : !missingIsFalse;
+			};
+
+		// get some connections, specifying source/target/scope
+		this.getConnections = function(options, flat) {
+			if (!options) {
+				options = {};
+			} else if (options.constructor == String) {
+				options = { "scope": options };
+			}
+			var scope = options.scope || _currentInstance.getDefaultScope(),
+				scopes = prepareList(scope, true),
+				sources = prepareList(options.source),
+				targets = prepareList(options.target),			
+				results = (!flat && scopes.length > 1) ? {} : [],
+				_addOne = function(scope, obj) {
+					if (!flat && scopes.length > 1) {
+						var ss = results[scope];
+						if (ss == null) {
+							ss = results[scope] = [];
+						}
+						ss.push(obj);
+					} else results.push(obj);
+				};
+			
+			for ( var j = 0, jj = connections.length; j < jj; j++) {
+				var c = connections[j];
+				if (filterList(scopes, c.scope) && filterList(sources, c.sourceId) && filterList(targets, c.targetId))
+					_addOne(c.scope, c);
+			}
+			
+			return results;
+		};
+		
+		var _curryEach = function(list, executor) {
+				return function(f) {
+					for (var i = 0, ii = list.length; i < ii; i++) {
+						f(list[i]);
+					}
+					return executor(list);
+				};		
+			},
+			_curryGet = function(list) {
+				return function(idx) {
+					return list[idx];
+				};
+			};
+			
+		var _makeCommonSelectHandler = function(list, executor) {
+            var out = {
+                    length:list.length,
+				    each:_curryEach(list, executor),
+				    get:_curryGet(list)
+                },
+                setters = ["setHover", "removeAllOverlays", "setLabel", "addClass", "addOverlay", "removeOverlay", 
+                           "removeOverlays", "showOverlay", "hideOverlay", "showOverlays", "hideOverlays", "setPaintStyle",
+                           "setHoverPaintStyle", "setSuspendEvents", "setParameter", "setParameters", "setVisible", 
+                           "repaint", "addType", "toggleType", "removeType", "removeClass", "setType", "bind", "unbind" ],
+                
+                getters = ["getLabel", "getOverlay", "isHover", "getParameter", "getParameters", "getPaintStyle",
+                           "getHoverPaintStyle", "isVisible", "hasType", "getType", "isSuspendEvents" ],
+                i, ii;
+            
+            for (i = 0, ii = setters.length; i < ii; i++)
+                out[setters[i]] = setter(list, setters[i], executor);
+            
+            for (i = 0, ii = getters.length; i < ii; i++)
+                out[getters[i]] = getter(list, getters[i]);       
+            
+            return out;
+		};
+		
+		var	_makeConnectionSelectHandler = function(list) {
+			var common = _makeCommonSelectHandler(list, _makeConnectionSelectHandler);
+			return jsPlumb.extend(common, {
+				// setters
+				setDetachable:setter(list, "setDetachable", _makeConnectionSelectHandler),
+				setReattach:setter(list, "setReattach", _makeConnectionSelectHandler),
+				setConnector:setter(list, "setConnector", _makeConnectionSelectHandler),			
+				detach:function() {
+					for (var i = 0, ii = list.length; i < ii; i++)
+						_currentInstance.detach(list[i]);
+				},				
+				// getters
+				isDetachable:getter(list, "isDetachable"),
+				isReattach:getter(list, "isReattach")
+			});
+		};
+		
+		var	_makeEndpointSelectHandler = function(list) {
+			var common = _makeCommonSelectHandler(list, _makeEndpointSelectHandler);
+			return jsPlumb.extend(common, {
+				setEnabled:setter(list, "setEnabled", _makeEndpointSelectHandler),				
+				setAnchor:setter(list, "setAnchor", _makeEndpointSelectHandler),
+				isEnabled:getter(list, "isEnabled"),
+				detachAll:function() {
+					for (var i = 0, ii = list.length; i < ii; i++)
+						list[i].detachAll();
+				},
+				"remove":function() {
+					for (var i = 0, ii = list.length; i < ii; i++)
+						_currentInstance.deleteObject({endpoint:list[i]});
+				}
+			});
+		};
+			
+
+		this.select = function(params) {
+			params = params || {};
+			params.scope = params.scope || "*";
+			return _makeConnectionSelectHandler(params.connections || _currentInstance.getConnections(params, true));							
+		};		
+
+		this.selectEndpoints = function(params) {
+			params = params || {};
+			params.scope = params.scope || "*";
+			var noElementFilters = !params.element && !params.source && !params.target,			
+				elements = noElementFilters ? "*" : prepareList(params.element),
+				sources = noElementFilters ? "*" : prepareList(params.source),
+				targets = noElementFilters ? "*" : prepareList(params.target),
+				scopes = prepareList(params.scope, true);
+			
+			var ep = [];
+			
+			for (var el in endpointsByElement) {
+				var either = filterList(elements, el, true),
+					source = filterList(sources, el, true),
+					sourceMatchExact = sources != "*",
+					target = filterList(targets, el, true),
+					targetMatchExact = targets != "*"; 
+					
+				// if they requested 'either' then just match scope. otherwise if they requested 'source' (not as a wildcard) then we have to match only endpoints that have isSource set to to true, and the same thing with isTarget.  
+				if ( either || source  || target ) {
+					inner:
+					for (var i = 0, ii = endpointsByElement[el].length; i < ii; i++) {
+						var _ep = endpointsByElement[el][i];
+						if (filterList(scopes, _ep.scope, true)) {
+						
+							var noMatchSource = (sourceMatchExact && sources.length > 0 && !_ep.isSource),
+								noMatchTarget = (targetMatchExact && targets.length > 0 && !_ep.isTarget);
+						
+							if (noMatchSource || noMatchTarget)								  
+								  continue inner; 
+							 							
+							ep.push(_ep);		
+						}
+					}
+				}					
+			}
+			
+			return _makeEndpointSelectHandler(ep);
+		};
+
+		// get all connections managed by the instance of jsplumb.
+		this.getAllConnections = function() { return connections; };
+		this.getDefaultScope = function() { return DEFAULT_SCOPE; };
+		// get an endpoint by uuid.
+		this.getEndpoint = _getEndpoint;				
+		// get endpoints for some element.
+		this.getEndpoints = function(el) { return endpointsByElement[_info(el).id]; };		
+		// gets the default endpoint type. used when subclassing. see wiki.
+		this.getDefaultEndpointType = function() { return jsPlumb.Endpoint; };		
+		// gets the default connection type. used when subclassing.  see wiki.
+		this.getDefaultConnectionType = function() { return jsPlumb.Connection; };
+		/*
+		 * Gets an element's id, creating one if necessary. really only exposed
+		 * for the lib-specific functionality to access; would be better to pass
+		 * the current instance into the lib-specific code (even though this is
+		 * a static call. i just don't want to expose it to the public API).
+		 */
+		this.getId = _getId;
+		this.getOffset = function(id) { 
+			return _updateOffset({elId:id}).o;
+		};
+		
+		this.appendElement = _appendElement;
+		
+		var _hoverSuspended = false;
+		this.isHoverSuspended = function() { return _hoverSuspended; };
+		this.setHoverSuspended = function(s) { _hoverSuspended = s; };
+
+		var _isAvailable = function(m) {
+			return function() {
+				return jsPlumbAdapter.isRenderModeAvailable(m);
+			};
+		};
+
+		this.isSVGAvailable = _isAvailable("svg");
+		this.isVMLAvailable = _isAvailable("vml");
+
+		// set an element's connections to be hidden
+		this.hide = function(el, changeEndpoints) {
+			_setVisible(el, "none", changeEndpoints);
+			return _currentInstance;
+		};
+		
+		// exposed for other objects to use to get a unique id.
+		this.idstamp = _idstamp;
+
+		this.connectorsInitialized = false;
+		var connectorTypes = [], rendererTypes = ["svg", "vml"];
+		this.registerConnectorType = function(connector, name) {
+			connectorTypes.push([connector, name]);
+		};
+		
+		// ensure that, if the current container exists, it is a DOM element and not a selector.
+		// if it does not exist and `candidate` is supplied, the offset parent of that element will be set as the Container.
+		// this is used to do a better default behaviour for the case that the user has not set a container:
+		// addEndpoint, makeSource, makeTarget and connect all call this method with the offsetParent of the 
+		// element in question (for connect it is the source element). So if no container is set, it is inferred
+		// to be the offsetParent of the first element the user tries to connect.
+		var _ensureContainer = function(candidate) {
+			if (!_container && candidate) {
+				var can = _currentInstance.getDOMElement(candidate);				
+                		if (can.offsetParent) _currentInstance.setContainer(can.offsetParent);
+			}
+		};
+
+		var _getContainerFromDefaults = function() {
+			if (_currentInstance.Defaults.Container)
+                	  _currentInstance.setContainer(_currentInstance.Defaults.Container);
+		};
+
+        // check if a given element is managed or not. if not, add to our map. if drawing is not suspended then
+        // we'll also stash its dimensions; otherwise we'll do this in a lazy way through updateOffset.
+            // TODO make sure we add a test that this tracks a setId call.
+        var _manage = _currentInstance.manage = function(id, element) {
+            if (!managedElements[id]) {
+                managedElements[id] = {
+                    el:element,
+                    endpoints:[],
+                    connections:[]
+                };
+
+                managedElements[id].info = _updateOffset({ elId: id, timestamp: _suspendedAt });
+
+             /*   if (!_suspendDrawing) {
+                    managedElements[id].info = _updateOffset({ elId: id, timestamp: _suspendedAt });
+                }*/
+            }
+
+            return managedElements[id];
+        };
+
+        var _unmanage = function(id) {
+            delete managedElements[id];
+        };
+
+        /**
+         * updates the offset and size for a given element, and stores the
+         * values. if 'offset' is not null we use that (it would have been
+         * passed in from a drag call) because it's faster; but if it is null,
+         * or if 'recalc' is true in order to force a recalculation, we get the current values.
+         */
+        var _updateOffset = this.updateOffset = function(params) {
+
+            var timestamp = params.timestamp, recalc = params.recalc, offset = params.offset, elId = params.elId, s;
+            if (_suspendDrawing && !timestamp) timestamp = _suspendedAt;
+            if (!recalc) {
+                if (timestamp && timestamp === offsetTimestamps[elId]) {
+                    return {o:params.offset || offsets[elId], s:sizes[elId]};
+                }
+            }
+            if (recalc || (!offset && offsets[elId] == null)) { // if forced repaint or no offset available, we recalculate.
+
+                // get the current size and offset, and store them
+                s = managedElements[elId] ? managedElements[elId].el : null;
+                if (s != null) {
+                    sizes[elId] = _currentInstance.getSize(s);
+                    offsets[elId] = _getOffset(s, _currentInstance);
+                    offsetTimestamps[elId] = timestamp;
+                }
+            } else {
+                offsets[elId] = offset || offsets[elId];
+                if (sizes[elId] == null) {
+                    //s = document.getElementById(elId);
+                    s = managedElements[elId].el;
+                    if (s != null) sizes[elId] = _currentInstance.getSize(s);
+                }
+                offsetTimestamps[elId] = timestamp;
+            }
+
+            if(offsets[elId] && !offsets[elId].right) {
+                offsets[elId].right = offsets[elId].left + sizes[elId][0];
+                offsets[elId].bottom = offsets[elId].top + sizes[elId][1];
+                offsets[elId].width = sizes[elId][0];
+                offsets[elId].height = sizes[elId][1];
+                offsets[elId].centerx = offsets[elId].left + (offsets[elId].width / 2);
+                offsets[elId].centery = offsets[elId].top + (offsets[elId].height / 2);
+            }
+
+            return {o:offsets[elId], s:sizes[elId]};
+        };
+		
+		/**
+		 * callback from the current library to tell us to prepare ourselves (attach
+		 * mouse listeners etc; can't do that until the library has provided a bind method)		 
+		 */
+		this.init = function() {
+			var _oneType = function(renderer, name, fn) {
+				jsPlumb.Connectors[renderer][name] = function() {
+					fn.apply(this, arguments);
+					jsPlumb.ConnectorRenderers[renderer].apply(this, arguments);		
+				};
+				jsPlumbUtil.extend(jsPlumb.Connectors[renderer][name], [ fn, jsPlumb.ConnectorRenderers[renderer]]);
+			};
+
+			if (!jsPlumb.connectorsInitialized) {
+				for (var i = 0; i < connectorTypes.length; i++) {
+					for (var j = 0; j < rendererTypes.length; j++) {
+						_oneType(rendererTypes[j], connectorTypes[i][1], connectorTypes[i][0]);												
+					}
+
+				}
+				jsPlumb.connectorsInitialized = true;
+			}
+			
+			if (!initialized) {                
+				_getContainerFromDefaults();	
+                _currentInstance.anchorManager = new jsPlumb.AnchorManager({jsPlumbInstance:_currentInstance});                
+				_currentInstance.setRenderMode(_currentInstance.Defaults.RenderMode);  // calling the method forces the capability logic to be run.														
+				initialized = true;
+				_currentInstance.fire("ready", _currentInstance);
+			}
+		}.bind(this);		
+		
+		this.log = log;
+		this.jsPlumbUIComponent = jsPlumbUIComponent;		
+
+		/*
+		 * Creates an anchor with the given params.
+		 * 
+		 * 
+		 * Returns: The newly created Anchor.
+		 * Throws: an error if a named anchor was not found.
+		 */
+		this.makeAnchor = function() {
+			var pp, _a = function(t, p) {
+				if (jsPlumb.Anchors[t]) return new jsPlumb.Anchors[t](p);
+				if (!_currentInstance.Defaults.DoNotThrowErrors)
+					throw { msg:"jsPlumb: unknown anchor type '" + t + "'" };
+			};
+			if (arguments.length === 0) return null;
+			var specimen = arguments[0], elementId = arguments[1], jsPlumbInstance = arguments[2], newAnchor = null;			
+			// if it appears to be an anchor already...
+			if (specimen.compute && specimen.getOrientation) return specimen;  //TODO hazy here about whether it should be added or is already added somehow.
+			// is it the name of an anchor type?
+			else if (typeof specimen == "string") {
+				newAnchor = _a(arguments[0], {elementId:elementId, jsPlumbInstance:_currentInstance});
+			}
+			// is it an array? it will be one of:
+			// 		an array of [spec, params] - this defines a single anchor, which may be dynamic, but has parameters.
+			//		an array of arrays - this defines some dynamic anchors
+			//		an array of numbers - this defines a single anchor.				
+			else if (_ju.isArray(specimen)) {
+				if (_ju.isArray(specimen[0]) || _ju.isString(specimen[0])) {
+					// if [spec, params] format
+					if (specimen.length == 2 && _ju.isObject(specimen[1])) {
+						// if first arg is a string, its a named anchor with params
+						if (_ju.isString(specimen[0])) {
+							pp = jsPlumb.extend({elementId:elementId, jsPlumbInstance:_currentInstance}, specimen[1]);
+							newAnchor = _a(specimen[0], pp);
+						}
+						// otherwise first arg is array, second is params. we treat as a dynamic anchor, which is fine
+						// even if the first arg has only one entry. you could argue all anchors should be implicitly dynamic in fact.
+						else {
+							pp = jsPlumb.extend({elementId:elementId, jsPlumbInstance:_currentInstance, anchors:specimen[0]}, specimen[1]);
+							newAnchor = new jsPlumb.DynamicAnchor(pp);
+						}
+					}
+					else
+						newAnchor = new jsPlumb.DynamicAnchor({anchors:specimen, selector:null, elementId:elementId, jsPlumbInstance:_currentInstance});
+
+				}
+				else {
+					var anchorParams = {
+						x:specimen[0], y:specimen[1],
+						orientation : (specimen.length >= 4) ? [ specimen[2], specimen[3] ] : [0,0],
+						offsets : (specimen.length >= 6) ? [ specimen[4], specimen[5] ] : [ 0, 0 ],
+						elementId:elementId,
+                        jsPlumbInstance:_currentInstance,
+                        cssClass:specimen.length == 7 ? specimen[6] : null
+					};						
+					newAnchor = new jsPlumb.Anchor(anchorParams);
+					newAnchor.clone = function() { return new jsPlumb.Anchor(anchorParams); };						 					
+				}
+			}
+			
+			if (!newAnchor.id) newAnchor.id = "anchor_" + _idstamp();
+			return newAnchor;
+		};
+
+		/**
+		 * makes a list of anchors from the given list of types or coords, eg
+		 * ["TopCenter", "RightMiddle", "BottomCenter", [0, 1, -1, -1] ]
+		 */
+		this.makeAnchors = function(types, elementId, jsPlumbInstance) {
+			var r = [];
+			for ( var i = 0, ii = types.length; i < ii; i++) {
+				if (typeof types[i] == "string")
+					r.push(jsPlumb.Anchors[types[i]]({elementId:elementId, jsPlumbInstance:jsPlumbInstance}));
+				else if (_ju.isArray(types[i]))
+					r.push(_currentInstance.makeAnchor(types[i], elementId, jsPlumbInstance));
+			}
+			return r;
+		};
+
+		/**
+		 * Makes a dynamic anchor from the given list of anchors (which may be in shorthand notation as strings or dimension arrays, or Anchor
+		 * objects themselves) and the given, optional, anchorSelector function (jsPlumb uses a default if this is not provided; most people will
+		 * not need to provide this - i think). 
+		 */
+		this.makeDynamicAnchor = function(anchors, anchorSelector) {
+			return new jsPlumb.DynamicAnchor({anchors:anchors, selector:anchorSelector, elementId:null, jsPlumbInstance:_currentInstance});
+		};
+		
+// --------------------- makeSource/makeTarget ---------------------------------------------- 
+		
+		this.targetEndpointDefinitions = {};
+		var _setEndpointPaintStylesAndAnchor = function(ep, epIndex, _instance) {
+				ep.paintStyle = ep.paintStyle ||
+				 				_instance.Defaults.EndpointStyles[epIndex] ||
+	                            _instance.Defaults.EndpointStyle;
+								
+				ep.hoverPaintStyle = ep.hoverPaintStyle ||
+	                           _instance.Defaults.EndpointHoverStyles[epIndex] ||
+	                           _instance.Defaults.EndpointHoverStyle;                            
+
+				ep.anchor = ep.anchor ||
+	                      	_instance.Defaults.Anchors[epIndex] ||
+	                      	_instance.Defaults.Anchor;
+					
+				ep.endpoint = ep.endpoint ||
+							  _instance.Defaults.Endpoints[epIndex] ||
+							  _instance.Defaults.Endpoint;
+			};
+			
+			// TODO put all the source stuff inside one parent, keyed by id.
+			this.sourceEndpointDefinitions = {};
+			
+			var selectorFilter = function(evt, _el, selector, _instance, negate) {
+                var t = evt.target || evt.srcElement, ok = false, 
+                    sel = _instance.getSelector(_el, selector);
+                for (var j = 0; j < sel.length; j++) {
+                    if (sel[j] == t) {
+                        ok = true;
+                        break;
+                    }
+                }
+                return negate ? !ok : ok;
+	        };
+
+
+        //this.
+
+		// see API docs
+		this.makeTarget = function(el, params, referenceParams) {
+
+			// put jsplumb ref into params without altering the params passed in
+			var p = jsPlumb.extend({_jsPlumb:this}, referenceParams);
+			jsPlumb.extend(p, params);
+
+			// calculate appropriate paint styles and anchor from the params given
+			_setEndpointPaintStylesAndAnchor(p, 1, this);
+
+			var targetScope = p.scope || _currentInstance.Defaults.Scope,
+				deleteEndpointsOnDetach = !(p.deleteEndpointsOnDetach === false),
+				maxConnections = p.maxConnections || -1,
+				onMaxConnections = p.onMaxConnections,
+
+				_doOne = function(el) {
+					
+					// get the element's id and store the endpoint definition for it.  jsPlumb.connect calls will look for one of these,
+					// and use the endpoint definition if found.
+					// decode the info for this element (id and element)
+					var elInfo = _info(el), 
+						elid = elInfo.id,
+						proxyComponent = new jsPlumbUIComponent(p),
+						dropOptions = jsPlumb.extend({}, p.dropOptions || {});
+
+					_ensureContainer(elid);
+
+					// store the definitions keyed against the element id.
+					// TODO why not just store inside the element itself?
+                    var _def = {
+                        def:p,
+                        uniqueEndpoint:p.uniqueEndpoint,
+                        maxConnections:maxConnections,
+                        enabled:true
+                    };
+                    elInfo.el._jsPlumbTarget = _def;
+
+					this.targetEndpointDefinitions[elid] = _def;
+
+
+                    var _drop = p._jsPlumb.EndpointDropHandler({
+                        //endpoint:_ep,
+                        jsPlumb: _currentInstance,
+                        enabled:function() {
+                            return elInfo.el._jsPlumbTarget.enabled;
+                        },
+                        isFull:function(originalEvent) {
+                            var targetCount = _currentInstance.select({target:elid}).length;
+                            var def = elInfo.el._jsPlumbTarget;
+                            var full = def.maxConnections > 0 && targetCount >= def.maxConnections;
+                            if (full && onMaxConnections) {
+                                // TODO here we still have the id of the floating element, not the
+                                // actual target.
+                                onMaxConnections({
+                                    element:elInfo.el,
+                                    connection:jpc
+                                }, originalEvent);
+                            }
+                            return full;
+                        },
+                        element:elInfo.el,
+                        elementId:elid,
+                        isSource:false,
+                        isTarget:true,
+                        addClass:function(clazz) {
+                            //_ep.addClass(clazz)
+                            _currentInstance.addClass(elInfo.el, clazz);
+                        },
+                        removeClass:function(clazz) {
+                            //_ep.removeClass(clazz)
+                            _currentInstance.removeClass(elInfo.el, clazz);
+                        },
+                        onDrop:function(jpc) {
+                            var source = jpc.endpoints[0];
+                            source.anchor.locked = false;
+                        },
+                        isDropAllowed:function() {
+                            return proxyComponent.isDropAllowed.apply(proxyComponent, arguments);
+                        },
+                        getEndpoint:function(jpc) {
+                            // make a new Endpoint for the target, or get it from the cache if uniqueEndpoint
+                            // is set.
+                            var _el = _currentInstance.getElementObject(elInfo.el),
+                                def = elInfo.el._jsPlumbTarget,
+                                newEndpoint = def.endpoint;
+
+                            // if no cached endpoint, or there was one but it has been cleaned up
+                            // (ie. detached), then create a new one.
+                            if (newEndpoint == null || newEndpoint._jsPlumb == null)
+                                newEndpoint = _currentInstance.addEndpoint(_el, p);
+
+                            if (p.uniqueEndpoint) def.endpoint = newEndpoint;  // may of course just store what it just pulled out. that's ok.
+                            // TODO test options to makeTarget to see if we should do this?
+                            newEndpoint._doNotDeleteOnDetach = false; // reset.
+                            newEndpoint._deleteOnDetach = true;
+
+                            // if connection is detachable, init the new endpoint to be draggable, to support that happening.
+                            if (jpc.isDetachable())
+                                newEndpoint.initDraggable();
+
+                            // if the anchor has a 'positionFinder' set, then delegate to that function to find
+                            // out where to locate the anchor.
+                            if (newEndpoint.anchor.positionFinder != null) {
+                                var dropPosition = _currentInstance.getUIPosition(arguments, this.getZoom()),
+                                    elPosition = _getOffset(_el, this),
+                                    elSize = _currentInstance.getSize(_el),
+                                    ap = newEndpoint.anchor.positionFinder(dropPosition, elPosition, elSize, newEndpoint.anchor.constructorParams);
+                                newEndpoint.anchor.x = ap[0];
+                                newEndpoint.anchor.y = ap[1];
+                                // now figure an orientation for it..kind of hard to know what to do actually. probably the best thing i can do is to
+                                // support specifying an orientation in the anchor's spec. if one is not supplied then i will make the orientation
+                                // be what will cause the most natural link to the source: it will be pointing at the source, but it needs to be
+                                // specified in one axis only, and so how to make that choice? i think i will use whichever axis is the one in which
+                                // the target is furthest away from the source.
+                            }
+
+                            return newEndpoint;
+                        }
+                    });
+					
+					// wrap drop events as needed and initialise droppable
+					var dropEvent = jsPlumb.dragEvents.drop;
+					dropOptions.scope = dropOptions.scope || targetScope;
+					dropOptions[dropEvent] = _ju.wrap(dropOptions[dropEvent], _drop);
+					// vanilla jsplumb only
+					if (p.allowLoopback === false) {
+						dropOptions.canDrop = function(_drag) {
+							var de = _drag.getDragElement()._jsPlumbRelatedElement;
+							return de != elInfo.el;
+						};
+					}
+					this.initDroppable(this.getElementObject(elInfo.el), dropOptions, "internal");
+				}.bind(this);
+
+			// make an array if only given one element
+			var inputs = el.length && el.constructor != String ? el : [ el ];
+						
+			// register each one in the list.
+			for (var i = 0, ii = inputs.length; i < ii; i++) {							
+				_doOne(inputs[i]);
+			}
+
+			return this;
+		};
+
+		// see api docs
+		this.unmakeTarget = function(el, doNotClearArrays) {
+			var info = _info(el);
+
+			jsPlumb.destroyDroppable(info.el);
+			// TODO this is not an exhaustive unmake of a target, since it does not remove the droppable stuff from
+			// the element.  the effect will be to prevent it from behaving as a target, but it's not completely purged.
+			if (!doNotClearArrays) {
+				delete this.targetEndpointDefinitions[info.id];
+			}
+
+			return this;
+		};						
+
+	    // see api docs
+		this.makeSource = function(el, params, referenceParams) {
+			var p = jsPlumb.extend({}, referenceParams);
+			jsPlumb.extend(p, params);
+			_setEndpointPaintStylesAndAnchor(p, 0, this);
+			var maxConnections = p.maxConnections || 1,
+				onMaxConnections = p.onMaxConnections,
+				_doOne = function(elInfo) {
+					// get the element's id and store the endpoint definition for it.  jsPlumb.connect calls will look for one of these,
+					// and use the endpoint definition if found.
+					var elid = elInfo.id,
+						_el = this.getElementObject(elInfo.el),
+						_del = this.getDOMElement(_el),
+						parentElement = function() {
+							return p.parent == null ? null : p.parent === "parent" ? elInfo.el.parentNode : _currentInstance.getDOMElement(p.parent);
+						},
+						idToRegisterAgainst = p.parent != null ? this.getId(parentElement()) : elid;
+
+					_ensureContainer(idToRegisterAgainst);
+					
+					this.sourceEndpointDefinitions[idToRegisterAgainst] = {
+						def:p,
+						uniqueEndpoint:p.uniqueEndpoint,
+						maxConnections:maxConnections,
+						enabled:true
+					};
+					var stopEvent = jsPlumb.dragEvents.stop,
+						dragEvent = jsPlumb.dragEvents.drag,
+						dragOptions = jsPlumb.extend({ }, p.dragOptions || {}),
+						existingDrag = dragOptions.drag,
+						existingStop = dragOptions.stop,
+						ep = null,
+						endpointAddedButNoDragYet = false;
+
+					// set scope if its not set in dragOptions but was passed in in params
+					dragOptions.scope = dragOptions.scope || p.scope;
+
+					dragOptions[dragEvent] = _ju.wrap(dragOptions[dragEvent], function() {
+						if (existingDrag) existingDrag.apply(this, arguments);
+						endpointAddedButNoDragYet = false;
+					});
+					
+					dragOptions[stopEvent] = _ju.wrap(dragOptions[stopEvent], function() { 
+
+						if (existingStop) existingStop.apply(this, arguments);
+	                    this.currentlyDragging = false;
+						if (ep._jsPlumb != null) { // if not cleaned up...
+									
+							// reset the anchor to the anchor that was initially provided. the one we were using to drag
+							// the connection was just a placeholder that was located at the place the user pressed the
+							// mouse button to initiate the drag.
+							var anchorDef = p.anchor || this.Defaults.Anchor,
+								oldAnchor = ep.anchor,
+								oldConnection = ep.connections[0],
+								newAnchor = this.makeAnchor(anchorDef, elid, this),
+								_el = ep.element;
+
+							// if the anchor has a 'positionFinder' set, then delegate to that function to find
+							// out where to locate the anchor. issue 117.
+							if (newAnchor.positionFinder != null) {
+								var elPosition = _getOffset(_el, this),
+									elSize = this.getSize(_el),
+									dropPosition = { left:elPosition.left + (oldAnchor.x * elSize[0]), top:elPosition.top + (oldAnchor.y * elSize[1]) },
+									ap = newAnchor.positionFinder(dropPosition, elPosition, elSize, newAnchor.constructorParams);
+
+								newAnchor.x = ap[0];
+								newAnchor.y = ap[1];
+							}
+
+							ep.setAnchor(newAnchor, true);
+							
+							if (p.parent) {
+								var parent = parentElement();
+								if (parent) {	
+									var potentialParent = p.container || _container;
+									ep.setElement(parent, potentialParent);
+								}
+							}
+							
+							ep.repaint();
+							this.repaint(ep.elementId);
+							this.repaint(oldConnection.targetId);
+						}
+					}.bind(this));
+					
+					// when the user presses the mouse, add an Endpoint, if we are enabled.
+					var mouseDownListener = function(e) {
+						var evt = this.getOriginalEvent(e);
+                        // on right mouse button, abort.
+                        if (e.which === 3 || e.button === 2) return;
+
+						var def = this.sourceEndpointDefinitions[idToRegisterAgainst];
+						elid = this.getId(this.getDOMElement(_el)); // elid might have changed since this method was called to configure the element.
+						
+						// if disabled, return.
+						if (!def.enabled) return;
+	                    
+	                    // if a filter was given, run it, and return if it says no.
+						if (p.filter) {
+							var r = jsPlumbUtil.isString(p.filter) ? selectorFilter(evt, _el, p.filter, this, p.filterExclude) : p.filter(evt, _el);
+							if (r === false) return;
+						}
+						
+						// if maxConnections reached
+						var sourceCount = this.select({source:idToRegisterAgainst}).length;
+						if (def.maxConnections >= 0 && (def.uniqueEndpoint && sourceCount >= def.maxConnections)) {
+							if (onMaxConnections) {
+								onMaxConnections({
+									element:_el,
+									maxConnections:maxConnections
+								}, e);
+							}
+							return false;
+						}
+
+						// find the position on the element at which the mouse was pressed; this is where the endpoint 
+						// will be located.
+						var elxy = jsPlumbAdapter.getPositionOnElement(evt, _del, _zoom), pelxy = elxy;
+
+						// we need to override the anchor in here, and force 'isSource', but we don't want to mess with
+						// the params passed in, because after a connection is established we're going to reset the endpoint
+						// to have the anchor we were given.
+						var tempEndpointParams = {};
+						jsPlumb.extend(tempEndpointParams, p);
+						tempEndpointParams.isTemporarySource = true;
+						tempEndpointParams.anchor = [ elxy[0], elxy[1] , 0,0];
+						tempEndpointParams.dragOptions = dragOptions;
+
+						ep = this.addEndpoint(elid, tempEndpointParams);
+						endpointAddedButNoDragYet = true;
+						ep.endpointWillMoveTo = p.parent ? parentElement() : null;
+
+                        // if unique endpoint and it's already been created, push it onto the endpoint we create. at the end
+                        // of a successful connection we'll switch to that endpoint.
+                        //if (def.uniqueEndpoint && def.endpoint) ep.finalEndpoint = def.endpoint;
+                        if (def.uniqueEndpoint) {
+                            if (!def.endpoint)
+                                def.endpoint = ep;
+                            else
+                                ep.finalEndpoint = def.endpoint;
+                        }
+
+						// TODO test options to makeSource to see if we should do this?
+						ep._doNotDeleteOnDetach = false; // reset.
+						ep._deleteOnDetach = true;
+
+	                    var _delTempEndpoint = function() {
+							// this mouseup event is fired only if no dragging occurred, by jquery and yui, but for mootools
+							// it is fired even if dragging has occurred, in which case we would blow away a perfectly
+							// legitimate endpoint, were it not for this check.  the flag is set after adding an
+							// endpoint and cleared in a drag listener we set in the dragOptions above.
+                            _currentInstance.off(ep.canvas, "mouseup",  _delTempEndpoint);
+                            _currentInstance.off(_el, "mouseup", _delTempEndpoint);
+							if(endpointAddedButNoDragYet) {
+								 endpointAddedButNoDragYet = false;
+								_currentInstance.deleteEndpoint(ep);
+	                        }
+						};
+
+						_currentInstance.on(ep.canvas, "mouseup", _delTempEndpoint);
+	                    _currentInstance.on(_el, "mouseup", _delTempEndpoint);
+						
+						// and then trigger its mousedown event, which will kick off a drag, which will start dragging
+						// a new connection from this endpoint.
+						_currentInstance.trigger(ep.canvas, "mousedown", e);
+
+						jsPlumbUtil.consume(e);
+						
+					}.bind(this);
+	               
+	                this.on(_el, "mousedown", mouseDownListener);
+	                this.sourceEndpointDefinitions[idToRegisterAgainst].trigger = mouseDownListener;
+
+	                // lastly, if a filter was provided, set it as a dragFilter on the element,
+	                // to prevent the element drag function from kicking in when we want to
+	                // drag a new connection
+	                if (p.filter && jsPlumbUtil.isString(p.filter)) {
+	                	_currentInstance.setDragFilter(_el, p.filter);
+	                }
+				}.bind(this);
+			
+			var inputs = el.length && el.constructor != String ? el : [ el ];
+			for (var i = 0, ii = inputs.length; i < ii; i++) {
+				_doOne(_info(inputs[i]));
+			}
+
+			return this;
+		};
+	
+		// see api docs		
+		this.unmakeSource = function(el, doNotClearArrays) {
+			var info = _info(el),
+				mouseDownListener = this.sourceEndpointDefinitions[info.id].trigger;
+			
+			if (mouseDownListener) 
+				_currentInstance.off(info.el, "mousedown", mouseDownListener);
+
+			if (!doNotClearArrays) {
+				delete this.sourceEndpointDefinitions[info.id];
+			}
+
+			return this;
+		};
+
+		// see api docs
+		this.unmakeEverySource = function() {
+			for (var i in this.sourceEndpointDefinitions)
+				_currentInstance.unmakeSource(i, true);
+
+			this.sourceEndpointDefinitions = {};
+			return this;
+		};
+
+        var _getScope = function(el, types) {
+            types = jsPlumbUtil.isArray(types) ? types : [ types ];
+            var id = _getId(el);
+            for (var i = 0; i < types.length; i++) {
+                var def = this[types[i]][id];
+                if (def) return def.def.scope || this.Defaults.Scope;
+            }
+        }.bind(this);
+
+        var _setScope = function(el, scope, types) {
+            types = jsPlumbUtil.isArray(types) ? types : [ types ];
+            var id = _getId(el);
+            for (var i = 0; i < types.length; i++) {
+                var def = this[types[i]][id];
+                if (def) {
+                    def.def.scope = scope;
+                    if (this.scopeChange != null) this.scopeChange(el, id, endpointsByElement[id], scope, types[i]);
+                }
+            }
+
+        }.bind(this);
+
+        this.getScope = function(el, scope) { return _getScope(el, [ "sourceEndpointDefinitions", "targetEndpointDefinitions" ]); };
+        this.getSourceScope = function(el) { return _getScope(el, "sourceEndpointDefinitions"); };
+        this.getTargetScope = function(el) { return _getScope(el, "targetEndpointDefinitions"); };
+        this.setScope = function(el, scope) { _setScope(el, scope, [ "sourceEndpointDefinitions", "targetEndpointDefinitions" ]); };
+        this.setSourceScope = function(el, scope) { _setScope(el, scope, "sourceEndpointDefinitions"); };
+        this.setTargetScope = function(el, scope) { _setScope(el, scope, "targetEndpointDefinitions"); };
+		
+		// see api docs
+		this.unmakeEveryTarget = function() {
+			for (var i in this.targetEndpointDefinitions)
+				_currentInstance.unmakeTarget(i, true);
+			
+			this.targetEndpointDefinitions = {};
+			return this;
+		};
+
+		// does the work of setting a source enabled or disabled.
+		var _setEnabled = function(type, el, state, toggle) {
+			var a = type == "source" ? this.sourceEndpointDefinitions : this.targetEndpointDefinitions;
+
+			if (_ju.isString(el)) a[el].enabled = toggle ? !a[el].enabled : state;
+			else if (el.length) {				
+				for (var i = 0, ii = el.length; i < ii; i++) {
+					var info = _info(el[i]);
+					if (a[info.id])
+						a[info.id].enabled = toggle ? !a[info.id].enabled : state;
+				}
+			}	
+			// otherwise a DOM element
+			else {
+				var id = _info(el).id;
+				a[id].enabled = toggle ? !a[id].enabled : state;
+			}
+			return this;
+		}.bind(this);
+		
+		var _first = function(el, fn) {
+			if (_ju.isString(el) || !el.length)
+				return fn.apply(this, [ el ]);
+			else if (el.length) 
+				return fn.apply(this, [ el[0] ]);
+				
+		}.bind(this);
+
+		this.toggleSourceEnabled = function(el) {
+			_setEnabled("source", el, null, true);
+			return this.isSourceEnabled(el);
+		};
+
+		this.setSourceEnabled = function(el, state) { return _setEnabled("source", el, state); };
+		this.isSource = function(el) { 
+			return _first(el, function(_el) { 
+				return this.sourceEndpointDefinitions[_info(_el).id] != null; 
+            }.bind(this));
+		};
+		this.isSourceEnabled = function(el) { 
+			return _first(el, function(_el) {
+				var sep = this.sourceEndpointDefinitions[_info(_el).id];
+				return sep && sep.enabled === true;
+            }.bind(this));
+		};
+
+		this.toggleTargetEnabled = function(el) {
+			_setEnabled("target", el, null, true);
+			return this.isTargetEnabled(el);
+		};
+		
+		this.isTarget = function(el) { 
+			return _first(el, function(_el) {
+				return this.targetEndpointDefinitions[_info(_el).id] != null; 
+            }.bind(this));
+		};
+		this.isTargetEnabled = function(el) { 
+			return _first(el, function(_el) {
+				var tep = this.targetEndpointDefinitions[_info(_el).id];
+				return tep && tep.enabled === true;
+            }.bind(this));
+		};
+		this.setTargetEnabled = function(el, state) { return _setEnabled("target", el, state); };
+
+// --------------------- end makeSource/makeTarget ---------------------------------------------- 				
+				
+		this.ready = function(fn) {
+			_currentInstance.bind("ready", fn);
+		};
+
+		// repaint some element's endpoints and connections
+		this.repaint = function(el, ui, timestamp) {
+			// support both lists...
+			if (typeof el == 'object' && el.length)
+				for ( var i = 0, ii = el.length; i < ii; i++) {
+					_draw(el[i], ui, timestamp);
+				}
+			else // ...and single strings.
+				_draw(el, ui, timestamp);
+				
+			return _currentInstance;
+		};
+
+        this.revalidate = function(el) {
+            var elId = _currentInstance.getId(el);
+            _currentInstance.updateOffset( { elId : elId, recalc : true } );
+            return _currentInstance.repaint(el);
+        };
+
+		// repaint every endpoint and connection.
+		this.repaintEverything = function(clearEdits) {	
+			// TODO this timestamp causes continuous anchors to not repaint properly.
+			// fix this. do not just take out the timestamp. it runs a lot faster with 
+			// the timestamp included.
+			//var timestamp = null;
+			var timestamp = _timestamp(), elId;
+
+            for (elId in endpointsByElement) {
+                _currentInstance.updateOffset( { elId : elId, recalc : true, timestamp:timestamp } );
+            }
+
+			for (elId in endpointsByElement) {
+				_draw(elId, null, timestamp, clearEdits);
+			}
+			return this;
+		};
+
+		this.removeAllEndpoints = function(el, recurse) {
+            var _one = function(_el) {
+                var info = _info(_el),
+                    ebe = endpointsByElement[info.id],
+                    i, ii;
+
+                if (ebe) {
+                    for ( i = 0, ii = ebe.length; i < ii; i++) 
+                        _currentInstance.deleteEndpoint(ebe[i]);
+                }
+                delete endpointsByElement[info.id];
+                
+                if (recurse) {
+                    if (info.el && info.el.nodeType != 3 && info.el.nodeType != 8 ) {
+                        for ( i = 0, ii = info.el.childNodes.length; i < ii; i++) {
+                            _one(info.el.childNodes[i]);
+                        }
+                    }
+                }
+                
+            };
+            _one(el);
+			return this;
+		};
+                    
+        /**
+        * Remove the given element, including cleaning up all endpoints registered for it.
+        * This is exposed in the public API but also used internally by jsPlumb when removing the
+        * element associated with a connection drag.
+        */
+        this.remove = function(el, doNotRepaint) {
+        	var info = _info(el);        	
+            _currentInstance.doWhileSuspended(function() {
+            	_currentInstance.removeAllEndpoints(info.id, true);
+            	_currentInstance.dragManager.elementRemoved(info.id);
+            	delete _currentInstance.floatingConnections[info.id];
+            	_currentInstance.anchorManager.clearFor(info.id);						
+            	_currentInstance.anchorManager.removeFloatingConnection(info.id);
+            }, doNotRepaint === false);
+            _unmanage(info.id);
+            if (info.el){
+                _currentInstance.removeElement(info.el);
+                info.el._jsPlumb = null;
+            }
+			return _currentInstance;
+        };
+		
+		this.reset = function() {
+            _currentInstance.setSuspendEvents(true);
+			_currentInstance.deleteEveryEndpoint();
+            _currentInstance.unbind();
+			this.targetEndpointDefinitions = {};
+			this.sourceEndpointDefinitions = {};
+			connections.length = 0;
+            _currentInstance.setSuspendEvents(false);
+		};
+
+        var _clearObject = function(obj) {
+            if(obj.canvas && obj.canvas.parentNode)
+                   obj.canvas.parentNode.removeChild(obj.canvas);
+            obj.cleanup();
+            obj.destroy();
+        };
+
+        var _clearOverlayObject = function(obj) {
+            _clearObject(obj);
+        };
+
+        this.clear = function() {
+            _currentInstance.select().each(_clearOverlayObject);
+            _currentInstance.selectEndpoints().each(_clearOverlayObject);
+
+            endpointsByElement = {};
+            endpointsByUUID = {};
+        };
+
+		this.setDefaultScope = function(scope) {
+			DEFAULT_SCOPE = scope;
+			return _currentInstance;
+		};
+
+		// sets whether or not some element should be currently draggable.
+		this.setDraggable = _setDraggable;
+
+		// sets the id of some element, changing whatever we need to to keep track.
+		this.setId = function(el, newId, doNotSetAttribute) {
+			// 
+			var id;
+
+			if (jsPlumbUtil.isString(el)) {
+				id = el;
+			}
+			else {
+				el = this.getDOMElement(el);
+				id = this.getId(el);
+			}
+
+			var sConns = this.getConnections({source:id, scope:'*'}, true),
+				tConns = this.getConnections({target:id, scope:'*'}, true);
+
+			newId = "" + newId;
+
+			if (!doNotSetAttribute) {
+				el = this.getDOMElement(id);
+				this.setAttribute(el, "id", newId);
+			}
+			else
+				el = this.getDOMElement(newId);
+
+			endpointsByElement[newId] = endpointsByElement[id] || [];
+			for (var i = 0, ii = endpointsByElement[newId].length; i < ii; i++) {
+				endpointsByElement[newId][i].setElementId(newId);
+				endpointsByElement[newId][i].setReferenceElement(el);
+			}
+			delete endpointsByElement[id];
+
+			this.anchorManager.changeId(id, newId);
+			if (this.dragManager) this.dragManager.changeId(id, newId);
+            managedElements[newId] = managedElements[id];
+            delete managedElements[id];
+
+			var _conns = function(list, epIdx, type) {
+				for (var i = 0, ii = list.length; i < ii; i++) {
+					list[i].endpoints[epIdx].setElementId(newId);
+					list[i].endpoints[epIdx].setReferenceElement(el);
+					list[i][type + "Id"] = newId;
+					list[i][type] = el;
+				}
+			};
+			_conns(sConns, 0, "source");
+			_conns(tConns, 1, "target");
+
+			this.repaint(newId);
+		};
+
+		this.setDebugLog = function(debugLog) {
+			log = debugLog;
+		};
+
+		this.setSuspendDrawing = function(val, repaintAfterwards) {
+			var curVal = _suspendDrawing;
+		    _suspendDrawing = val;
+				if (val) _suspendedAt = new Date().getTime(); else _suspendedAt = null;
+		    if (repaintAfterwards) this.repaintEverything();
+		    return curVal;
+		};
+
+        // returns whether or not drawing is currently suspended.
+		this.isSuspendDrawing = function() {
+			return _suspendDrawing;
+		};
+
+        // return timestamp for when drawing was suspended.
+        this.getSuspendedAt = function() { return _suspendedAt; };
+
+        this.doWhileSuspended = function(fn, doNotRepaintAfterwards) {
+        	var _wasSuspended = this.isSuspendDrawing();
+        	if (!_wasSuspended)
+				this.setSuspendDrawing(true);
+			try {
+				fn();
+			}
+			catch (e) {
+				_ju.log("Function run while suspended failed", e);
+			}
+			if (!_wasSuspended)
+				this.setSuspendDrawing(false, !doNotRepaintAfterwards);
+		};
+
+		this.getOffset = function(elId) { return offsets[elId]; };
+		this.getCachedData = _getCachedData;
+		this.timestamp = _timestamp;
+		this.setRenderMode = function(mode) {
+			if (mode !== jsPlumb.SVG && mode !== jsPlumb.VML) throw new TypeError("Render mode [" + mode + "] not supported");
+			renderMode = jsPlumbAdapter.setRenderMode(mode);
+			return renderMode;
+		};
+		this.getRenderMode = function() { return renderMode; };
+		this.show = function(el, changeEndpoints) {
+			_setVisible(el, "block", changeEndpoints);
+			return _currentInstance;
+		};
+
+		// TODO: update this method to return the current state.
+		this.toggleVisible = _toggleVisible;
+		this.toggleDraggable = _toggleDraggable;
+		this.addListener = this.bind;
+
+		if (!jsPlumbAdapter.headless) {
+			_currentInstance.dragManager = jsPlumbAdapter.getDragManager(_currentInstance);
+			_currentInstance.recalculateOffsets = _currentInstance.dragManager.updateOffsets;
+		}
+	};
+
+    jsPlumbUtil.extend(jsPlumbInstance, jsPlumbUtil.EventGenerator, {
+    	setAttribute : function(el, a, v) {
+    		this.setAttribute(el, a, v);
+    	},
+    	getAttribute : function(el, a) {
+    		return this.getAttribute(jsPlumb.getDOMElement(el), a);
+    	},    	
+    	registerConnectionType : function(id, type) {
+    		this._connectionTypes[id] = jsPlumb.extend({}, type);
+    	},    	
+    	registerConnectionTypes : function(types) {
+    		for (var i in types)
+    			this._connectionTypes[i] = jsPlumb.extend({}, types[i]);
+    	},
+    	registerEndpointType : function(id, type) {
+    		this._endpointTypes[id] = jsPlumb.extend({}, type);
+    	},    	
+    	registerEndpointTypes : function(types) {
+    		for (var i in types)
+    			this._endpointTypes[i] = jsPlumb.extend({}, types[i]);
+    	},    	
+    	getType : function(id, typeDescriptor) {
+    		return typeDescriptor ===  "connection" ? this._connectionTypes[id] : this._endpointTypes[id];
+    	},
+    	setIdChanged : function(oldId, newId) {
+    		this.setId(oldId, newId, true);
+    	},
+    	// set parent: change the parent for some node and update all the registrations we need to.
+    	setParent : function(el, newParent) {
+    		var _el = this.getElementObject(el),
+    			_dom = this.getDOMElement(_el),
+    			_id = this.getId(_dom),
+    			_pel = this.getElementObject(newParent),
+    			_pdom = this.getDOMElement(_pel),
+    			_pid = this.getId(_pdom);
+
+    		_dom.parentNode.removeChild(_dom);
+    		_pdom.appendChild(_dom);
+    		this.dragManager.setParent(_el, _id, _pel, _pid);
+    	},
+		/**
+		 * gets the size for the element, in an array : [ width, height ].
+		 */
+		getSize : function(el) {
+			return [ el.offsetWidth, el.offsetHeight ];
+		},
+		getWidth : function(el) {
+			return el.offsetWidth;
+		},
+		getHeight : function(el) {
+			return el.offsetHeight;
+		},
+		extend : function(o1, o2, names) {
+			var i;
+			if (names) {
+				for (i = 0; i < names.length; i++)
+					o1[names[i]] = o2[names[i]];
+			}
+			else
+				for (i in o2) o1[i] = o2[i];
+			return o1;
+		},
+        floatingConnections:{},
+        getFloatingAnchorIndex : function(jpc) {
+            return jpc.endpoints[0].isFloating() ? 0 : 1;
+        }
+    }, jsPlumbAdapter);
+
+// --------------------- static instance + AMD registration -------------------------------------------	
+	
+// create static instance and assign to window if window exists.	
+	var jsPlumb = new jsPlumbInstance();
+	// register on window if defined (lets us run on server)
+	if (typeof window != 'undefined') window.jsPlumb = jsPlumb;	
+	// add 'getInstance' method to static instance
+	jsPlumb.getInstance = function(_defaults) {
+		var j = new jsPlumbInstance(_defaults);
+		j.init();
+		return j;
+	};
+// maybe register static instance as an AMD module, and getInstance method too.
+	if ( typeof define === "function") {
+		define( "jsplumb", [], function () { return jsPlumb; } );
+		define( "jsplumbinstance", [], function () { return jsPlumb.getInstance(); } );
+	}
+ // CommonJS 
+	if (typeof exports !== 'undefined') {
+      exports.jsPlumb = jsPlumb;
+  	}
+	
+	
+// --------------------- end static instance + AMD registration -------------------------------------------		
+	
+})();
+
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the code for Endpoints.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+;(function() {
+    
+    "use strict";
+        
+    // create the drag handler for a connection
+    var _makeConnectionDragHandler = function(placeholder, _jsPlumb) {
+        var stopped = false;
+        return {
+            drag : function() {
+                if (stopped) {
+                    stopped = false;
+                    return true;
+                }
+                var _ui = jsPlumb.getUIPosition(arguments, _jsPlumb.getZoom());
+        
+                if (placeholder.element) {
+                    jsPlumbAdapter.setPosition(placeholder.element, _ui);                    
+                    _jsPlumb.repaint(placeholder.element, _ui);
+                }
+            },
+            stopDrag : function() {
+                stopped = true;
+            }
+        };
+    };
+        
+    // creates a placeholder div for dragging purposes, adds it to the DOM, and pre-computes its offset.    
+    var _makeDraggablePlaceholder = function(placeholder, _jsPlumb) {
+        var n = document.createElement("div");
+        n.style.position = "absolute";
+        var parent = _jsPlumb.getContainer() || document.body;
+        parent.appendChild(n);
+        var id = _jsPlumb.getId(n);
+        //_jsPlumb.updateOffset( { elId : id });
+        _jsPlumb.manage( id, n );
+        // create and assign an id, and initialize the offset.
+        placeholder.id = id;
+        placeholder.element = n;
+    };
+    
+    // create a floating endpoint (for drag connections)
+    var _makeFloatingEndpoint = function(paintStyle, referenceAnchor, endpoint, referenceCanvas, sourceElement, _jsPlumb, _newEndpoint, scope) {
+        var floatingAnchor = new jsPlumb.FloatingAnchor( { reference : referenceAnchor, referenceCanvas : referenceCanvas, jsPlumbInstance:_jsPlumb });
+        //setting the scope here should not be the way to fix that mootools issue.  it should be fixed by not
+        // adding the floating endpoint as a droppable.  that makes more sense anyway!
+        return _newEndpoint({ paintStyle : paintStyle, endpoint : endpoint, anchor : floatingAnchor, source : sourceElement, scope:scope });
+    };
+
+    var typeParameters = [ "connectorStyle", "connectorHoverStyle", "connectorOverlays",
+                "connector", "connectionType", "connectorClass", "connectorHoverClass" ];
+
+    // a helper function that tries to find a connection to the given element, and returns it if so. if elementWithPrecedence is null,
+    // or no connection to it is found, we return the first connection in our list.
+    var findConnectionToUseForDynamicAnchor = function(ep, elementWithPrecedence) {
+        var idx = 0;
+        if (elementWithPrecedence != null) {
+            for (var i = 0; i < ep.connections.length; i++) {
+                if (ep.connections[i].sourceId == elementWithPrecedence || ep.connections[i].targetId == elementWithPrecedence) {
+                    idx = i;
+                    break;
+                }
+            }
+        }
+        
+        return ep.connections[idx];
+    };
+
+    var findConnectionIndex = function(conn, ep) {
+        return jsPlumbUtil.findWithFunction(ep.connections, function(c) { return c.id == conn.id; });
+    };
+
+    jsPlumb.Endpoint = function(params) {
+        var _jsPlumb = params._jsPlumb,
+            _gel = jsPlumb.getElementObject,            
+            _ju = jsPlumbUtil,            
+            _newConnection = params.newConnection,
+            _newEndpoint = params.newEndpoint,
+            _finaliseConnection = params.finaliseConnection,
+            _fireMoveEvent = params.fireMoveEvent;
+        
+        this.idPrefix = "_jsplumb_e_";			
+        this.defaultLabelLocation = [ 0.5, 0.5 ];
+        this.defaultOverlayKeys = ["Overlays", "EndpointOverlays"];
+        OverlayCapableJsPlumbUIComponent.apply(this, arguments);        
+        
+// TYPE		
+                
+        this.getDefaultType = function() {								
+            return {
+                parameters:{},
+                scope:null,
+                maxConnections:this._jsPlumb.instance.Defaults.MaxConnections,
+                paintStyle:this._jsPlumb.instance.Defaults.EndpointStyle || jsPlumb.Defaults.EndpointStyle,
+                endpoint:this._jsPlumb.instance.Defaults.Endpoint || jsPlumb.Defaults.Endpoint,
+                hoverPaintStyle:this._jsPlumb.instance.Defaults.EndpointHoverStyle || jsPlumb.Defaults.EndpointHoverStyle,				
+                overlays:this._jsPlumb.instance.Defaults.EndpointOverlays || jsPlumb.Defaults.EndpointOverlays,
+                connectorStyle:params.connectorStyle,				
+                connectorHoverStyle:params.connectorHoverStyle,
+                connectorClass:params.connectorClass,
+                connectorHoverClass:params.connectorHoverClass,
+                connectorOverlays:params.connectorOverlays,
+                connector:params.connector,
+                connectorTooltip:params.connectorTooltip
+            };
+        };
+        			
+// END TYPE
+            
+        this._jsPlumb.enabled = !(params.enabled === false);
+        this._jsPlumb.visible = true;        
+        this.element = jsPlumb.getDOMElement(params.source);  
+        this._jsPlumb.uuid = params.uuid;
+        this._jsPlumb.floatingEndpoint = null;  
+        var inPlaceCopy = null;
+        if (this._jsPlumb.uuid) params.endpointsByUUID[this._jsPlumb.uuid] = this;
+        this.elementId = params.elementId;
+        
+        this._jsPlumb.connectionCost = params.connectionCost;
+        this._jsPlumb.connectionsDirected = params.connectionsDirected;        
+        this._jsPlumb.currentAnchorClass = "";
+        this._jsPlumb.events = {};
+            
+        var  _updateAnchorClass = function() {
+            // stash old, get new
+            var oldAnchorClass = this._jsPlumb.currentAnchorClass;
+            this._jsPlumb.currentAnchorClass = this.anchor.getCssClass();
+            // add and remove at the same time to reduce the number of reflows.
+            jsPlumbAdapter.updateClasses(this.element, _jsPlumb.endpointAnchorClassPrefix + "_" + this._jsPlumb.currentAnchorClass, _jsPlumb.endpointAnchorClassPrefix + "_" + oldAnchorClass);
+            this.updateClasses(_jsPlumb.endpointAnchorClassPrefix + "_" + this._jsPlumb.currentAnchorClass, _jsPlumb.endpointAnchorClassPrefix + "_" + oldAnchorClass);
+        }.bind(this);
+        
+        this.setAnchor = function(anchorParams, doNotRepaint) {
+            this._jsPlumb.instance.continuousAnchorFactory.clear(this.elementId);
+            this.anchor = this._jsPlumb.instance.makeAnchor(anchorParams, this.elementId, _jsPlumb);
+            _updateAnchorClass();
+            this.anchor.bind("anchorChanged", function(currentAnchor) {
+                this.fire("anchorChanged", {endpoint:this, anchor:currentAnchor});
+                _updateAnchorClass();
+            }.bind(this));
+            if (!doNotRepaint)
+                this._jsPlumb.instance.repaint(this.elementId);
+            return this;
+        };
+
+        var anchorParamsToUse = params.anchor ? params.anchor : params.anchors ? params.anchors : (_jsPlumb.Defaults.Anchor || "Top");
+        this.setAnchor(anchorParamsToUse, true);
+
+        var internalHover = function(state) {
+          if (this.connections.length > 0) {
+              for (var i = 0; i < this.connections.length; i++)
+                  this.connections[i].setHover(state, false);
+          }
+          else
+            this.setHover(state);
+        }.bind(this);
+
+        this.bind("mouseover", function() { internalHover(true); });
+        this.bind("mouseout", function() { internalHover(false); });
+            
+        // ANCHOR MANAGER
+        if (!params._transient) // in place copies, for example, are transient.  they will never need to be retrieved during a paint cycle, because they dont move, and then they are deleted.
+            this._jsPlumb.instance.anchorManager.add(this, this.elementId);
+        
+        this.setEndpoint = function(ep) {
+
+            if (this.endpoint != null) {
+                this.endpoint.cleanup();
+                this.endpoint.destroy();
+            }
+
+            var _e = function(t, p) {
+                var rm = _jsPlumb.getRenderMode();
+                if (jsPlumb.Endpoints[rm][t]) return new jsPlumb.Endpoints[rm][t](p);
+                if (!_jsPlumb.Defaults.DoNotThrowErrors)
+                    throw { msg:"jsPlumb: unknown endpoint type '" + t + "'" };
+            };            
+
+            var endpointArgs = {
+                _jsPlumb:this._jsPlumb.instance,
+                cssClass:params.cssClass,
+                container:params.container,
+                tooltip:params.tooltip,
+                connectorTooltip:params.connectorTooltip,
+                endpoint:this
+            };
+
+            if (_ju.isString(ep)) 
+                this.endpoint = _e(ep, endpointArgs);
+            else if (_ju.isArray(ep)) {
+                endpointArgs = _ju.merge(ep[1], endpointArgs);
+                this.endpoint = _e(ep[0], endpointArgs);
+            }
+            else {
+                this.endpoint = ep.clone();
+            }
+
+            // assign a clone function using a copy of endpointArgs. this is used when a drag starts: the endpoint that was dragged is cloned,
+            // and the clone is left in its place while the original one goes off on a magical journey. 
+            // the copy is to get around a closure problem, in which endpointArgs ends up getting shared by
+            // the whole world.
+            //var argsForClone = jsPlumb.extend({}, endpointArgs);
+            this.endpoint.clone = function() {
+                // TODO this, and the code above, can be refactored to be more dry.
+                if (_ju.isString(ep)) 
+                    return _e(ep, endpointArgs);
+                else if (_ju.isArray(ep)) {
+                    endpointArgs = _ju.merge(ep[1], endpointArgs);
+                    return _e(ep[0], endpointArgs);
+                }
+            }.bind(this);
+
+            this.type = this.endpoint.type;
+        };
+         
+        this.setEndpoint(params.endpoint || _jsPlumb.Defaults.Endpoint || jsPlumb.Defaults.Endpoint || "Dot");
+
+        this.setPaintStyle(params.endpointStyle || params.paintStyle || params.style || _jsPlumb.Defaults.EndpointStyle || jsPlumb.Defaults.EndpointStyle, true);
+        this.setHoverPaintStyle(params.endpointHoverStyle || params.hoverPaintStyle || _jsPlumb.Defaults.EndpointHoverStyle || jsPlumb.Defaults.EndpointHoverStyle, true);
+        this._jsPlumb.paintStyleInUse = this.getPaintStyle();
+
+        jsPlumb.extend(this, params, typeParameters);
+
+        this.isSource = params.isSource || false;
+        this.isTemporarySource = params.isTemporarySource || false;
+        this.isTarget = params.isTarget || false;        
+        this._jsPlumb.maxConnections = params.maxConnections || _jsPlumb.Defaults.MaxConnections; // maximum number of connections this endpoint can be the source of.                
+        this.canvas = this.endpoint.canvas;
+        this.canvas._jsPlumb = this;
+
+        // add anchor class (need to do this on construction because we set anchor first)
+        this.addClass(_jsPlumb.endpointAnchorClassPrefix + "_" + this._jsPlumb.currentAnchorClass);	
+        jsPlumbAdapter.addClass(this.element, _jsPlumb.endpointAnchorClassPrefix + "_" + this._jsPlumb.currentAnchorClass);
+
+        this.connections = params.connections || [];
+        this.connectorPointerEvents = params["connector-pointer-events"];
+        
+        this.scope = params.scope || _jsPlumb.getDefaultScope();        
+        this.timestamp = null;
+        this.reattachConnections = params.reattach || _jsPlumb.Defaults.ReattachConnections;
+        this.connectionsDetachable = _jsPlumb.Defaults.ConnectionsDetachable;
+        if (params.connectionsDetachable === false || params.detachable === false)
+            this.connectionsDetachable = false;
+        this.dragAllowedWhenFull = params.dragAllowedWhenFull !== false;
+        
+        if (params.onMaxConnections)
+            this.bind("maxConnections", params.onMaxConnections);        
+        
+        //
+        // add a connection. not part of public API.
+        //
+        this.addConnection = function(connection) {
+            this.connections.push(connection);                  
+            this[(this.connections.length > 0 ? "add" : "remove") + "Class"](_jsPlumb.endpointConnectedClass);       
+            this[(this.isFull() ? "add" : "remove") + "Class"](_jsPlumb.endpointFullClass); 
+        };	
+
+        this.detachFromConnection = function(connection, idx, doNotCleanup) {
+            idx = idx == null ? findConnectionIndex(connection, this) : idx;
+            if (idx >= 0) {
+                this.connections.splice(idx, 1);
+                this[(this.connections.length > 0 ? "add" : "remove") + "Class"](_jsPlumb.endpointConnectedClass);       
+                this[(this.isFull() ? "add" : "remove") + "Class"](_jsPlumb.endpointFullClass);
+            }
+            
+            if (!doNotCleanup && this._deleteOnDetach && this.connections.length === 0) {
+                _jsPlumb.deleteObject({
+                    endpoint:this,
+                    fireEvent:false,
+                    deleteAttachedObjects:false
+                });
+            }
+        };
+
+        this.detach = function(connection, ignoreTarget, forceDetach, fireEvent, originalEvent, endpointBeingDeleted, connectionIndex) {
+
+            var idx = connectionIndex == null ? findConnectionIndex(connection, this) : connectionIndex,
+                actuallyDetached = false;
+                fireEvent = (fireEvent !== false);
+
+            if (idx >= 0) {		                
+
+                if (forceDetach || connection._forceDetach || (connection.isDetachable() && connection.isDetachAllowed(connection) && this.isDetachAllowed(connection) && _jsPlumb.checkCondition("beforeDetach", connection) )) {
+
+                    _jsPlumb.deleteObject({
+                        connection:connection, 
+                        fireEvent:(!ignoreTarget && fireEvent), 
+                        originalEvent:originalEvent,
+                        deleteAttachedObjects:false
+                    });
+                    actuallyDetached = true;                       
+                }
+            }
+            return actuallyDetached;
+        };	
+
+        this.detachAll = function(fireEvent, originalEvent) {
+            while (this.connections.length > 0) {
+                // TODO this could pass the index in to the detach method to save some time (index will always be zero in this while loop)
+                this.detach(this.connections[0], false, true, fireEvent !== false, originalEvent, this, 0);
+            }
+            return this;
+        };                
+        this.detachFrom = function(targetEndpoint, fireEvent, originalEvent) {
+            var c = [];
+            for ( var i = 0; i < this.connections.length; i++) {
+                if (this.connections[i].endpoints[1] == targetEndpoint || this.connections[i].endpoints[0] == targetEndpoint) {
+                    c.push(this.connections[i]);
+                }
+            }
+            for ( var j = 0; j < c.length; j++) {
+                this.detach(c[j], false, true, fireEvent, originalEvent);				
+            }
+            return this;
+        };	        
+        
+        this.getElement = function() {
+            return this.element;
+        };		
+                 
+        this.setElement = function(el) {
+            var parentId = this._jsPlumb.instance.getId(el),
+                curId = this.elementId;
+            // remove the endpoint from the list for the current endpoint's element
+            _ju.removeWithFunction(params.endpointsByElement[this.elementId], function(e) {
+                return e.id == this.id;
+            }.bind(this));
+            this.element = jsPlumb.getDOMElement(el);
+            this.elementId = _jsPlumb.getId(this.element);                         
+            _jsPlumb.anchorManager.rehomeEndpoint(this, curId, this.element);
+            _jsPlumb.dragManager.endpointAdded(this.element);            
+            _ju.addToList(params.endpointsByElement, parentId, this);            
+            return this;
+        };
+                
+        /**
+         * private but must be exposed.
+         */
+        this.makeInPlaceCopy = function() {
+            var loc = this.anchor.getCurrentLocation({element:this}),
+                o = this.anchor.getOrientation(this),
+                acc = this.anchor.getCssClass(),
+                inPlaceAnchor = {
+                    bind:function() { },
+                    compute:function() { return [ loc[0], loc[1] ]; },
+                    getCurrentLocation : function() { return [ loc[0], loc[1] ]; },
+                    getOrientation:function() { return o; },
+                    getCssClass:function() { return acc; }
+                };
+
+            return _newEndpoint( { 
+                dropOptions:params.dropOptions,
+                anchor : inPlaceAnchor, 
+                source : this.element, 
+                paintStyle : this.getPaintStyle(), 
+                endpoint : params.hideOnDrag ? "Blank" : this.endpoint,
+                _transient:true,
+                scope:this.scope
+            });
+        };
+        
+        /**
+         * returns a connection from the pool; used when dragging starts.  just gets the head of the array if it can.
+         */
+        this.connectorSelector = function() {
+            var candidate = this.connections[0];
+            if (this.isTarget && candidate) return candidate;
+            else {
+                return (this.connections.length < this._jsPlumb.maxConnections) || this._jsPlumb.maxConnections == -1 ? null : candidate;
+            }
+        };        
+        
+        this.setStyle = this.setPaintStyle;        
+        
+        this.paint = function(params) {
+            params = params || {};
+            var timestamp = params.timestamp, recalc = !(params.recalc === false);								
+            if (!timestamp || this.timestamp !== timestamp) {						
+
+                var info = _jsPlumb.updateOffset({ elId:this.elementId, timestamp:timestamp });
+
+                var xy = params.offset ? params.offset.o : info.o;
+                if(xy != null) {
+                    var ap = params.anchorPoint,connectorPaintStyle = params.connectorPaintStyle;
+                    if (ap == null) {
+                        var wh = params.dimensions || info.s,                       
+                            anchorParams = { xy : [ xy.left, xy.top ], wh : wh, element : this, timestamp : timestamp };
+                        if (recalc && this.anchor.isDynamic && this.connections.length > 0) {
+                            var c = findConnectionToUseForDynamicAnchor(this, params.elementWithPrecedence),
+                                oIdx = c.endpoints[0] == this ? 1 : 0,
+                                oId = oIdx === 0 ? c.sourceId : c.targetId,
+                                oInfo = _jsPlumb.getCachedData(oId),
+                                oOffset = oInfo.o, oWH = oInfo.s;
+                            anchorParams.txy = [ oOffset.left, oOffset.top ];
+                            anchorParams.twh = oWH;
+                            anchorParams.tElement = c.endpoints[oIdx];
+                        }
+                        ap = this.anchor.compute(anchorParams);
+                    }
+                                        
+                    this.endpoint.compute(ap, this.anchor.getOrientation(this), this._jsPlumb.paintStyleInUse, connectorPaintStyle || this.paintStyleInUse);
+                    this.endpoint.paint(this._jsPlumb.paintStyleInUse, this.anchor);					
+                    this.timestamp = timestamp;
+
+                    // paint overlays
+                    for ( var i = 0; i < this._jsPlumb.overlays.length; i++) {
+                        var o = this._jsPlumb.overlays[i];
+                        if (o.isVisible()) { 
+                            this._jsPlumb.overlayPlacements[i] = o.draw(this.endpoint, this._jsPlumb.paintStyleInUse);
+                            o.paint(this._jsPlumb.overlayPlacements[i]);    
+                        }
+                    }
+                }
+            }
+        };
+
+        this.repaint = this.paint; 
+
+        var draggingInitialised = false;
+        this.initDraggable = function() {
+
+            // is this a connection source? we make it draggable and have the
+            // drag listener maintain a connection with a floating endpoint.
+            if (!draggingInitialised && jsPlumb.isDragSupported(this.element)) {
+                var placeholderInfo = { id:null, element:null },
+                    jpc = null,
+                    existingJpc = false,
+                    existingJpcParams = null,
+                    _dragHandler = _makeConnectionDragHandler(placeholderInfo, _jsPlumb),
+                    dragOptions = params.dragOptions || {},
+                    defaultOpts = {},
+                    startEvent = jsPlumb.dragEvents.start,
+                    stopEvent = jsPlumb.dragEvents.stop,
+                    dragEvent = jsPlumb.dragEvents.drag;
+
+                var start = function() {    
+                // drag might have started on an endpoint that is not actually a source, but which has
+                // one or more connections.
+                    jpc = this.connectorSelector();
+                    var _continue = true;
+                    // if not enabled, return
+                    if (!this.isEnabled()) _continue = false;
+                    // if no connection and we're not a source - or temporarily a source, as is the case with makeSource - return.
+                    if (jpc == null && !this.isSource && !this.isTemporarySource) _continue = false;
+                    // otherwise if we're full and not allowed to drag, also return false.
+                    if (this.isSource && this.isFull() && !this.dragAllowedWhenFull) _continue = false;
+                    // if the connection was setup as not detachable or one of its endpoints
+                    // was setup as connectionsDetachable = false, or Defaults.ConnectionsDetachable
+                    // is set to false...
+                    if (jpc != null && !jpc.isDetachable()) _continue = false;
+
+                    if (_continue === false) {
+                        // this is for mootools and yui. returning false from this causes jquery to stop drag.
+                        // the events are wrapped in both mootools and yui anyway, but i don't think returning
+                        // false from the start callback would stop a drag.
+                        if (_jsPlumb.stopDrag) _jsPlumb.stopDrag(this.canvas);
+                        _dragHandler.stopDrag();
+                        return false;
+                    }
+
+                    // clear hover for all connections for this endpoint before continuing.
+                    for (var i = 0; i < this.connections.length; i++)
+                        this.connections[i].setHover(false);
+
+                    this.addClass("endpointDrag");
+                    _jsPlumb.setConnectionBeingDragged(true);
+
+                    // if we're not full but there was a connection, make it null. we'll create a new one.
+                    if (jpc && !this.isFull() && this.isSource) jpc = null;
+
+                    _jsPlumb.updateOffset( { elId : this.elementId });
+                    inPlaceCopy = this.makeInPlaceCopy();
+                    inPlaceCopy.referenceEndpoint = this;
+                    inPlaceCopy.paint();                                                                
+                    
+                    _makeDraggablePlaceholder(placeholderInfo, _jsPlumb);
+                    
+                    // set the offset of this div to be where 'inPlaceCopy' is, to start with.
+                    // TODO merge this code with the code in both Anchor and FloatingAnchor, because it
+                    // does the same stuff.
+                    var ipcoel = _gel(inPlaceCopy.canvas),
+                        ipco = jsPlumbAdapter.getOffset(ipcoel, this._jsPlumb.instance),                        
+                        canvasElement = _gel(this.canvas);                               
+                        
+                    jsPlumbAdapter.setPosition(placeholderInfo.element, ipco);
+                    
+                    // when using makeSource and a parent, we first draw the source anchor on the source element, then
+                    // move it to the parent.  note that this happens after drawing the placeholder for the
+                    // first time.
+                    if (this.parentAnchor) this.anchor = _jsPlumb.makeAnchor(this.parentAnchor, this.elementId, _jsPlumb);
+                    
+                    // store the id of the dragging div and the source element. the drop function will pick these up.                   
+                    _jsPlumb.setAttribute(this.canvas, "dragId", placeholderInfo.id);
+                    _jsPlumb.setAttribute(this.canvas, "elId", this.elementId);
+
+                    this._jsPlumb.floatingEndpoint = _makeFloatingEndpoint(this.getPaintStyle(), this.anchor, this.endpoint, this.canvas, placeholderInfo.element, _jsPlumb, _newEndpoint, this.scope);
+                    // TODO we should not know about DOM here. make the library adapter do this (or the 
+                        // dom adapter)
+                    this.canvas.style.visibility = "hidden";            
+                    
+                    if (jpc == null) {                                                                                                                                                         
+                        this.anchor.locked = true;
+                        this.setHover(false, false);                        
+                        // create a connection. one end is this endpoint, the other is a floating endpoint.                    
+                        jpc = _newConnection({
+                            sourceEndpoint : this,
+                            targetEndpoint : this._jsPlumb.floatingEndpoint,
+                            source : this.endpointWillMoveTo || this.element,  // for makeSource with parent option.  ensure source element is represented correctly.
+                            target : placeholderInfo.element,
+                            anchors : [ this.anchor, this._jsPlumb.floatingEndpoint.anchor ],
+                            paintStyle : params.connectorStyle, // this can be null. Connection will use the default.
+                            hoverPaintStyle:params.connectorHoverStyle,
+                            connector : params.connector, // this can also be null. Connection will use the default.
+                            overlays : params.connectorOverlays,
+                            type:this.connectionType,
+                            cssClass:this.connectorClass,
+                            hoverClass:this.connectorHoverClass
+                        });
+                        //jpc.pending = true; // mark this connection as not having been established.
+                        jpc.addClass(_jsPlumb.draggingClass);
+                        this._jsPlumb.floatingEndpoint.addClass(_jsPlumb.draggingClass);
+                        // fire an event that informs that a connection is being dragged
+                        _jsPlumb.fire("connectionDrag", jpc);
+
+                    } else {
+                        existingJpc = true;
+                        jpc.setHover(false);
+                        // new anchor idx
+                        var anchorIdx = jpc.endpoints[0].id == this.id ? 0 : 1;
+                        this.detachFromConnection(jpc, null, true);                         // detach from the connection while dragging is occurring. but dont cleanup automatically.
+                                                
+                        // store the original scope (issue 57)
+                        var dragScope = _jsPlumb.getDragScope(canvasElement);
+                        _jsPlumb.setAttribute(this.canvas, "originalScope", dragScope);
+                        // now we want to get this endpoint's DROP scope, and set it for now: we can only be dropped on drop zones
+                        // that have our drop scope (issue 57).
+                        var dropScope = _jsPlumb.getDropScope(canvasElement);
+                        _jsPlumb.setDragScope(canvasElement, dropScope);
+                        //*/
+
+                        // fire an event that informs that a connection is being dragged. we do this before
+                        // replacing the original target with the floating element info.
+                        _jsPlumb.fire("connectionDrag", jpc);
+                
+                        // now we replace ourselves with the temporary div we created above:
+                        if (anchorIdx === 0) {
+                            existingJpcParams = [ jpc.source, jpc.sourceId, canvasElement, dragScope ];
+                            jpc.source = placeholderInfo.element;
+                            jpc.sourceId = placeholderInfo.id;
+                        } else {
+                            existingJpcParams = [ jpc.target, jpc.targetId, canvasElement, dragScope ];
+                            jpc.target = placeholderInfo.element;
+                            jpc.targetId = placeholderInfo.id;
+                        }
+
+                        // lock the other endpoint; if it is dynamic it will not move while the drag is occurring.
+                        jpc.endpoints[anchorIdx === 0 ? 1 : 0].anchor.locked = true;
+                        // store the original endpoint and assign the new floating endpoint for the drag.
+                        jpc.suspendedEndpoint = jpc.endpoints[anchorIdx];
+                        
+                        // PROVIDE THE SUSPENDED ELEMENT, BE IT A SOURCE OR TARGET (ISSUE 39)
+                        jpc.suspendedElement = jpc.endpoints[anchorIdx].getElement();
+                        jpc.suspendedElementId = jpc.endpoints[anchorIdx].elementId;
+                        jpc.suspendedElementType = anchorIdx === 0 ? "source" : "target";
+                        
+                        jpc.suspendedEndpoint.setHover(false);
+                        this._jsPlumb.floatingEndpoint.referenceEndpoint = jpc.suspendedEndpoint;
+                        jpc.endpoints[anchorIdx] = this._jsPlumb.floatingEndpoint;
+
+                        jpc.addClass(_jsPlumb.draggingClass);
+                        this._jsPlumb.floatingEndpoint.addClass(_jsPlumb.draggingClass);                    
+                    }
+                
+                    // register it and register connection on it.
+                    _jsPlumb.floatingConnections[placeholderInfo.id] = jpc;
+                    _jsPlumb.anchorManager.addFloatingConnection(placeholderInfo.id, jpc);               
+                    // only register for the target endpoint; we will not be dragging the source at any time
+                    // before this connection is either discarded or made into a permanent connection.
+                    _ju.addToList(params.endpointsByElement, placeholderInfo.id, this._jsPlumb.floatingEndpoint);
+                    // tell jsplumb about it
+                    _jsPlumb.currentlyDragging = true;
+                }.bind(this);
+
+                var stop = function() {
+                    _jsPlumb.setConnectionBeingDragged(false);
+                    // if no endpoints, jpc already cleaned up.
+                    if (jpc && jpc.endpoints != null) {
+                        // get the actual drop event (decode from library args to stop function)
+                        var originalEvent = _jsPlumb.getDropEvent(arguments);
+                        // unlock the other endpoint (if it is dynamic, it would have been locked at drag start)
+                        var idx = _jsPlumb.getFloatingAnchorIndex(jpc);
+                        jpc.endpoints[idx === 0 ? 1 : 0].anchor.locked = false;
+                        // TODO: Dont want to know about css classes inside jsplumb, ideally.
+                        jpc.removeClass(_jsPlumb.draggingClass);
+
+                        // if we have the floating endpoint then the connection has not been dropped
+                        // on another endpoint.  If it is a new connection we throw it away. If it is an
+                        // existing connection we check to see if we should reattach it, throwing it away
+                        // if not.
+                        if (this._jsPlumb && (jpc.deleteConnectionNow || jpc.endpoints[idx] == this._jsPlumb.floatingEndpoint)) {
+                            // 6a. if the connection was an existing one...
+                            if (existingJpc && jpc.suspendedEndpoint) {
+                                // fix for issue35, thanks Sylvain Gizard: when firing the detach event make sure the
+                                // floating endpoint has been replaced.
+                                if (idx === 0) {
+                                    jpc.source = existingJpcParams[0];
+                                    jpc.sourceId = existingJpcParams[1];
+                                } else {
+                                    jpc.target = existingJpcParams[0];
+                                    jpc.targetId = existingJpcParams[1];
+                                }
+
+                                var fe = this._jsPlumb.floatingEndpoint; // store for later removal.
+                                // restore the original scope (issue 57)
+                                _jsPlumb.setDragScope(existingJpcParams[2], existingJpcParams[3]);
+                                jpc.endpoints[idx] = jpc.suspendedEndpoint;
+                                // IF the connection should be reattached, or the other endpoint refuses detach, then
+                                // reset the connection to its original state
+                                if (jpc.isReattach() || jpc._forceReattach || jpc._forceDetach || !jpc.endpoints[idx === 0 ? 1 : 0].detach(jpc, false, false, true, originalEvent)) {
+                                    jpc.setHover(false);
+                                    jpc._forceDetach = null;
+                                    jpc._forceReattach = null;
+                                    this._jsPlumb.floatingEndpoint.detachFromConnection(jpc);
+                                    jpc.suspendedEndpoint.addConnection(jpc);
+                                    _jsPlumb.repaint(existingJpcParams[1]);
+                                }
+                                else
+                                    _jsPlumb.deleteObject({endpoint:fe});
+                            }
+                        }
+
+                        // remove the element associated with the floating endpoint
+                        // (and its associated floating endpoint and visual artefacts)
+                        _jsPlumb.remove(placeholderInfo.element, false);
+                        // remove the inplace copy
+                        _jsPlumb.deleteObject({endpoint:inPlaceCopy});
+
+                        // makeTargets sets this flag, to tell us we have been replaced and should delete ourself.
+                        if (this.deleteAfterDragStop) {
+                            _jsPlumb.deleteObject({endpoint:this});
+                        }
+                        else {
+                            if (this._jsPlumb) {
+                                this._jsPlumb.floatingEndpoint = null;
+                                // repaint this endpoint.
+                                // make our canvas visible (TODO: hand off to library; we should not know about DOM)
+                                this.canvas.style.visibility = "visible";
+                                // unlock our anchor
+                                this.anchor.locked = false;
+                                this.paint({recalc:false});
+                            }
+                        }
+
+                        // although the connection is no longer valid, there are use cases where this is useful.
+                        _jsPlumb.fire("connectionDragStop", jpc, originalEvent);
+
+                        // tell jsplumb that dragging is finished.
+                        _jsPlumb.currentlyDragging = false;
+
+                        jpc = null;
+                    }
+
+                }.bind(this);
+
+                dragOptions = jsPlumb.extend(defaultOpts, dragOptions);
+                dragOptions.scope = this.scope || dragOptions.scope;
+                dragOptions[startEvent] = _ju.wrap(dragOptions[startEvent], start, false);
+                // extracted drag handler function so can be used by makeSource
+                dragOptions[dragEvent] = _ju.wrap(dragOptions[dragEvent], _dragHandler.drag);
+                dragOptions[stopEvent] = _ju.wrap(dragOptions[stopEvent], stop);
+
+                dragOptions.canDrag = function() {
+                    return this.isSource || this.isTemporarySource || (this.isTarget && this.connections.length > 0);
+                }.bind(this);
+
+                _jsPlumb.initDraggable(this.canvas, dragOptions, "internal");
+
+                this.canvas._jsPlumbRelatedElement = this.element;
+
+                draggingInitialised = true;
+            }
+        };
+
+        // if marked as source or target at create time, init the dragging.
+        if (this.isSource || this.isTarget || this.isTemporarySource)
+            this.initDraggable();
+
+
+        // pulled this out into a function so we can reuse it for the inPlaceCopy canvas; you can now drop detached connections
+        // back onto the endpoint you detached it from.
+        var _initDropTarget = function(canvas, forceInit, isTransient, endpoint) {
+
+            if ((this.isTarget || forceInit) && jsPlumb.isDropSupported(this.element)) {
+                var dropOptions = params.dropOptions || _jsPlumb.Defaults.DropOptions || jsPlumb.Defaults.DropOptions;
+                dropOptions = jsPlumb.extend( {}, dropOptions);
+                dropOptions.scope = dropOptions.scope || this.scope;
+                var dropEvent = jsPlumb.dragEvents.drop,
+                    overEvent = jsPlumb.dragEvents.over,
+                    outEvent = jsPlumb.dragEvents.out,
+                    _ep = this,
+                    drop = _jsPlumb.EndpointDropHandler({
+                        getEndpoint:function() { return _ep; },
+                        jsPlumb:_jsPlumb,
+                        enabled:function() {
+                            return endpoint != null ? endpoint.isEnabled() : true;
+                        },
+                        isFull:function() {
+                            return endpoint.isFull();
+                        },
+                        element:this.element,
+                        elementId:this.elementId,
+                        isSource:this.isSource,
+                        isTarget:this.isTarget,
+                        addClass:function(clazz) {
+                            _ep.addClass(clazz);
+                        },
+                        removeClass:function(clazz) {
+                            _ep.removeClass(clazz);
+                        },
+                        isDropAllowed:function() {
+                            return _ep.isDropAllowed.apply(_ep, arguments);
+                        }
+                    });
+                
+                dropOptions[dropEvent] = _ju.wrap(dropOptions[dropEvent], drop);
+                dropOptions[overEvent] = _ju.wrap(dropOptions[overEvent], function() {					
+                    var draggable = jsPlumb.getDragObject(arguments),
+                        id = _jsPlumb.getAttribute(jsPlumb.getDOMElement(draggable), "dragId"),
+                        _jpc = _jsPlumb.floatingConnections[id];
+                        
+                    if (_jpc != null) {								
+                        var idx = _jsPlumb.getFloatingAnchorIndex(_jpc);
+                        // here we should fire the 'over' event if we are a target and this is a new connection,
+                        // or we are the same as the floating endpoint.								
+                        var _cont = (this.isTarget && idx !== 0) || (_jpc.suspendedEndpoint && this.referenceEndpoint && this.referenceEndpoint.id == _jpc.suspendedEndpoint.id);
+                        if (_cont) {
+                            var bb = _jsPlumb.checkCondition("checkDropAllowed", { 
+                                sourceEndpoint:_jpc.endpoints[idx], 
+                                targetEndpoint:this,
+                                connection:_jpc
+                            }); 
+                            this[(bb ? "add" : "remove") + "Class"](_jsPlumb.endpointDropAllowedClass);
+                            this[(bb ? "remove" : "add") + "Class"](_jsPlumb.endpointDropForbiddenClass);
+                            _jpc.endpoints[idx].anchor.over(this.anchor, this);
+                        }
+                    }						
+                }.bind(this));	
+
+                dropOptions[outEvent] = _ju.wrap(dropOptions[outEvent], function() {					
+                    var draggable = jsPlumb.getDragObject(arguments),
+                        id = draggable == null ? null : _jsPlumb.getAttribute( jsPlumb.getDOMElement(draggable), "dragId"),
+                        _jpc = id? _jsPlumb.floatingConnections[id] : null;
+                        
+                    if (_jpc != null) {
+                        var idx = _jsPlumb.getFloatingAnchorIndex(_jpc);
+                        var _cont = (this.isTarget && idx !== 0) || (_jpc.suspendedEndpoint && this.referenceEndpoint && this.referenceEndpoint.id == _jpc.suspendedEndpoint.id);
+                        if (_cont) {
+                            this.removeClass(_jsPlumb.endpointDropAllowedClass);
+                            this.removeClass(_jsPlumb.endpointDropForbiddenClass);
+                            _jpc.endpoints[idx].anchor.out();
+                        }
+                    }
+                }.bind(this));
+
+                _jsPlumb.initDroppable(canvas, dropOptions, "internal", isTransient);
+            }
+        }.bind(this);
+        
+        // initialise the endpoint's canvas as a drop target.  this will be ignored if the endpoint is not a target or drag is not supported.
+        if (!this.anchor.isFloating)
+            _initDropTarget(_gel(this.canvas), true, !(params._transient || this.anchor.isFloating), this);
+
+        // finally, set type if it was provided
+         if (params.type)
+            this.addType(params.type, params.data, _jsPlumb.isSuspendDrawing());
+
+        return this;        					
+    };
+
+    jsPlumbUtil.extend(jsPlumb.Endpoint, OverlayCapableJsPlumbUIComponent, {
+        getTypeDescriptor : function() { return "endpoint"; },        
+        isVisible : function() { return this._jsPlumb.visible; },
+        setVisible : function(v, doNotChangeConnections, doNotNotifyOtherEndpoint) {
+            this._jsPlumb.visible = v;
+            if (this.canvas) this.canvas.style.display = v ? "block" : "none";
+            this[v ? "showOverlays" : "hideOverlays"]();
+            if (!doNotChangeConnections) {
+                for (var i = 0; i < this.connections.length; i++) {
+                    this.connections[i].setVisible(v);
+                    if (!doNotNotifyOtherEndpoint) {
+                        var oIdx = this === this.connections[i].endpoints[0] ? 1 : 0;
+                        // only change the other endpoint if this is its only connection.
+                        if (this.connections[i].endpoints[oIdx].connections.length == 1) this.connections[i].endpoints[oIdx].setVisible(v, true, true);
+                    }
+                }
+            }
+        },
+        getAttachedElements : function() {
+            return this.connections;
+        },
+        applyType : function(t) {
+            this.setPaintStyle(t.endpointStyle || t.paintStyle);
+            this.setHoverPaintStyle(t.endpointHoverStyle || t.hoverPaintStyle);
+            if (t.maxConnections != null) this._jsPlumb.maxConnections = t.maxConnections;
+            if (t.scope) this.scope = t.scope;
+            jsPlumb.extend(this, t, typeParameters);
+            if (t.anchor) {
+                this.anchor = this._jsPlumb.instance.makeAnchor(t.anchor);
+            }
+            if (t.cssClass != null && this.canvas) this._jsPlumb.instance.addClass(this.canvas, t.cssClass);
+        },
+        isEnabled : function() { return this._jsPlumb.enabled; },
+        setEnabled : function(e) { this._jsPlumb.enabled = e; },
+        cleanup : function() {            
+            jsPlumbAdapter.removeClass(this.element, this._jsPlumb.instance.endpointAnchorClassPrefix + "_" + this._jsPlumb.currentAnchorClass);            
+            this.anchor = null;
+            this.endpoint.cleanup();
+            this.endpoint.destroy();
+            this.endpoint = null;
+            // drag/drop
+            var i = jsPlumb.getElementObject(this.canvas);              
+            this._jsPlumb.instance.destroyDraggable(i, "internal");
+            this._jsPlumb.instance.destroyDroppable(i, "internal");
+        },
+        setHover : function(h) {
+            if (this.endpoint && this._jsPlumb && !this._jsPlumb.instance.isConnectionBeingDragged())
+                this.endpoint.setHover(h);            
+        },
+        isFull : function() {
+            return !(this.isFloating() || this._jsPlumb.maxConnections < 1 || this.connections.length < this._jsPlumb.maxConnections);              
+        },
+        /**
+         * private but needs to be exposed.
+         */
+        isFloating : function() {
+            return this.anchor != null && this.anchor.isFloating;
+        },
+        isConnectedTo : function(endpoint) {
+            var found = false;
+            if (endpoint) {
+                for ( var i = 0; i < this.connections.length; i++) {
+                    if (this.connections[i].endpoints[1] == endpoint || this.connections[i].endpoints[0] == endpoint) {
+                        found = true;
+                        break;
+                    }
+                }
+            }
+            return found;
+        },
+        getConnectionCost : function() { return this._jsPlumb.connectionCost; },
+        setConnectionCost : function(c) {
+            this._jsPlumb.connectionCost = c; 
+        },
+        areConnectionsDirected : function() { return this._jsPlumb.connectionsDirected; },
+        setConnectionsDirected : function(b) { this._jsPlumb.connectionsDirected = b; },
+        setElementId : function(_elId) {
+            this.elementId = _elId;
+            this.anchor.elementId = _elId;
+        },        
+        setReferenceElement : function(_el) {
+            this.element = jsPlumb.getDOMElement(_el);
+        },
+        setDragAllowedWhenFull : function(allowed) {
+            this.dragAllowedWhenFull = allowed;
+        },
+        equals : function(endpoint) {
+            return this.anchor.equals(endpoint.anchor);
+        },
+        getUuid : function() {
+            return this._jsPlumb.uuid;
+        },
+        computeAnchor : function(params) {
+            return this.anchor.compute(params);
+        }
+    });
+
+    jsPlumbInstance.prototype.EndpointDropHandler = function(dhParams) {
+        return function(e) {
+
+            var _jsPlumb = dhParams.jsPlumb;
+
+            // remove the classes that are added dynamically. drop is neither forbidden nor allowed now that
+            // the drop is finishing.
+            // makeTarget:probably keep these. 'this' would refer to the DOM element though
+            dhParams.removeClass(_jsPlumb.endpointDropAllowedClass);
+            dhParams.removeClass(_jsPlumb.endpointDropForbiddenClass);
+
+            var originalEvent = _jsPlumb.getDropEvent(arguments),
+                draggable = _jsPlumb.getDOMElement(_jsPlumb.getDragObject(arguments)),
+                id = _jsPlumb.getAttribute(draggable, "dragId"),
+                elId = _jsPlumb.getAttribute(draggable, "elId"),
+                scope = _jsPlumb.getAttribute(draggable, "originalScope"),
+                jpc = _jsPlumb.floatingConnections[id];
+
+            if (jpc == null) return;
+            var _ep = dhParams.getEndpoint(jpc);
+
+            if (dhParams.onDrop) dhParams.onDrop(jpc);
+
+            // if this is a drop back where the connection came from, mark it force rettach and
+            // return; the stop handler will reattach. without firing an event.
+            var redrop = jpc.suspendedEndpoint && (jpc.suspendedEndpoint.id == _ep.id ||
+                _ep.referenceEndpoint && jpc.suspendedEndpoint.id == _ep.referenceEndpoint.id) ;
+            if (redrop) {
+                jpc._forceReattach = true;
+                jpc.setHover(false);
+                return;
+            }
+
+            var idx = _jsPlumb.getFloatingAnchorIndex(jpc);
+
+            // restore the original scope if necessary (issue 57)
+            if (scope) _jsPlumb.setDragScope(draggable, scope);
+
+            // if the target of the drop is full, fire an event (we abort below)
+            // makeTarget: keep.
+            if (dhParams.isFull(e)) {
+                _ep.fire("maxConnections", {
+                    endpoint:this,
+                    connection:jpc,
+                    maxConnections:_ep._jsPlumb.maxConnections
+                }, originalEvent);
+            }
+
+            if (!dhParams.isFull() && !(idx === 0 && !dhParams.isSource) && !(idx == 1 && !dhParams.isTarget) && dhParams.enabled()) {
+                var _doContinue = true;
+                // if this is an existing connection and detach is not allowed we won't continue. The connection's
+                // endpoints have been reinstated; everything is back to how it was.
+                if (jpc.suspendedEndpoint && jpc.suspendedEndpoint.id != _ep.id) {
+
+                    if (!jpc.isDetachAllowed(jpc) || !jpc.endpoints[idx].isDetachAllowed(jpc) || !jpc.suspendedEndpoint.isDetachAllowed(jpc) || !_jsPlumb.checkCondition("beforeDetach", jpc))
+                        _doContinue = false;
+                }
+
+                // these have to be set before testing for beforeDrop.
+                if (idx === 0) {
+                    jpc.source = dhParams.element;
+                    jpc.sourceId = dhParams.elementId;
+                } else {
+                    jpc.target = dhParams.element;
+                    jpc.targetId = dhParams.elementId;
+                }
+
+// ------------ wrap the execution path in a function so we can support asynchronous beforeDrop
+
+                var continueFunction = function() {
+                    // remove this jpc from the current endpoint, which is a floating endpoint that we will
+                    // subsequently discard.
+                    jpc.endpoints[idx].detachFromConnection(jpc);
+
+                    // if there's a suspended endpoint, detach it from the connection.
+                    if (jpc.suspendedEndpoint) jpc.suspendedEndpoint.detachFromConnection(jpc);
+                    // TODO why?
+
+                    jpc.endpoints[idx] = _ep;
+                    _ep.addConnection(jpc);
+
+                    // copy our parameters in to the connection:
+                    var params = _ep.getParameters();
+                    for (var aParam in params)
+                        jpc.setParameter(aParam, params[aParam]);
+
+                    if (!jpc.suspendedEndpoint) {
+                        // if not an existing connection and
+                        if (params.draggable)
+                            _jsPlumb.initDraggable(this.element, dragOptions, "internal", _jsPlumb);
+                    }
+                    else {
+                        var suspendedElementId = jpc.suspendedEndpoint.elementId;
+                        _jsPlumb.fireMoveEvent({
+                            index:idx,
+                            originalSourceId:idx === 0 ? suspendedElementId : jpc.sourceId,
+                            newSourceId:idx === 0 ? _ep.elementId : jpc.sourceId,
+                            originalTargetId:idx == 1 ? suspendedElementId : jpc.targetId,
+                            newTargetId:idx == 1 ? _ep.elementId : jpc.targetId,
+                            originalSourceEndpoint:idx === 0 ? jpc.suspendedEndpoint : jpc.endpoints[0],
+                            newSourceEndpoint:idx === 0 ? _ep : jpc.endpoints[0],
+                            originalTargetEndpoint:idx == 1 ? jpc.suspendedEndpoint : jpc.endpoints[1],
+                            newTargetEndpoint:idx == 1 ? _ep : jpc.endpoints[1],
+                            connection:jpc
+                        }, originalEvent);
+                    }
+
+                    if (idx == 1)
+                        _jsPlumb.anchorManager.updateOtherEndpoint(jpc.sourceId, jpc.suspendedElementId, jpc.targetId, jpc);
+                    else
+                        _jsPlumb.anchorManager.sourceChanged(jpc.suspendedEndpoint.elementId, jpc.sourceId, jpc);
+
+                    // when makeSource has uniqueEndpoint:true, we want to create connections with new endpoints
+                    // that are subsequently deleted. So makeSource sets `finalEndpoint`, which is the Endpoint to
+                    // which the connection should be attached. The `detachFromConnection` call below results in the
+                    // temporary endpoint being cleaned up.
+                    if (jpc.endpoints[0].finalEndpoint) {
+                        var _toDelete = jpc.endpoints[0];
+                        _toDelete.detachFromConnection(jpc);
+                        jpc.endpoints[0] = jpc.endpoints[0].finalEndpoint;
+                        jpc.endpoints[0].addConnection(jpc);
+                    }
+
+                    // finalise will inform the anchor manager and also add to
+                    // connectionsByScope if necessary.
+                    // TODO if this is not set to true, then dragging a connection's target to a new
+                    // target causes the connection to be forgotten. however if it IS set to true, then
+                    // the opposite happens: dragging by source causes the connection to get forgotten
+                    // about and then if you delete it jsplumb breaks.
+                    _jsPlumb.finaliseConnection(jpc, null, originalEvent/*, true*/);
+                    jpc.setHover(false);
+
+                }.bind(this);
+
+                var dontContinueFunction = function() {
+                    // otherwise just put it back on the endpoint it was on before the drag.
+                    if (jpc.suspendedEndpoint) {
+                        jpc.endpoints[idx] = jpc.suspendedEndpoint;
+                        jpc.setHover(false);
+                        jpc._forceDetach = true;
+                        if (idx === 0) {
+                            jpc.source = jpc.suspendedEndpoint.element;
+                            jpc.sourceId = jpc.suspendedEndpoint.elementId;
+                        } else {
+                            jpc.target = jpc.suspendedEndpoint.element;
+                            jpc.targetId = jpc.suspendedEndpoint.elementId;
+                        }
+                        jpc.suspendedEndpoint.addConnection(jpc);
+
+                        _jsPlumb.repaint(jpc.sourceId);
+                        jpc._forceDetach = false;
+                    }
+                };
+
+// --------------------------------------
+                // now check beforeDrop.  this will be available only on Endpoints that are setup to
+                // have a beforeDrop condition (although, secretly, under the hood all Endpoints and
+                // the Connection have them, because they are on jsPlumbUIComponent.  shhh!), because
+                // it only makes sense to have it on a target endpoint.
+                _doContinue = _doContinue && dhParams.isDropAllowed(jpc.sourceId, jpc.targetId, jpc.scope, jpc, _ep);// && jpc.pending;
+
+                if (_doContinue) {
+                    continueFunction();
+                }
+                else {
+                    dontContinueFunction();
+                }
+            }
+            _jsPlumb.currentlyDragging = false;
+        };
+    };
+})();
+
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the code for Connections.
+ *
+ * Copyright (c) 2010 - 2014 jsPlumb (hello@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://jsplumb.org
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+;(function() {
+    
+    "use strict";
+
+    var makeConnector = function(_jsPlumb, renderMode, connectorName, connectorArgs, forComponent) {
+            if (!_jsPlumb.Defaults.DoNotThrowErrors && jsPlumb.Connectors[renderMode][connectorName] == null)
+                    throw { msg:"jsPlumb: unknown connector type '" + connectorName + "'" };
+
+            return new jsPlumb.Connectors[renderMode][connectorName](connectorArgs, forComponent);
+        },
+        _makeAnchor = function(anchorParams, elementId, _jsPlumb) {
+            return (anchorParams) ? _jsPlumb.makeAnchor(anchorParams, elementId, _jsPlumb) : null;
+        };
+    
+    jsPlumb.Connection = function(params) {
+        var _newEndpoint = params.newEndpoint, _ju = jsPlumbUtil;
+
+        this.connector = null;
+        this.idPrefix = "_jsplumb_c_";
+        this.defaultLabelLocation = 0.5;
+        this.defaultOverlayKeys = ["Overlays", "ConnectionOverlays"];
+        // if a new connection is the result of moving some existing connection, params.previousConnection
+        // will have that Connection in it. listeners for the jsPlumbConnection event can look for that
+        // member and take action if they need to.
+        this.previousConnection = params.previousConnection;
+        this.source = jsPlumb.getDOMElement(params.source);
+        this.target = jsPlumb.getDOMElement(params.target);
+        // sourceEndpoint and targetEndpoint override source/target, if they are present. but 
+        // source is not overridden if the Endpoint has declared it is not the final target of a connection;
+        // instead we use the source that the Endpoint declares will be the final source element.
+        if (params.sourceEndpoint) this.source = params.sourceEndpoint.endpointWillMoveTo || params.sourceEndpoint.getElement();            
+        if (params.targetEndpoint) this.target = params.targetEndpoint.getElement();        
+
+        OverlayCapableJsPlumbUIComponent.apply(this, arguments);
+
+        this.sourceId = this._jsPlumb.instance.getId(this.source);
+        this.targetId = this._jsPlumb.instance.getId(this.target);
+        this.scope = params.scope; // scope may have been passed in to the connect call. if it wasn't, we will pull it from the source endpoint, after having initialised the endpoints.            
+        this.endpoints = [];
+        this.endpointStyles = [];
+            
+        var _jsPlumb = this._jsPlumb.instance;
+
+        _jsPlumb.manage(this.sourceId, this.source);
+        _jsPlumb.manage(this.targetId, this.target);
+
+        this._jsPlumb.visible = true;
+        this._jsPlumb.editable = params.editable === true;    
+        this._jsPlumb.params = {
+            cssClass:params.cssClass,
+            container:params.container,
+            "pointer-events":params["pointer-events"],
+            editorParams:params.editorParams
+        };   
+        this._jsPlumb.lastPaintedAt = null;
+        this.getDefaultType = function() {
+            return {
+                parameters:{},
+                scope:null,
+                detachable:this._jsPlumb.instance.Defaults.ConnectionsDetachable,
+                rettach:this._jsPlumb.instance.Defaults.ReattachConnections,
+                paintStyle:this._jsPlumb.instance.Defaults.PaintStyle || jsPlumb.Defaults.PaintStyle,
+                connector:this._jsPlumb.instance.Defaults.Connector || jsPlumb.Defaults.Connector,
+                hoverPaintStyle:this._jsPlumb.instance.Defaults.HoverPaintStyle || jsPlumb.Defaults.HoverPaintStyle,
+                overlays:this._jsPlumb.instance.Defaults.ConnectorOverlays || jsPlumb.Defaults.ConnectorOverlays
+            };
+        };
+
+	// listen to mouseover and mouseout events passed from the container delegate.
+        this.bind("mouseover", function() { this.setHover(true);}.bind(this));
+        this.bind("mouseout", function() { this.setHover(false);}.bind(this));
+        
+// INITIALISATION CODE			
+                            
+        // wrapped the main function to return null if no input given. this lets us cascade defaults properly.
+        
+        this.makeEndpoint = function(isSource, el, elId, ep) {
+            elId = elId ||  this._jsPlumb.instance.getId(el);
+            return this.prepareEndpoint(_jsPlumb, _newEndpoint, this, ep, isSource ? 0 : 1, params, el, elId);
+        };
+        
+        var eS = this.makeEndpoint(true, this.source, this.sourceId, params.sourceEndpoint),
+            eT = this.makeEndpoint(false, this.target, this.targetId, params.targetEndpoint);
+        
+        if (eS) _ju.addToList(params.endpointsByElement, this.sourceId, eS);
+        if (eT) _ju.addToList(params.endpointsByElement, this.targetId, eT);
+        // if scope not set, set it to be the scope for the source endpoint.
+        if (!this.scope) this.scope = this.endpoints[0].scope;
+                
+        // if explicitly told to (or not to) delete endpoints on detach, override endpoint's preferences
+        if (params.deleteEndpointsOnDetach != null) {
+            this.endpoints[0]._deleteOnDetach = params.deleteEndpointsOnDetach;
+            this.endpoints[1]._deleteOnDetach = params.deleteEndpointsOnDetach;
+        }
+        else {
+            // otherwise, unless the endpoints say otherwise, mark them for deletion.
+            if (!this.endpoints[0]._doNotDeleteOnDetach) this.endpoints[0]._deleteOnDetach = true;
+            if (!this.endpoints[1]._doNotDeleteOnDetach) this.endpoints[1]._deleteOnDetach = true;
+        }   
+                    
+        // TODO these could surely be refactored into some method that tries them one at a time until something exists
+        this.setConnector(this.endpoints[0].connector || 
+                          this.endpoints[1].connector || 
+                          params.connector || 
+                          _jsPlumb.Defaults.Connector || 
+                          jsPlumb.Defaults.Connector, true, true);
+
+        if (params.path)
+            this.connector.setPath(params.path);
+        
+        this.setPaintStyle(this.endpoints[0].connectorStyle || 
+                           this.endpoints[1].connectorStyle || 
+                           params.paintStyle || 
+                           _jsPlumb.Defaults.PaintStyle || 
+                           jsPlumb.Defaults.PaintStyle, true);
+                    
+        this.setHoverPaintStyle(this.endpoints[0].connectorHoverStyle || 
+                                this.endpoints[1].connectorHoverStyle || 
+                                params.hoverPaintStyle || 
+                                _jsPlumb.Defaults.HoverPaintStyle || 
+                                jsPlumb.Defaults.HoverPaintStyle, true);
+        
+        this._jsPlumb.paintStyleInUse = this.getPaintStyle();
+        
+        var _suspendedAt = _jsPlumb.getSuspendedAt();
+//*
+        if(!_jsPlumb.isSuspendDrawing()) {                    
+            // paint the endpoints
+            var myInfo = _jsPlumb.getCachedData(this.sourceId),
+                myOffset = myInfo.o, myWH = myInfo.s,
+                otherInfo = _jsPlumb.getCachedData(this.targetId),
+                otherOffset = otherInfo.o,
+                otherWH = otherInfo.s,
+                initialTimestamp = _suspendedAt || _jsPlumb.timestamp(),
+                anchorLoc = this.endpoints[0].anchor.compute( {
+                    xy : [ myOffset.left, myOffset.top ], wh : myWH, element : this.endpoints[0],
+                    elementId:this.endpoints[0].elementId,
+                    txy : [ otherOffset.left, otherOffset.top ], twh : otherWH, tElement : this.endpoints[1],
+                    timestamp:initialTimestamp
+                });
+
+            this.endpoints[0].paint( { anchorLoc : anchorLoc, timestamp:initialTimestamp });
+
+            anchorLoc = this.endpoints[1].anchor.compute( {
+                xy : [ otherOffset.left, otherOffset.top ], wh : otherWH, element : this.endpoints[1],
+                elementId:this.endpoints[1].elementId,				
+                txy : [ myOffset.left, myOffset.top ], twh : myWH, tElement : this.endpoints[0],
+                timestamp:initialTimestamp				
+            });
+            this.endpoints[1].paint({ anchorLoc : anchorLoc, timestamp:initialTimestamp });
+        }
+        //*/
+                                
+// END INITIALISATION CODE			
+        
+// DETACHABLE 				
+        this._jsPlumb.detachable = _jsPlumb.Defaults.ConnectionsDetachable;
+        if (params.detachable === false) this._jsPlumb.detachable = false;
+        if(this.endpoints[0].connectionsDetachable === false) this._jsPlumb.detachable = false;
+        if(this.endpoints[1].connectionsDetachable === false) this._jsPlumb.detachable = false;                
+// REATTACH
+        this._jsPlumb.reattach = params.reattach || this.endpoints[0].reattachConnections || this.endpoints[1].reattachConnections || _jsPlumb.Defaults.ReattachConnections;
+// COST + DIRECTIONALITY
+        // if cost not supplied, try to inherit from source endpoint
+        this._jsPlumb.cost = params.cost || this.endpoints[0].getConnectionCost();			        
+        this._jsPlumb.directed = params.directed;
+        // inherit directed flag if set no source endpoint
+        if (params.directed == null) this._jsPlumb.directed = this.endpoints[0].areConnectionsDirected();        
+// END COST + DIRECTIONALITY
+                    
+// PARAMETERS						
+        // merge all the parameters objects into the connection.  parameters set
+        // on the connection take precedence; then source endpoint params, then
+        // finally target endpoint params.
+        // TODO jsPlumb.extend could be made to take more than two args, and it would
+        // apply the second through nth args in order.
+        var _p = jsPlumb.extend({}, this.endpoints[1].getParameters());
+        jsPlumb.extend(_p, this.endpoints[0].getParameters());
+        jsPlumb.extend(_p, this.getParameters());
+        this.setParameters(_p);
+// END PARAMETERS
+
+// PAINTING
+                  
+        // the very last thing we do is apply types, if there are any.
+        var _types = [params.type, this.endpoints[0].connectionType, this.endpoints[1].connectionType ].join(" ");
+        if (/[^\s]/.test(_types))
+            this.addType(_types, params.data, true);
+        
+// END PAINTING    
+    };
+
+    jsPlumbUtil.extend(jsPlumb.Connection, OverlayCapableJsPlumbUIComponent, {
+        applyType : function(t, doNotRepaint) {            
+            if (t.detachable != null) this.setDetachable(t.detachable);
+            if (t.reattach != null) this.setReattach(t.reattach);
+            if (t.scope) this.scope = t.scope;
+            this.setConnector(t.connector, doNotRepaint);
+            if (t.cssClass != null && this.canvas) this._jsPlumb.instance.addClass(this.canvas, t.cssClass);
+            if (t.anchor) {
+                this.endpoints[0].anchor = this._jsPlumb.instance.makeAnchor(t.anchor);
+                this.endpoints[1].anchor = this._jsPlumb.instance.makeAnchor(t.anchor);
+            }
+            else if (t.anchors) {
+                this.endpoints[0].anchor = this._jsPlumb.instance.makeAnchor(t.anchors[0]);
+                this.endpoints[1].anchor = this._jsPlumb.instance.makeAnchor(t.anchors[1]);
+            }
+        },
+        getTypeDescriptor : function() { return "connection"; },
+        getAttachedElements : function() {
+            return this.endpoints;
+        },
+        addClass : function(c, informEndpoints) {        
+            if (informEndpoints) {
+                this.endpoints[0].addClass(c);
+                this.endpoints[1].addClass(c); 
+                if (this.suspendedEndpoint) this.suspendedEndpoint.addClass(c);                   
+            }
+            if (this.connector) {
+                this.connector.addClass(c);
+            }
+        },
+        removeClass : function(c, informEndpoints) {            
+            if (informEndpoints) {
+                this.endpoints[0].removeClass(c);
+                this.endpoints[1].removeClass(c);                    
+                if (this.suspendedEndpoint) this.suspendedEndpoint.removeClass(c);
+            }
+            if (this.connector) {
+                this.connector.removeClass(c);
+            }
+        },
+        isVisible : function() { return this._jsPlumb.visible; },
+        setVisible : function(v) {
+            this._jsPlumb.visible = v;
+            if (this.connector) 
+                this.connector.setVisible(v);
+            this.repaint();
+        },
+        cleanup:function() {
+            this.endpoints = null;
+            this.source = null;
+            this.target = null;                    
+            if (this.connector != null) {
+                this.connector.cleanup();            
+                this.connector.destroy();
+            }
+            this.connector = null;
+        },
+        isDetachable : function() {
+            return this._jsPlumb.detachable === true;
+        },
+        setDetachable : function(detachable) {
+          this._jsPlumb.detachable = detachable === true;
+        },
+        isReattach : function() {
+            return this._jsPlumb.reattach === true;
+        },        
+        setReattach : function(reattach) {
+          this._jsPlumb.reattach = reattach === true;
+        },
+        setHover : function(state) {
+            if (this.connector && this._jsPlumb && !this._jsPlumb.instance.isConnectionBeingDragged()) {
+                this.connector.setHover(state);
+                jsPlumbAdapter[state ? "addClass" : "removeClass"](this.source, this._jsPlumb.instance.hoverSourceClass);
+                jsPlumbAdapter[state ? "addClass" : "removeClass"](this.target, this._jsPlumb.instance.hoverTargetClass);
+            }
+        },
+        getCost : function() { return this._jsPlumb.cost; },
+        setCost : function(c) { this._jsPlumb.cost = c; },
+        isDirected : function() { return this._jsPlumb.directed === true; },
+        getConnector : function() { return this.connector; },
+        setConnector : function(connectorSpec, doNotRepaint, doNotChangeListenerComponent) {
+            var _ju = jsPlumbUtil;
+            if (this.connector != null) {
+                this.connector.cleanup();
+                this.connector.destroy();
+            }
+
+            var connectorArgs = { 
+                    _jsPlumb:this._jsPlumb.instance, 
+                    cssClass:this._jsPlumb.params.cssClass, 
+                    container:this._jsPlumb.params.container,                 
+                    "pointer-events":this._jsPlumb.params["pointer-events"]
+                },
+                renderMode = this._jsPlumb.instance.getRenderMode();
+            
+            if (_ju.isString(connectorSpec)) 
+                this.connector = makeConnector(this._jsPlumb.instance, renderMode, connectorSpec, connectorArgs, this); // lets you use a string as shorthand.
+            else if (_ju.isArray(connectorSpec)) {
+                if (connectorSpec.length == 1)
+                    this.connector = makeConnector(this._jsPlumb.instance, renderMode, connectorSpec[0], connectorArgs, this);
+                else
+                    this.connector = makeConnector(this._jsPlumb.instance, renderMode, connectorSpec[0], _ju.merge(connectorSpec[1], connectorArgs), this);
+            }
+            
+            this.canvas = this.connector.canvas;
+            this.bgCanvas = this.connector.bgCanvas;
+
+            // new: instead of binding listeners per connector, we now just have one delegate on the container.
+            // so for that handler we set the connection as the '_jsPlumb' member of the canvas element, and
+            // bgCanvas, if it exists, which it does right now in the VML renderer, so it won't from v 2.0.0 onwards.
+            if(this.canvas) this.canvas._jsPlumb = this;
+            if(this.bgCanvas) this.bgCanvas._jsPlumb = this;
+
+            if (!doNotChangeListenerComponent) this.setListenerComponent(this.connector);
+            if (!doNotRepaint) this.repaint();
+        },
+        paint : function(params) {
+                    
+            if (!this._jsPlumb.instance.isSuspendDrawing() && this._jsPlumb.visible) {
+                params = params || {};
+                var timestamp = params.timestamp,
+                    // if the moving object is not the source we must transpose the two references.
+                    swap = false,
+                    tId = swap ? this.sourceId : this.targetId, sId = swap ? this.targetId : this.sourceId,                    
+                    tIdx = swap ? 0 : 1, sIdx = swap ? 1 : 0;
+
+                if (timestamp == null || timestamp != this._jsPlumb.lastPaintedAt) {                        
+                    var sourceInfo = this._jsPlumb.instance.getOffset(sId),
+                        targetInfo = this._jsPlumb.instance.getOffset(tId),
+                        sE = this.endpoints[sIdx], tE = this.endpoints[tIdx];
+
+                    var sAnchorP = sE.anchor.getCurrentLocation({xy:[sourceInfo.left,sourceInfo.top], wh:[sourceInfo.width, sourceInfo.height], element:sE, timestamp:timestamp}),              
+                        tAnchorP = tE.anchor.getCurrentLocation({xy:[targetInfo.left,targetInfo.top], wh:[targetInfo.width, targetInfo.height], element:tE, timestamp:timestamp});                                                 
+                        
+                    this.connector.resetBounds();
+
+                    this.connector.compute({
+                        sourcePos:sAnchorP,
+                        targetPos:tAnchorP, 
+                        sourceEndpoint:this.endpoints[sIdx],
+                        targetEndpoint:this.endpoints[tIdx],
+                        lineWidth:this._jsPlumb.paintStyleInUse.lineWidth,                                          
+                        sourceInfo:sourceInfo,
+                        targetInfo:targetInfo
+                    });
+
+                    var overlayExtents = { minX:Infinity, minY:Infinity, maxX:-Infinity, maxY:-Infinity };
+
+                    // compute overlays. we do this first so we can get their placements, and adjust the
+                    // container if needs be (if an overlay would be clipped)
+                    for ( var i = 0; i < this._jsPlumb.overlays.length; i++) {
+                        var o = this._jsPlumb.overlays[i];
+                        if (o.isVisible()) {                            
+                            this._jsPlumb.overlayPlacements[i] = o.draw(this.connector, this._jsPlumb.paintStyleInUse, this.getAbsoluteOverlayPosition(o));
+                            overlayExtents.minX = Math.min(overlayExtents.minX, this._jsPlumb.overlayPlacements[i].minX);
+                            overlayExtents.maxX = Math.max(overlayExtents.maxX, this._jsPlumb.overlayPlacements[i].maxX);
+                            overlayExtents.minY = Math.min(overlayExtents.minY, this._jsPlumb.overlayPlacements[i].minY);
+                            overlayExtents.maxY = Math.max(overlayExtents.maxY, this._jsPlumb.overlayPlacements[i].maxY);
+                        }
+                    }
+
+                    var lineWidth = parseFloat(this._jsPlumb.paintStyleInUse.lineWidth || 1) / 2,
+                        outlineWidth = parseFloat(this._jsPlumb.paintStyleInUse.lineWidth || 0),
+                        extents = {
+                            xmin : Math.min(this.connector.bounds.minX - (lineWidth + outlineWidth), overlayExtents.minX),
+                            ymin : Math.min(this.connector.bounds.minY - (lineWidth + outlineWidth), overlayExtents.minY),
+                            xmax : Math.max(this.connector.bounds.maxX + (lineWidth + outlineWidth), overlayExtents.maxX),
+                            ymax : Math.max(this.connector.bounds.maxY + (lineWidth + outlineWidth), overlayExtents.maxY)
+                        };
+                    // paint the connector.
+                    this.connector.paint(this._jsPlumb.paintStyleInUse, null, extents);
+                    // and then the overlays
+                    for ( var j = 0; j < this._jsPlumb.overlays.length; j++) {
+                        var p = this._jsPlumb.overlays[j];
+                        if (p.isVisible()) {
+                            p.paint(this._jsPlumb.overlayPlacements[j], extents);    
+                        }
+                    }
+                }
+                this._jsPlumb.lastPaintedAt = timestamp;
+            }
+        },
+        repaint : function(params) {
+            params = params || {};            
+            this.paint({ elId : this.sourceId, recalc : !(params.recalc === false), timestamp:params.timestamp});
+        },
+        prepareEndpoint : function(_jsPlumb, _newEndpoint, conn, existing, index, params, element, elementId) {
+            var e;
+            if (existing) {
+                conn.endpoints[index] = existing;
+                existing.addConnection(conn);                   
+            } else {
+                if (!params.endpoints) params.endpoints = [ null, null ];
+                var ep = params.endpoints[index]  || params.endpoint || _jsPlumb.Defaults.Endpoints[index] || jsPlumb.Defaults.Endpoints[index] || _jsPlumb.Defaults.Endpoint || jsPlumb.Defaults.Endpoint;
+                if (!params.endpointStyles) params.endpointStyles = [ null, null ];
+                if (!params.endpointHoverStyles) params.endpointHoverStyles = [ null, null ];
+                var es = params.endpointStyles[index] || params.endpointStyle || _jsPlumb.Defaults.EndpointStyles[index] || jsPlumb.Defaults.EndpointStyles[index] || _jsPlumb.Defaults.EndpointStyle || jsPlumb.Defaults.EndpointStyle;
+                // Endpoints derive their fillStyle from the connector's strokeStyle, if no fillStyle was specified.
+                if (es.fillStyle == null && params.paintStyle != null)
+                    es.fillStyle = params.paintStyle.strokeStyle;
+                
+                // TODO: decide if the endpoint should derive the connection's outline width and color.  currently it does:
+                //*
+                if (es.outlineColor == null && params.paintStyle != null) 
+                    es.outlineColor = params.paintStyle.outlineColor;
+                if (es.outlineWidth == null && params.paintStyle != null) 
+                    es.outlineWidth = params.paintStyle.outlineWidth;
+                //*/
+                
+                var ehs = params.endpointHoverStyles[index] || params.endpointHoverStyle || _jsPlumb.Defaults.EndpointHoverStyles[index] || jsPlumb.Defaults.EndpointHoverStyles[index] || _jsPlumb.Defaults.EndpointHoverStyle || jsPlumb.Defaults.EndpointHoverStyle;
+                // endpoint hover fill style is derived from connector's hover stroke style.  TODO: do we want to do this by default? for sure?
+                if (params.hoverPaintStyle != null) {
+                    if (ehs == null) ehs = {};
+                    if (ehs.fillStyle == null) {
+                        ehs.fillStyle = params.hoverPaintStyle.strokeStyle;
+                    }
+                }
+                var a = params.anchors ? params.anchors[index] : 
+                        params.anchor ? params.anchor :
+                        _makeAnchor(_jsPlumb.Defaults.Anchors[index], elementId, _jsPlumb) || 
+                        _makeAnchor(jsPlumb.Defaults.Anchors[index], elementId,_jsPlumb) || 
+                        _makeAnchor(_jsPlumb.Defaults.Anchor, elementId,_jsPlumb) || 
+                        _makeAnchor(jsPlumb.Defaults.Anchor, elementId, _jsPlumb),                  
+                    u = params.uuids ? params.uuids[index] : null;
+                    
+                e = _newEndpoint({ 
+                    paintStyle : es,  hoverPaintStyle:ehs,  endpoint : ep,  connections : [ conn ], 
+                    uuid : u,  anchor : a,  source : element, scope  : params.scope,
+                    reattach:params.reattach || _jsPlumb.Defaults.ReattachConnections,
+                    detachable:params.detachable || _jsPlumb.Defaults.ConnectionsDetachable
+                });
+                conn.endpoints[index] = e;
+                
+                if (params.drawEndpoints === false) e.setVisible(false, true, true);
+                                    
+            }
+            return e;
+        }
+        
+    }); // END Connection class            
+})();
+
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the code for creating and manipulating anchors.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+;(function() {	
+
+    "use strict";
+
+    //
+	// manages anchors for all elements.
+	//
+	jsPlumb.AnchorManager = function(params) {
+		var _amEndpoints = {},
+            continuousAnchors = {},
+            continuousAnchorLocations = {},
+            userDefinedContinuousAnchorLocations = {},        
+            continuousAnchorOrientations = {},
+            Orientation = { HORIZONTAL : "horizontal", VERTICAL : "vertical", DIAGONAL : "diagonal", IDENTITY:"identity" },
+            axes = ["left", "top", "right", "bottom"],
+			connectionsByElementId = {},
+			self = this,
+            anchorLists = {},
+            jsPlumbInstance = params.jsPlumbInstance,
+            floatingConnections = {},            
+            calculateOrientation = function(sourceId, targetId, sd, td, sourceAnchor, targetAnchor) {
+        
+                if (sourceId === targetId) return {
+                    orientation:Orientation.IDENTITY,
+                    a:["top", "top"]
+                };        
+
+                var theta = Math.atan2((td.centery - sd.centery) , (td.centerx - sd.centerx)),
+                    theta2 = Math.atan2((sd.centery - td.centery) , (sd.centerx - td.centerx));
+
+// --------------------------------------------------------------------------------------
+
+				// improved face calculation. get midpoints of each face for source and target, then put in an array with all combinations of
+				// source/target faces. sort this array by distance between midpoints. the entry at index 0 is our preferred option. we can 
+				// go through the array one by one until we find an entry in which each requested face is supported.
+				var candidates = [], midpoints = { };
+				(function(types, dim) {
+					for (var i = 0; i < types.length; i++) {
+						midpoints[types[i]] = {
+							"left":[ dim[i].left, dim[i].centery ],
+							"right":[ dim[i].right, dim[i].centery ],
+							"top":[ dim[i].centerx, dim[i].top ],
+							"bottom":[ dim[i].centerx , dim[i].bottom]
+						};
+					}
+				})([ "source", "target" ], [ sd, td ]);
+
+				for (var sf = 0; sf < axes.length; sf++) {
+					for (var tf = 0; tf < axes.length; tf++) {
+						if (sf != tf) {
+							candidates.push({ 
+								source:axes[sf], 
+								target:axes[tf], 
+								dist:Biltong.lineLength(midpoints.source[axes[sf]], midpoints.target[axes[tf]]) 
+							});
+						}
+					}
+				}
+
+				candidates.sort(function(a, b) {
+					return a.dist < b.dist ? -1 : a.dist > b.dist ? 1 : 0;
+				});
+
+				// now go through this list and try to get an entry that satisfies both (there will be one, unless one of the anchors
+				// declares no available faces)
+				var sourceEdge = candidates[0].source, targetEdge = candidates[0].target;
+				for (var i = 0; i < candidates.length; i++) {
+					
+					if (!sourceAnchor.isContinuous || sourceAnchor.isEdgeSupported(candidates[i].source))
+						sourceEdge = candidates[i].source;
+					else
+						sourceEdge = null;
+
+					if (!targetAnchor.isContinuous || targetAnchor.isEdgeSupported(candidates[i].target))
+						targetEdge = candidates[i].target;
+					else {
+						targetEdge = null;
+					}
+
+					if (sourceEdge != null && targetEdge != null) break;
+				}				
+
+// --------------------------------------------------------------------------------------
+
+                return {
+                	a : [ sourceEdge, targetEdge ],
+                    theta:theta,
+                    theta2:theta2
+                };
+            },
+                // used by placeAnchors function
+            placeAnchorsOnLine = function(desc, elementDimensions, elementPosition,
+                            connections, horizontal, otherMultiplier, reverse) {
+                var a = [], step = elementDimensions[horizontal ? 0 : 1] / (connections.length + 1);
+        
+                for (var i = 0; i < connections.length; i++) {
+                    var val = (i + 1) * step, other = otherMultiplier * elementDimensions[horizontal ? 1 : 0];
+                    if (reverse)
+                      val = elementDimensions[horizontal ? 0 : 1] - val;
+        
+                    var dx = (horizontal ? val : other), x = elementPosition[0] + dx,  xp = dx / elementDimensions[0],
+                        dy = (horizontal ? other : val), y = elementPosition[1] + dy, yp = dy / elementDimensions[1];
+        
+                    a.push([ x, y, xp, yp, connections[i][1], connections[i][2] ]);
+                }
+        
+                return a;
+            },
+            // used by edgeSortFunctions        
+            currySort = function(reverseAngles) {
+                return function(a,b) {
+                    var r = true;
+                    if (reverseAngles) {
+                        r = a[0][0] < b[0][0];
+                    }
+                    else {                        
+                        r = a[0][0] > b[0][0];
+                    }
+                    return r === false ? -1 : 1;
+                };
+            },
+                // used by edgeSortFunctions
+            leftSort = function(a,b) {
+                // first get adjusted values
+                var p1 = a[0][0] < 0 ? -Math.PI - a[0][0] : Math.PI - a[0][0],
+                p2 = b[0][0] < 0 ? -Math.PI - b[0][0] : Math.PI - b[0][0];
+                if (p1 > p2) return 1;
+                else return a[0][1] > b[0][1] ? 1 : -1;
+            },
+                // used by placeAnchors
+            edgeSortFunctions = {
+                "top":function(a, b) { return a[0] > b[0] ? 1 : -1; },
+                "right":currySort(true),
+                "bottom":currySort(true),
+                "left":leftSort
+            },
+                // used by placeAnchors
+            _sortHelper = function(_array, _fn) { return _array.sort(_fn); },
+                // used by AnchorManager.redraw
+            placeAnchors = function(elementId, _anchorLists) {		
+                var cd = jsPlumbInstance.getCachedData(elementId), sS = cd.s, sO = cd.o,
+                placeSomeAnchors = function(desc, elementDimensions, elementPosition, unsortedConnections, isHorizontal, otherMultiplier, orientation) {
+                    if (unsortedConnections.length > 0) {
+                        var sc = _sortHelper(unsortedConnections, edgeSortFunctions[desc]), // puts them in order based on the target element's pos on screen
+                            reverse = desc === "right" || desc === "top",
+                            anchors = placeAnchorsOnLine(desc, elementDimensions,
+                                                     elementPosition, sc,
+                                                     isHorizontal, otherMultiplier, reverse );
+        
+                        // takes a computed anchor position and adjusts it for parent offset and scroll, then stores it.
+                        var _setAnchorLocation = function(endpoint, anchorPos) {                            
+                            continuousAnchorLocations[endpoint.id] = [ anchorPos[0], anchorPos[1], anchorPos[2], anchorPos[3] ];
+                            continuousAnchorOrientations[endpoint.id] = orientation;
+                        };
+        
+                        for (var i = 0; i < anchors.length; i++) {
+                            var c = anchors[i][4], weAreSource = c.endpoints[0].elementId === elementId, weAreTarget = c.endpoints[1].elementId === elementId;
+                            if (weAreSource)
+                                _setAnchorLocation(c.endpoints[0], anchors[i]);
+                            else if (weAreTarget)
+                                _setAnchorLocation(c.endpoints[1], anchors[i]);
+                        }
+                    }
+                };
+        
+                placeSomeAnchors("bottom", sS, [sO.left,sO.top], _anchorLists.bottom, true, 1, [0,1]);
+                placeSomeAnchors("top", sS, [sO.left,sO.top], _anchorLists.top, true, 0, [0,-1]);
+                placeSomeAnchors("left", sS, [sO.left,sO.top], _anchorLists.left, false, 0, [-1,0]);
+                placeSomeAnchors("right", sS, [sO.left,sO.top], _anchorLists.right, false, 1, [1,0]);
+            };
+
+        this.reset = function() {
+            _amEndpoints = {};
+            connectionsByElementId = {};
+            anchorLists = {};
+        };			
+        this.addFloatingConnection = function(key, conn) {
+            floatingConnections[key] = conn;
+        };
+        this.removeFloatingConnection = function(key) {
+            delete floatingConnections[key];
+        };                                                 
+        this.newConnection = function(conn) {
+			var sourceId = conn.sourceId, targetId = conn.targetId,
+				ep = conn.endpoints,
+                doRegisterTarget = true,
+                registerConnection = function(otherIndex, otherEndpoint, otherAnchor, elId, c) {
+					if ((sourceId == targetId) && otherAnchor.isContinuous){
+                       // remove the target endpoint's canvas.  we dont need it.
+                        conn._jsPlumb.instance.removeElement(ep[1].canvas);
+                        doRegisterTarget = false;
+                    }
+					jsPlumbUtil.addToList(connectionsByElementId, elId, [c, otherEndpoint, otherAnchor.constructor == jsPlumb.DynamicAnchor]);
+			    };
+
+			registerConnection(0, ep[0], ep[0].anchor, targetId, conn);
+            if (doRegisterTarget)
+            	registerConnection(1, ep[1], ep[1].anchor, sourceId, conn);
+		};
+        var removeEndpointFromAnchorLists = function(endpoint) {
+            (function(list, eId) {
+                if (list) {  // transient anchors dont get entries in this list.
+                    var f = function(e) { return e[4] == eId; };
+                    jsPlumbUtil.removeWithFunction(list.top, f);
+                    jsPlumbUtil.removeWithFunction(list.left, f);
+                    jsPlumbUtil.removeWithFunction(list.bottom, f);
+                    jsPlumbUtil.removeWithFunction(list.right, f);
+                }
+            })(anchorLists[endpoint.elementId], endpoint.id);
+        };
+		this.connectionDetached = function(connInfo) {
+            var connection = connInfo.connection || connInfo,
+			    sourceId = connInfo.sourceId,
+                targetId = connInfo.targetId,
+				ep = connection.endpoints,
+				removeConnection = function(otherIndex, otherEndpoint, otherAnchor, elId, c) {
+					if (otherAnchor != null && otherAnchor.constructor == jsPlumb.FloatingAnchor) {
+						// no-op
+					}
+					else {
+						jsPlumbUtil.removeWithFunction(connectionsByElementId[elId], function(_c) {
+							return _c[0].id == c.id;
+						});
+					}
+				};
+				
+			removeConnection(1, ep[1], ep[1].anchor, sourceId, connection);
+			removeConnection(0, ep[0], ep[0].anchor, targetId, connection);
+
+            // remove from anchorLists            
+            removeEndpointFromAnchorLists(connection.endpoints[0]);
+            removeEndpointFromAnchorLists(connection.endpoints[1]);
+
+            self.redraw(connection.sourceId);
+            self.redraw(connection.targetId);
+		};
+		this.add = function(endpoint, elementId) {
+			jsPlumbUtil.addToList(_amEndpoints, elementId, endpoint);
+		};
+		this.changeId = function(oldId, newId) {
+			connectionsByElementId[newId] = connectionsByElementId[oldId];
+			_amEndpoints[newId] = _amEndpoints[oldId];
+			delete connectionsByElementId[oldId];
+			delete _amEndpoints[oldId];	
+		};
+		this.getConnectionsFor = function(elementId) {
+			return connectionsByElementId[elementId] || [];
+		};
+		this.getEndpointsFor = function(elementId) {
+			return _amEndpoints[elementId] || [];
+		};
+		this.deleteEndpoint = function(endpoint) {
+			jsPlumbUtil.removeWithFunction(_amEndpoints[endpoint.elementId], function(e) {
+				return e.id == endpoint.id;
+			});
+            removeEndpointFromAnchorLists(endpoint);
+		};
+		this.clearFor = function(elementId) {
+			delete _amEndpoints[elementId];
+			_amEndpoints[elementId] = [];
+		};
+        // updates the given anchor list by either updating an existing anchor's info, or adding it. this function
+        // also removes the anchor from its previous list, if the edge it is on has changed.
+        // all connections found along the way (those that are connected to one of the faces this function
+        // operates on) are added to the connsToPaint list, as are their endpoints. in this way we know to repaint
+        // them wthout having to calculate anything else about them.
+        var _updateAnchorList = function(lists, theta, order, conn, aBoolean, otherElId, idx, reverse, edgeId, elId, connsToPaint, endpointsToPaint) {        
+            // first try to find the exact match, but keep track of the first index of a matching element id along the way.s
+            var exactIdx = -1,
+                firstMatchingElIdx = -1,
+                endpoint = conn.endpoints[idx],
+                endpointId = endpoint.id,
+                oIdx = [1,0][idx],
+                values = [ [ theta, order ], conn, aBoolean, otherElId, endpointId ],
+                listToAddTo = lists[edgeId],
+                listToRemoveFrom = endpoint._continuousAnchorEdge ? lists[endpoint._continuousAnchorEdge] : null,
+                i;
+
+            if (listToRemoveFrom) {
+                var rIdx = jsPlumbUtil.findWithFunction(listToRemoveFrom, function(e) { return e[4] == endpointId; });
+                if (rIdx != -1) {
+                    listToRemoveFrom.splice(rIdx, 1);
+                    // get all connections from this list
+                    for (i = 0; i < listToRemoveFrom.length; i++) {
+                        jsPlumbUtil.addWithFunction(connsToPaint, listToRemoveFrom[i][1], function(c) { return c.id == listToRemoveFrom[i][1].id; });
+                        jsPlumbUtil.addWithFunction(endpointsToPaint, listToRemoveFrom[i][1].endpoints[idx], function(e) { return e.id == listToRemoveFrom[i][1].endpoints[idx].id; });
+                        jsPlumbUtil.addWithFunction(endpointsToPaint, listToRemoveFrom[i][1].endpoints[oIdx], function(e) { return e.id == listToRemoveFrom[i][1].endpoints[oIdx].id; });
+                    }
+                }
+            }
+
+            for (i = 0; i < listToAddTo.length; i++) {
+                if (params.idx == 1 && listToAddTo[i][3] === otherElId && firstMatchingElIdx == -1)
+                    firstMatchingElIdx = i;
+                jsPlumbUtil.addWithFunction(connsToPaint, listToAddTo[i][1], function(c) { return c.id == listToAddTo[i][1].id; });                
+                jsPlumbUtil.addWithFunction(endpointsToPaint, listToAddTo[i][1].endpoints[idx], function(e) { return e.id == listToAddTo[i][1].endpoints[idx].id; });
+                jsPlumbUtil.addWithFunction(endpointsToPaint, listToAddTo[i][1].endpoints[oIdx], function(e) { return e.id == listToAddTo[i][1].endpoints[oIdx].id; });
+            }
+            if (exactIdx != -1) {
+                listToAddTo[exactIdx] = values;
+            }
+            else {
+                var insertIdx = reverse ? firstMatchingElIdx != -1 ? firstMatchingElIdx : 0 : listToAddTo.length; // of course we will get this from having looked through the array shortly.
+                listToAddTo.splice(insertIdx, 0, values);
+            }
+
+            // store this for next time.
+            endpoint._continuousAnchorEdge = edgeId;
+        };
+
+        //
+        // find the entry in an endpoint's list for this connection and update its target endpoint
+        // with the current target in the connection.
+        // 
+        //
+        this.updateOtherEndpoint = function(elId, oldTargetId, newTargetId, connection) {
+            var sIndex = jsPlumbUtil.findWithFunction(connectionsByElementId[elId], function(i) {
+                    return i[0].id === connection.id;
+                }),
+                tIndex = jsPlumbUtil.findWithFunction(connectionsByElementId[oldTargetId], function(i) {
+                    return i[0].id === connection.id;
+                });
+
+            // update or add data for source
+            if (sIndex != -1) {
+                connectionsByElementId[elId][sIndex][0] = connection;
+                connectionsByElementId[elId][sIndex][1] = connection.endpoints[1];
+                connectionsByElementId[elId][sIndex][2] = connection.endpoints[1].anchor.constructor == jsPlumb.DynamicAnchor;
+            }
+
+            // remove entry for previous target (if there)
+            if (tIndex > -1) {
+                connectionsByElementId[oldTargetId].splice(tIndex, 1);
+                // add entry for new target
+                jsPlumbUtil.addToList(connectionsByElementId, newTargetId, [connection, connection.endpoints[0], connection.endpoints[0].anchor.constructor == jsPlumb.DynamicAnchor]);         
+            }
+        };       
+        
+        //
+        // notification that the connection given has changed source from the originalId to the newId.
+        // This involves:
+        // 1. removing the connection from the list of connections stored for the originalId
+        // 2. updating the source information for the target of the connection
+        // 3. re-registering the connection in connectionsByElementId with the newId
+        //
+        this.sourceChanged = function(originalId, newId, connection) {        
+            if (originalId !== newId) {    
+                // remove the entry that points from the old source to the target
+                jsPlumbUtil.removeWithFunction(connectionsByElementId[originalId], function(info) {
+                    return info[0].id === connection.id;
+                });
+                // find entry for target and update it
+                var tIdx = jsPlumbUtil.findWithFunction(connectionsByElementId[connection.targetId], function(i) {
+                    return i[0].id === connection.id;
+                });
+                if (tIdx > -1) {
+                    connectionsByElementId[connection.targetId][tIdx][0] = connection;
+                    connectionsByElementId[connection.targetId][tIdx][1] = connection.endpoints[0];
+                    connectionsByElementId[connection.targetId][tIdx][2] = connection.endpoints[0].anchor.constructor == jsPlumb.DynamicAnchor;
+                }
+                // add entry for new source
+                jsPlumbUtil.addToList(connectionsByElementId, newId, [connection, connection.endpoints[1], connection.endpoints[1].anchor.constructor == jsPlumb.DynamicAnchor]);         
+            }
+        };
+
+        //
+        // moves the given endpoint from `currentId` to `element`.
+        // This involves:
+        //
+        // 1. changing the key in _amEndpoints under which the endpoint is stored
+        // 2. changing the source or target values in all of the endpoint's connections
+        // 3. changing the array in connectionsByElementId in which the endpoint's connections
+        //    are stored (done by either sourceChanged or updateOtherEndpoint)
+        //
+        this.rehomeEndpoint = function(ep, currentId, element) {
+            var eps = _amEndpoints[currentId] || [], 
+                elementId = jsPlumbInstance.getId(element);
+                
+            if (elementId !== currentId) {
+                var idx = jsPlumbUtil.indexOf(eps, ep);
+                if (idx > -1) {
+                    var _ep = eps.splice(idx, 1)[0];
+                    self.add(_ep, elementId);
+                }
+            }
+
+            for (var i = 0; i < ep.connections.length; i++) {                
+                if (ep.connections[i].sourceId == currentId) {
+                    ep.connections[i].sourceId = ep.elementId;
+                    ep.connections[i].source = ep.element;                  
+                    self.sourceChanged(currentId, ep.elementId, ep.connections[i]);
+                }
+                else if(ep.connections[i].targetId == currentId) {
+                    ep.connections[i].targetId = ep.elementId;
+                    ep.connections[i].target = ep.element;   
+                    self.updateOtherEndpoint(ep.connections[i].sourceId, currentId, ep.elementId, ep.connections[i]);               
+                }
+            }   
+        };
+
+		this.redraw = function(elementId, ui, timestamp, offsetToUI, clearEdits, doNotRecalcEndpoint) {
+		
+			if (!jsPlumbInstance.isSuspendDrawing()) {
+				// get all the endpoints for this element
+				var ep = _amEndpoints[elementId] || [],
+					endpointConnections = connectionsByElementId[elementId] || [],
+					connectionsToPaint = [],
+					endpointsToPaint = [],
+	                anchorsToUpdate = [];
+	            
+				timestamp = timestamp || jsPlumbInstance.timestamp();
+				// offsetToUI are values that would have been calculated in the dragManager when registering
+				// an endpoint for an element that had a parent (somewhere in the hierarchy) that had been
+				// registered as draggable.
+				offsetToUI = offsetToUI || {left:0, top:0};
+				if (ui) {
+					ui = {
+						left:ui.left + offsetToUI.left,
+						top:ui.top + offsetToUI.top
+					};
+				}
+
+				// valid for one paint cycle.
+				var myOffset = jsPlumbInstance.updateOffset( { elId : elementId, offset : ui, recalc : false, timestamp : timestamp }),
+	                orientationCache = {};
+				
+				// actually, first we should compute the orientation of this element to all other elements to which
+				// this element is connected with a continuous anchor (whether both ends of the connection have
+				// a continuous anchor or just one)
+
+	            for (var i = 0; i < endpointConnections.length; i++) {
+	                var conn = endpointConnections[i][0],
+						sourceId = conn.sourceId,
+	                    targetId = conn.targetId,
+	                    sourceContinuous = conn.endpoints[0].anchor.isContinuous,
+	                    targetContinuous = conn.endpoints[1].anchor.isContinuous;
+	
+	                if (sourceContinuous || targetContinuous) {
+		                var oKey = sourceId + "_" + targetId,
+		                    oKey2 = targetId + "_" + sourceId,
+		                    o = orientationCache[oKey],
+		                    oIdx = conn.sourceId == elementId ? 1 : 0;
+	
+		                if (sourceContinuous && !anchorLists[sourceId]) anchorLists[sourceId] = { top:[], right:[], bottom:[], left:[] };
+		                if (targetContinuous && !anchorLists[targetId]) anchorLists[targetId] = { top:[], right:[], bottom:[], left:[] };
+	
+		                if (elementId != targetId) jsPlumbInstance.updateOffset( { elId : targetId, timestamp : timestamp }); 
+		                if (elementId != sourceId) jsPlumbInstance.updateOffset( { elId : sourceId, timestamp : timestamp }); 
+	
+		                var td = jsPlumbInstance.getCachedData(targetId),
+							sd = jsPlumbInstance.getCachedData(sourceId);
+	
+		                if (targetId == sourceId && (sourceContinuous || targetContinuous)) {
+		                    // here we may want to improve this by somehow determining the face we'd like
+						    // to put the connector on.  ideally, when drawing, the face should be calculated
+						    // by determining which face is closest to the point at which the mouse button
+							// was released.  for now, we're putting it on the top face.                            
+		                    _updateAnchorList(
+                                anchorLists[sourceId], 
+                                -Math.PI / 2, 
+                                0, 
+                                conn, 
+                                false, 
+                                targetId, 
+                                0, false, "top", sourceId, connectionsToPaint, endpointsToPaint);
+						}
+		                else {
+		                    if (!o) {
+		                        o = calculateOrientation(sourceId, targetId, sd.o, td.o, conn.endpoints[0].anchor, conn.endpoints[1].anchor);
+		                        orientationCache[oKey] = o;
+		                        // this would be a performance enhancement, but the computed angles need to be clamped to
+		                        //the (-PI/2 -> PI/2) range in order for the sorting to work properly.
+		                    /*  orientationCache[oKey2] = {
+		                            orientation:o.orientation,
+		                            a:[o.a[1], o.a[0]],
+		                            theta:o.theta + Math.PI,
+		                            theta2:o.theta2 + Math.PI
+		                        };*/
+		                    }
+		                    if (sourceContinuous) _updateAnchorList(anchorLists[sourceId], o.theta, 0, conn, false, targetId, 0, false, o.a[0], sourceId, connectionsToPaint, endpointsToPaint);
+		                    if (targetContinuous) _updateAnchorList(anchorLists[targetId], o.theta2, -1, conn, true, sourceId, 1, true, o.a[1], targetId, connectionsToPaint, endpointsToPaint);
+		                }
+	
+		                if (sourceContinuous) jsPlumbUtil.addWithFunction(anchorsToUpdate, sourceId, function(a) { return a === sourceId; });
+		                if (targetContinuous) jsPlumbUtil.addWithFunction(anchorsToUpdate, targetId, function(a) { return a === targetId; });
+		                jsPlumbUtil.addWithFunction(connectionsToPaint, conn, function(c) { return c.id == conn.id; });
+		                if ((sourceContinuous && oIdx === 0) || (targetContinuous && oIdx === 1))
+		                	jsPlumbUtil.addWithFunction(endpointsToPaint, conn.endpoints[oIdx], function(e) { return e.id == conn.endpoints[oIdx].id; });
+		            }
+	            }
+
+				// place Endpoints whose anchors are continuous but have no Connections
+				for (i = 0; i < ep.length; i++) {
+					if (ep[i].connections.length === 0 && ep[i].anchor.isContinuous) {
+						if (!anchorLists[elementId]) anchorLists[elementId] = { top:[], right:[], bottom:[], left:[] };
+                        _updateAnchorList(anchorLists[elementId], -Math.PI / 2, 0, {endpoints:[ep[i], ep[i]], paint:function(){}}, false, elementId, 0, false, ep[i].anchor.getDefaultFace(), elementId, connectionsToPaint, endpointsToPaint);
+						jsPlumbUtil.addWithFunction(anchorsToUpdate, elementId, function(a) { return a === elementId; });
+					}
+				}
+
+
+	            // now place all the continuous anchors we need to;
+	            for (i = 0; i < anchorsToUpdate.length; i++) {
+					placeAnchors(anchorsToUpdate[i], anchorLists[anchorsToUpdate[i]]);
+				}
+
+				// now that continuous anchors have been placed, paint all the endpoints for this element
+	            // TODO performance: add the endpoint ids to a temp array, and then when iterating in the next
+	            // loop, check that we didn't just paint that endpoint. we can probably shave off a few more milliseconds this way.
+				for (i = 0; i < ep.length; i++) {				
+                    ep[i].paint( { timestamp : timestamp, offset : myOffset, dimensions : myOffset.s, recalc:doNotRecalcEndpoint !== true });
+				}
+
+	            // ... and any other endpoints we came across as a result of the continuous anchors.
+	            for (i = 0; i < endpointsToPaint.length; i++) {
+                    var cd = jsPlumbInstance.getCachedData(endpointsToPaint[i].elementId);
+                    endpointsToPaint[i].paint( { timestamp : timestamp, offset : cd, dimensions : cd.s });
+				}
+
+				// paint all the standard and "dynamic connections", which are connections whose other anchor is
+				// static and therefore does need to be recomputed; we make sure that happens only one time.
+
+				// TODO we could have compiled a list of these in the first pass through connections; might save some time.
+				for (i = 0; i < endpointConnections.length; i++) {
+					var otherEndpoint = endpointConnections[i][1];
+					if (otherEndpoint.anchor.constructor == jsPlumb.DynamicAnchor) {			 							
+						otherEndpoint.paint({ elementWithPrecedence:elementId, timestamp:timestamp });								
+	                    jsPlumbUtil.addWithFunction(connectionsToPaint, endpointConnections[i][0], function(c) { return c.id == endpointConnections[i][0].id; });
+						// all the connections for the other endpoint now need to be repainted
+						for (var k = 0; k < otherEndpoint.connections.length; k++) {
+							if (otherEndpoint.connections[k] !== endpointConnections[i][0])							
+	                            jsPlumbUtil.addWithFunction(connectionsToPaint, otherEndpoint.connections[k], function(c) { return c.id == otherEndpoint.connections[k].id; });
+						}
+					} else if (otherEndpoint.anchor.constructor == jsPlumb.Anchor) {					
+	                    jsPlumbUtil.addWithFunction(connectionsToPaint, endpointConnections[i][0], function(c) { return c.id == endpointConnections[i][0].id; });
+					}
+				}
+
+				// paint current floating connection for this element, if there is one.
+				var fc = floatingConnections[elementId];
+				if (fc) 
+					fc.paint({timestamp:timestamp, recalc:false, elId:elementId});
+
+				// paint all the connections
+				for (i = 0; i < connectionsToPaint.length; i++) {
+                    connectionsToPaint[i].paint({elId:elementId, timestamp:timestamp, recalc:false, clearEdits:clearEdits});
+				}
+			}
+		};        
+        
+        var ContinuousAnchor = function(anchorParams) {
+            jsPlumbUtil.EventGenerator.apply(this);
+            this.type = "Continuous";
+            this.isDynamic = true;
+            this.isContinuous = true;
+            var faces = anchorParams.faces || ["top", "right", "bottom", "left"],
+                clockwise = !(anchorParams.clockwise === false),
+                availableFaces = { },
+                opposites = { "top":"bottom", "right":"left","left":"right","bottom":"top" },
+                clockwiseOptions = { "top":"right", "right":"bottom","left":"top","bottom":"left" },
+                antiClockwiseOptions = { "top":"left", "right":"top","left":"bottom","bottom":"right" },
+                secondBest = clockwise ? clockwiseOptions : antiClockwiseOptions,
+                lastChoice = clockwise ? antiClockwiseOptions : clockwiseOptions,
+                cssClass = anchorParams.cssClass || "";
+
+            for (var i = 0; i < faces.length; i++) { availableFaces[faces[i]] = true; }
+
+            this.getDefaultFace = function() {
+                return faces.length === 0 ? "top" : faces[0];
+            };
+
+            // if the given edge is supported, returns it. otherwise looks for a substitute that _is_
+            // supported. if none supported we also return the request edge.
+            this.verifyEdge = function(edge) {
+                if (availableFaces[edge]) return edge;
+                else if (availableFaces[opposites[edge]]) return opposites[edge];
+                else if (availableFaces[secondBest[edge]]) return secondBest[edge];
+                else if (availableFaces[lastChoice[edge]]) return lastChoice[edge];
+                return edge; // we have to give them something.
+            };
+
+            this.isEdgeSupported = function(edge) {
+            	return availableFaces[edge] === true;
+            };
+
+            this.compute = function(params) {
+                return userDefinedContinuousAnchorLocations[params.element.id] || continuousAnchorLocations[params.element.id] || [0,0];
+            };
+            this.getCurrentLocation = function(params) {
+                return userDefinedContinuousAnchorLocations[params.element.id] || continuousAnchorLocations[params.element.id] || [0,0];
+            };
+            this.getOrientation = function(endpoint) {
+                return continuousAnchorOrientations[endpoint.id] || [0,0];
+            };
+            this.clearUserDefinedLocation = function() {
+                delete userDefinedContinuousAnchorLocations[anchorParams.elementId];
+            };
+            this.setUserDefinedLocation = function(loc) {
+                userDefinedContinuousAnchorLocations[anchorParams.elementId] = loc;
+            };
+            this.getCssClass = function() { return cssClass; };
+            this.setCssClass = function(c) { cssClass = c; };
+        };
+        
+        // continuous anchors
+        jsPlumbInstance.continuousAnchorFactory = {
+            get:function(params) {
+                return new ContinuousAnchor(params);
+            },
+            clear:function(elementId) {
+                delete userDefinedContinuousAnchorLocations[elementId];
+                delete continuousAnchorLocations[elementId];
+            }
+        };
+	};
+    
+    /**
+     * Anchors model a position on some element at which an Endpoint may be located.  They began as a first class citizen of jsPlumb, ie. a user
+     * was required to create these themselves, but over time this has been replaced by the concept of referring to them either by name (eg. "TopMiddle"),
+     * or by an array describing their coordinates (eg. [ 0, 0.5, 0, -1 ], which is the same as "TopMiddle").  jsPlumb now handles all of the
+     * creation of Anchors without user intervention.
+     */
+    jsPlumb.Anchor = function(params) {       
+        this.x = params.x || 0;
+        this.y = params.y || 0;
+        this.elementId = params.elementId;  
+        this.cssClass = params.cssClass || "";      
+        this.userDefinedLocation = null;
+        this.orientation = params.orientation || [ 0, 0 ];
+
+        jsPlumbUtil.EventGenerator.apply(this);
+        
+        var jsPlumbInstance = params.jsPlumbInstance;//,
+            //lastTimestamp = null;//, lastReturnValue = null;
+        
+        this.lastReturnValue = null;
+        this.offsets = params.offsets || [ 0, 0 ];
+        this.timestamp = null;        
+        this.compute = function(params) {
+
+			var xy = params.xy, wh = params.wh, element = params.element, timestamp = params.timestamp; 
+
+			if(params.clearUserDefinedLocation)
+				this.userDefinedLocation = null;
+
+			if (timestamp && timestamp === self.timestamp)
+				return this.lastReturnValue;
+
+			if (this.userDefinedLocation != null) {
+				this.lastReturnValue = this.userDefinedLocation;
+			}
+			else {
+				this.lastReturnValue = [ xy[0] + (this.x * wh[0]) + this.offsets[0], xy[1] + (this.y * wh[1]) + this.offsets[1] ];
+			}
+
+			this.timestamp = timestamp;
+			return this.lastReturnValue;
+		};
+
+        this.getCurrentLocation = function(params) { 
+            return (this.lastReturnValue == null || (params.timestamp != null && this.timestamp != params.timestamp)) ? this.compute(params) : this.lastReturnValue; 
+        };
+    };
+    jsPlumbUtil.extend(jsPlumb.Anchor, jsPlumbUtil.EventGenerator, {
+        equals : function(anchor) {
+            if (!anchor) return false;
+            var ao = anchor.getOrientation(),
+                o = this.getOrientation();
+            return this.x == anchor.x && this.y == anchor.y && this.offsets[0] == anchor.offsets[0] && this.offsets[1] == anchor.offsets[1] && o[0] == ao[0] && o[1] == ao[1];
+        },
+        getUserDefinedLocation : function() { 
+            return this.userDefinedLocation;
+        },        
+        setUserDefinedLocation : function(l) {
+            this.userDefinedLocation = l;
+        },
+        clearUserDefinedLocation : function() {
+            this.userDefinedLocation = null;
+        },
+        getOrientation : function(_endpoint) { return this.orientation; },
+        getCssClass : function() { return this.cssClass; }
+    });
+
+    /**
+     * An Anchor that floats. its orientation is computed dynamically from
+     * its position relative to the anchor it is floating relative to.  It is used when creating 
+     * a connection through drag and drop.
+     * 
+     * TODO FloatingAnchor could totally be refactored to extend Anchor just slightly.
+     */
+    jsPlumb.FloatingAnchor = function(params) {
+        
+        jsPlumb.Anchor.apply(this, arguments);
+
+        // this is the anchor that this floating anchor is referenced to for
+        // purposes of calculating the orientation.
+        var ref = params.reference,
+            jsPlumbInstance = params.jsPlumbInstance,
+            // the canvas this refers to.
+            refCanvas = params.referenceCanvas,
+            size = jsPlumb.getSize(refCanvas),
+            // these are used to store the current relative position of our
+            // anchor wrt the reference anchor. they only indicate
+            // direction, so have a value of 1 or -1 (or, very rarely, 0). these
+            // values are written by the compute method, and read
+            // by the getOrientation method.
+            xDir = 0, yDir = 0,
+            // temporary member used to store an orientation when the floating
+            // anchor is hovering over another anchor.
+            orientation = null,
+            _lastResult = null;
+
+        // clear from parent. we want floating anchor orientation to always be computed.
+        this.orientation = null;
+
+        // set these to 0 each; they are used by certain types of connectors in the loopback case,
+        // when the connector is trying to clear the element it is on. but for floating anchor it's not
+        // very important.
+        this.x = 0; this.y = 0;
+
+        this.isFloating = true;
+
+		this.compute = function(params) {
+			var xy = params.xy, element = params.element,
+				result = [ xy[0] + (size[0] / 2), xy[1] + (size[1] / 2) ]; // return origin of the element. we may wish to improve this so that any object can be the drag proxy.
+			_lastResult = result;
+			return result;
+		};
+
+        this.getOrientation = function(_endpoint) {
+            if (orientation) return orientation;
+            else {
+                var o = ref.getOrientation(_endpoint);
+                // here we take into account the orientation of the other
+                // anchor: if it declares zero for some direction, we declare zero too. this might not be the most awesome. perhaps we can come
+                // up with a better way. it's just so that the line we draw looks like it makes sense. maybe this wont make sense.
+                return [ Math.abs(o[0]) * xDir * -1,
+                        Math.abs(o[1]) * yDir * -1 ];
+            }
+        };
+
+        /**
+         * notification the endpoint associated with this anchor is hovering
+         * over another anchor; we want to assume that anchor's orientation
+         * for the duration of the hover.
+         */
+        this.over = function(anchor, endpoint) { 
+            orientation = anchor.getOrientation(endpoint); 
+        };
+
+        /**
+         * notification the endpoint associated with this anchor is no
+         * longer hovering over another anchor; we should resume calculating
+         * orientation as we normally do.
+         */
+        this.out = function() { orientation = null; };
+
+        this.getCurrentLocation = function(params) { return _lastResult == null ? this.compute(params) : _lastResult; };
+    };
+    jsPlumbUtil.extend(jsPlumb.FloatingAnchor, jsPlumb.Anchor);
+
+    var _convertAnchor = function(anchor, jsPlumbInstance, elementId) { 
+        return anchor.constructor == jsPlumb.Anchor ? anchor: jsPlumbInstance.makeAnchor(anchor, elementId, jsPlumbInstance); 
+    };
+
+    /* 
+     * A DynamicAnchor is an Anchor that contains a list of other Anchors, which it cycles
+     * through at compute time to find the one that is located closest to
+     * the center of the target element, and returns that Anchor's compute
+     * method result. this causes endpoints to follow each other with
+     * respect to the orientation of their target elements, which is a useful
+     * feature for some applications.
+     * 
+     */
+    jsPlumb.DynamicAnchor = function(params) {
+        jsPlumb.Anchor.apply(this, arguments);
+        
+        this.isSelective = true;
+        this.isDynamic = true;			
+        this.anchors = [];
+        this.elementId = params.elementId;
+        this.jsPlumbInstance = params.jsPlumbInstance;
+
+        for (var i = 0; i < params.anchors.length; i++) 
+            this.anchors[i] = _convertAnchor(params.anchors[i], this.jsPlumbInstance, this.elementId);			
+        this.addAnchor = function(anchor) { this.anchors.push(_convertAnchor(anchor, this.jsPlumbInstance, this.elementId)); };
+        this.getAnchors = function() { return this.anchors; };
+        this.locked = false;
+        var _curAnchor = this.anchors.length > 0 ? this.anchors[0] : null,
+            _curIndex = this.anchors.length > 0 ? 0 : -1,
+            _lastAnchor = _curAnchor,
+            self = this,
+        
+            // helper method to calculate the distance between the centers of the two elements.
+            _distance = function(anchor, cx, cy, xy, wh) {
+                var ax = xy[0] + (anchor.x * wh[0]), ay = xy[1] + (anchor.y * wh[1]),				
+                    acx = xy[0] + (wh[0] / 2), acy = xy[1] + (wh[1] / 2);
+                return (Math.sqrt(Math.pow(cx - ax, 2) + Math.pow(cy - ay, 2)) +
+                        Math.sqrt(Math.pow(acx - ax, 2) + Math.pow(acy - ay, 2)));
+            },        
+            // default method uses distance between element centers.  you can provide your own method in the dynamic anchor
+            // constructor (and also to jsPlumb.makeDynamicAnchor). the arguments to it are four arrays: 
+            // xy - xy loc of the anchor's element
+            // wh - anchor's element's dimensions
+            // txy - xy loc of the element of the other anchor in the connection
+            // twh - dimensions of the element of the other anchor in the connection.
+            // anchors - the list of selectable anchors
+            _anchorSelector = params.selector || function(xy, wh, txy, twh, anchors) {
+                var cx = txy[0] + (twh[0] / 2), cy = txy[1] + (twh[1] / 2);
+                var minIdx = -1, minDist = Infinity;
+                for ( var i = 0; i < anchors.length; i++) {
+                    var d = _distance(anchors[i], cx, cy, xy, wh);
+                    if (d < minDist) {
+                        minIdx = i + 0;
+                        minDist = d;
+                    }
+                }
+                return anchors[minIdx];
+            };
+        
+        this.compute = function(params) {				
+            var xy = params.xy, wh = params.wh, timestamp = params.timestamp, txy = params.txy, twh = params.twh;
+
+            this.timestamp = timestamp;            
+            
+            var udl = self.getUserDefinedLocation();
+            if (udl != null) {
+                return udl;
+            }
+            
+            // if anchor is locked or an opposite element was not given, we
+            // maintain our state. anchor will be locked
+            // if it is the source of a drag and drop.
+            if (this.locked || txy == null || twh == null)
+                return _curAnchor.compute(params);				
+            else
+                params.timestamp = null; // otherwise clear this, i think. we want the anchor to compute.
+            
+            _curAnchor = _anchorSelector(xy, wh, txy, twh, this.anchors);
+            this.x = _curAnchor.x;
+            this.y = _curAnchor.y;        
+
+            if (_curAnchor != _lastAnchor)
+                this.fire("anchorChanged", _curAnchor);
+
+            _lastAnchor = _curAnchor;
+            
+            return _curAnchor.compute(params);
+        };
+
+        this.getCurrentLocation = function(params) {
+            return this.getUserDefinedLocation() || (_curAnchor != null ? _curAnchor.getCurrentLocation(params) : null);
+        };
+
+        this.getOrientation = function(_endpoint) { return _curAnchor != null ? _curAnchor.getOrientation(_endpoint) : [ 0, 0 ]; };
+        this.over = function(anchor, endpoint) { if (_curAnchor != null) _curAnchor.over(anchor, endpoint); };
+        this.out = function() { if (_curAnchor != null) _curAnchor.out(); };
+
+        this.getCssClass = function() { return (_curAnchor && _curAnchor.getCssClass()) || ""; };
+    };    
+    jsPlumbUtil.extend(jsPlumb.DynamicAnchor, jsPlumb.Anchor);        
+    
+// -------- basic anchors ------------------    
+    var _curryAnchor = function(x, y, ox, oy, type, fnInit) {
+        jsPlumb.Anchors[type] = function(params) {
+            var a = params.jsPlumbInstance.makeAnchor([ x, y, ox, oy, 0, 0 ], params.elementId, params.jsPlumbInstance);
+            a.type = type;
+            if (fnInit) fnInit(a, params);
+            return a;
+        };
+    };
+    	
+	_curryAnchor(0.5, 0, 0,-1, "TopCenter");
+    _curryAnchor(0.5, 1, 0, 1, "BottomCenter");
+    _curryAnchor(0, 0.5, -1, 0, "LeftMiddle");
+    _curryAnchor(1, 0.5, 1, 0, "RightMiddle");
+    // from 1.4.2: Top, Right, Bottom, Left
+    _curryAnchor(0.5, 0, 0,-1, "Top");
+    _curryAnchor(0.5, 1, 0, 1, "Bottom");
+    _curryAnchor(0, 0.5, -1, 0, "Left");
+    _curryAnchor(1, 0.5, 1, 0, "Right");
+    _curryAnchor(0.5, 0.5, 0, 0, "Center");
+    _curryAnchor(1, 0, 0,-1, "TopRight");
+    _curryAnchor(1, 1, 0, 1, "BottomRight");
+    _curryAnchor(0, 0, 0, -1, "TopLeft");
+    _curryAnchor(0, 1, 0, 1, "BottomLeft");
+    
+// ------- dynamic anchors -------------------    
+			
+    // default dynamic anchors chooses from Top, Right, Bottom, Left
+	jsPlumb.Defaults.DynamicAnchors = function(params) {
+		return params.jsPlumbInstance.makeAnchors(["TopCenter", "RightMiddle", "BottomCenter", "LeftMiddle"], params.elementId, params.jsPlumbInstance);
+	};
+    
+    // default dynamic anchors bound to name 'AutoDefault'
+	jsPlumb.Anchors.AutoDefault  = function(params) { 
+		var a = params.jsPlumbInstance.makeDynamicAnchor(jsPlumb.Defaults.DynamicAnchors(params));
+		a.type = "AutoDefault";
+		return a;
+	};	
+    
+// ------- continuous anchors -------------------    
+    
+    var _curryContinuousAnchor = function(type, faces) {
+        jsPlumb.Anchors[type] = function(params) {
+            var a = params.jsPlumbInstance.makeAnchor(["Continuous", { faces:faces }], params.elementId, params.jsPlumbInstance);
+            a.type = type;
+            return a;
+        };
+    };
+    
+    jsPlumb.Anchors.Continuous = function(params) {
+		return params.jsPlumbInstance.continuousAnchorFactory.get(params);
+	};
+                
+    _curryContinuousAnchor("ContinuousLeft", ["left"]);    
+    _curryContinuousAnchor("ContinuousTop", ["top"]);                 
+    _curryContinuousAnchor("ContinuousBottom", ["bottom"]);                 
+    _curryContinuousAnchor("ContinuousRight", ["right"]); 
+    
+// ------- position assign anchors -------------------    
+    
+    // this anchor type lets you assign the position at connection time.
+	_curryAnchor(0, 0, 0, 0, "Assign", function(anchor, params) {
+		// find what to use as the "position finder". the user may have supplied a String which represents
+		// the id of a position finder in jsPlumb.AnchorPositionFinders, or the user may have supplied the
+		// position finder as a function.  we find out what to use and then set it on the anchor.
+		var pf = params.position || "Fixed";
+		anchor.positionFinder = pf.constructor == String ? params.jsPlumbInstance.AnchorPositionFinders[pf] : pf;
+		// always set the constructor params; the position finder might need them later (the Grid one does,
+		// for example)
+		anchor.constructorParams = params;
+	});	
+
+    // these are the default anchor positions finders, which are used by the makeTarget function.  supplying
+    // a position finder argument to that function allows you to specify where the resulting anchor will
+    // be located
+	jsPlumbInstance.prototype.AnchorPositionFinders = {
+		"Fixed": function(dp, ep, es, params) {
+			return [ (dp.left - ep.left) / es[0], (dp.top - ep.top) / es[1] ];	
+		},
+		"Grid":function(dp, ep, es, params) {
+			var dx = dp.left - ep.left, dy = dp.top - ep.top,
+				gx = es[0] / (params.grid[0]), gy = es[1] / (params.grid[1]),
+				mx = Math.floor(dx / gx), my = Math.floor(dy / gy);
+			return [ ((mx * gx) + (gx / 2)) / es[0], ((my * gy) + (gy / 2)) / es[1] ];
+		}
+	};
+    
+// ------- perimeter anchors -------------------    
+		
+	jsPlumb.Anchors.Perimeter = function(params) {
+		params = params || {};
+		var anchorCount = params.anchorCount || 60,
+			shape = params.shape;
+		
+		if (!shape) throw new Error("no shape supplied to Perimeter Anchor type");		
+		
+		var _circle = function() {
+                var r = 0.5, step = Math.PI * 2 / anchorCount, current = 0, a = [];
+                for (var i = 0; i < anchorCount; i++) {
+                    var x = r + (r * Math.sin(current)),
+                        y = r + (r * Math.cos(current));                                
+                    a.push( [ x, y, 0, 0 ] );
+                    current += step;
+                }
+                return a;	
+            },
+            _path = function(segments) {
+                var anchorsPerFace = anchorCount / segments.length, a = [],
+                    _computeFace = function(x1, y1, x2, y2, fractionalLength) {
+                        anchorsPerFace = anchorCount * fractionalLength;
+                        var dx = (x2 - x1) / anchorsPerFace, dy = (y2 - y1) / anchorsPerFace;
+                        for (var i = 0; i < anchorsPerFace; i++) {
+                            a.push( [
+                                x1 + (dx * i),
+                                y1 + (dy * i),
+                                0,
+                                0
+                            ]);
+                        }
+                    };
+								
+                for (var i = 0; i < segments.length; i++)
+                    _computeFace.apply(null, segments[i]);
+														
+                return a;					
+            },
+			_shape = function(faces) {												
+                var s = [];
+                for (var i = 0; i < faces.length; i++) {
+                    s.push([faces[i][0], faces[i][1], faces[i][2], faces[i][3], 1 / faces.length]);
+                }
+                return _path(s);
+			},
+			_rectangle = function() {
+				return _shape([
+					[ 0, 0, 1, 0 ], [ 1, 0, 1, 1 ], [ 1, 1, 0, 1 ], [ 0, 1, 0, 0 ]
+				]);		
+			};
+		
+		var _shapes = {
+			"Circle":_circle,
+			"Ellipse":_circle,
+			"Diamond":function() {
+				return _shape([
+						[ 0.5, 0, 1, 0.5 ], [ 1, 0.5, 0.5, 1 ], [ 0.5, 1, 0, 0.5 ], [ 0, 0.5, 0.5, 0 ]
+				]);
+			},
+			"Rectangle":_rectangle,
+			"Square":_rectangle,
+			"Triangle":function() {
+				return _shape([
+						[ 0.5, 0, 1, 1 ], [ 1, 1, 0, 1 ], [ 0, 1, 0.5, 0]
+				]);	
+			},
+			"Path":function(params) {
+                var points = params.points, p = [], tl = 0;
+				for (var i = 0; i < points.length - 1; i++) {
+                    var l = Math.sqrt(Math.pow(points[i][2] - points[i][0]) + Math.pow(points[i][3] - points[i][1]));
+                    tl += l;
+					p.push([points[i][0], points[i][1], points[i+1][0], points[i+1][1], l]);						
+				}
+                for (var j = 0; j < p.length; j++) {
+                    p[j][4] = p[j][4] / tl;
+                }
+				return _path(p);
+			}
+		},
+        _rotate = function(points, amountInDegrees) {
+            var o = [], theta = amountInDegrees / 180 * Math.PI ;
+            for (var i = 0; i < points.length; i++) {
+                var _x = points[i][0] - 0.5,
+                    _y = points[i][1] - 0.5;
+                    
+                o.push([
+                    0.5 + ((_x * Math.cos(theta)) - (_y * Math.sin(theta))),
+                    0.5 + ((_x * Math.sin(theta)) + (_y * Math.cos(theta))),
+                    points[i][2],
+                    points[i][3]
+                ]);
+            }
+            return o;
+        };
+		
+		if (!_shapes[shape]) throw new Error("Shape [" + shape + "] is unknown by Perimeter Anchor type");
+		
+		var da = _shapes[shape](params);
+        if (params.rotation) da = _rotate(da, params.rotation);
+        var a = params.jsPlumbInstance.makeDynamicAnchor(da);
+		a.type = "Perimeter";
+		return a;
+	};
+})();
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the default Connectors, Endpoint and Overlay definitions.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */  
+;(function() {	
+
+	"use strict";
+
+	jsPlumb.Segments = {
+
+        /*
+         * Class: AbstractSegment
+         * A Connector is made up of 1..N Segments, each of which has a Type, such as 'Straight', 'Arc',
+         * 'Bezier'. This is new from 1.4.2, and gives us a lot more flexibility when drawing connections: things such
+         * as rounded corners for flowchart connectors, for example, or a straight line stub for Bezier connections, are
+         * much easier to do now.
+         *
+         * A Segment is responsible for providing coordinates for painting it, and also must be able to report its length.
+         * 
+         */ 
+        AbstractSegment : function(params) { 
+            this.params = params;
+            
+            /**
+            * Function: findClosestPointOnPath
+            * Finds the closest point on this segment to the given [x, y], 
+            * returning both the x and y of the point plus its distance from
+            * the supplied point, and its location along the length of the
+            * path inscribed by the segment.  This implementation returns
+            * Infinity for distance and null values for everything else;
+            * subclasses are expected to override.
+            */
+            this.findClosestPointOnPath = function(x, y) {
+                return {
+                    d:Infinity,
+                    x:null,
+                    y:null,
+                    l:null
+                };
+            };
+
+            this.getBounds = function() {
+                return {
+                    minX:Math.min(params.x1, params.x2),
+                    minY:Math.min(params.y1, params.y2),
+                    maxX:Math.max(params.x1, params.x2),
+                    maxY:Math.max(params.y1, params.y2)
+                };
+            };
+        },
+        Straight : function(params) {
+            var _super = jsPlumb.Segments.AbstractSegment.apply(this, arguments),
+                length, m, m2, x1, x2, y1, y2,
+                _recalc = function() {
+                    length = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
+                    m = Biltong.gradient({x:x1, y:y1}, {x:x2, y:y2});
+                    m2 = -1 / m;                
+                };
+                
+            this.type = "Straight";
+            
+            this.getLength = function() { return length; };
+            this.getGradient = function() { return m; };
+                
+            this.getCoordinates = function() {
+                return { x1:x1,y1:y1,x2:x2,y2:y2 };
+            };
+            this.setCoordinates = function(coords) {
+                x1 = coords.x1; y1 = coords.y1; x2 = coords.x2; y2 = coords.y2;
+                _recalc();
+            };
+            this.setCoordinates({x1:params.x1, y1:params.y1, x2:params.x2, y2:params.y2});
+
+            this.getBounds = function() {
+                return {
+                    minX:Math.min(x1, x2),
+                    minY:Math.min(y1, y2),
+                    maxX:Math.max(x1, x2),
+                    maxY:Math.max(y1, y2)
+                };
+            };
+            
+            /**
+             * returns the point on the segment's path that is 'location' along the length of the path, where 'location' is a decimal from
+             * 0 to 1 inclusive. for the straight line segment this is simple maths.
+             */
+             this.pointOnPath = function(location, absolute) {
+                if (location === 0 && !absolute)
+                    return { x:x1, y:y1 };
+                else if (location == 1 && !absolute)
+                    return { x:x2, y:y2 };
+                else {
+                    var l = absolute ? location > 0 ? location : length + location : location * length;
+                    return Biltong.pointOnLine({x:x1, y:y1}, {x:x2, y:y2}, l);
+                }
+            };
+            
+            /**
+             * returns the gradient of the segment at the given point - which for us is constant.
+             */
+            this.gradientAtPoint = function(_) {
+                return m;
+            };
+            
+            /**
+             * returns the point on the segment's path that is 'distance' along the length of the path from 'location', where 
+             * 'location' is a decimal from 0 to 1 inclusive, and 'distance' is a number of pixels.
+             * this hands off to jsPlumbUtil to do the maths, supplying two points and the distance.
+             */            
+            this.pointAlongPathFrom = function(location, distance, absolute) {            
+                var p = this.pointOnPath(location, absolute),
+                    farAwayPoint = distance <= 0 ? {x:x1, y:y1} : {x:x2, y:y2 };
+
+                /*
+                location == 1 ? {
+                                        x:x1 + ((x2 - x1) * 10),
+                                        y:y1 + ((y1 - y2) * 10)
+                                    } : 
+                */
+    
+                if (distance <= 0 && Math.abs(distance) > 1) distance *= -1;
+    
+                return Biltong.pointOnLine(p, farAwayPoint, distance);
+            };
+            
+            // is c between a and b?
+            var within = function(a,b,c) {
+                return c >= Math.min(a,b) && c <= Math.max(a,b); 
+            };
+            // find which of a and b is closest to c
+            var closest = function(a,b,c) {
+                return Math.abs(c - a) < Math.abs(c - b) ? a : b;
+            };
+            
+            /**
+                Function: findClosestPointOnPath
+                Finds the closest point on this segment to [x,y]. See
+                notes on this method in AbstractSegment.
+            */
+            this.findClosestPointOnPath = function(x, y) {
+                var out = {
+                    d:Infinity,
+                    x:null,
+                    y:null,
+                    l:null,
+                    x1:x1,
+                    x2:x2,
+                    y1:y1,
+                    y2:y2
+                };
+
+                if (m === 0) {                  
+                    out.y = y1;
+                    out.x = within(x1, x2, x) ? x : closest(x1, x2, x);
+                }
+                else if (m == Infinity || m == -Infinity) {
+                    out.x = x1;                
+                    out.y = within(y1, y2, y) ? y : closest(y1, y2, y);
+                }
+                else {
+                    // closest point lies on normal from given point to this line.  
+                    var b = y1 - (m * x1),
+                        b2 = y - (m2 * x),                    
+                    // y1 = m.x1 + b and y1 = m2.x1 + b2
+                    // so m.x1 + b = m2.x1 + b2
+                    // x1(m - m2) = b2 - b
+                    // x1 = (b2 - b) / (m - m2)
+                        _x1 = (b2 -b) / (m - m2),
+                        _y1 = (m * _x1) + b;
+                                        
+                    out.x = within(x1,x2,_x1) ? _x1 : closest(x1,x2,_x1);//_x1;
+                    out.y = within(y1,y2,_y1) ? _y1 : closest(y1,y2,_y1);//_y1;                    
+                }
+
+                var fractionInSegment = Biltong.lineLength([ out.x, out.y ], [ x1, y1 ]);
+                out.d = Biltong.lineLength([x,y], [out.x, out.y]);
+                out.l = fractionInSegment / length;            
+                return out;
+            };        
+        },
+	
+        /*
+            Arc Segment. You need to supply:
+    
+            r   -   radius
+            cx  -   center x for the arc
+            cy  -   center y for the arc
+            ac  -   whether the arc is anticlockwise or not. default is clockwise.
+    
+            and then either:
+    
+            startAngle  -   startAngle for the arc.
+            endAngle    -   endAngle for the arc.
+    
+            or:
+    
+            x1          -   x for start point
+            y1          -   y for start point
+            x2          -   x for end point
+            y2          -   y for end point
+    
+        */
+        Arc : function(params) {
+            var _super = jsPlumb.Segments.AbstractSegment.apply(this, arguments),
+                _calcAngle = function(_x, _y) {
+                    return Biltong.theta([params.cx, params.cy], [_x, _y]);    
+                },
+                _calcAngleForLocation = function(segment, location) {
+                    if (segment.anticlockwise) {
+                        var sa = segment.startAngle < segment.endAngle ? segment.startAngle + TWO_PI : segment.startAngle,
+                            s = Math.abs(sa - segment.endAngle);
+                        return sa - (s * location);                    
+                    }
+                    else {
+                        var ea = segment.endAngle < segment.startAngle ? segment.endAngle + TWO_PI : segment.endAngle,
+                            ss = Math.abs (ea - segment.startAngle);
+                    
+                        return segment.startAngle + (ss * location);
+                    }
+                },
+                TWO_PI = 2 * Math.PI;
+            
+            this.radius = params.r;
+            this.anticlockwise = params.ac;			
+            this.type = "Arc";
+                
+            if (params.startAngle && params.endAngle) {
+                this.startAngle = params.startAngle;
+                this.endAngle = params.endAngle;            
+                this.x1 = params.cx + (this.radius * Math.cos(params.startAngle));     
+                this.y1 = params.cy + (this.radius * Math.sin(params.startAngle));            
+                this.x2 = params.cx + (this.radius * Math.cos(params.endAngle));     
+                this.y2 = params.cy + (this.radius * Math.sin(params.endAngle));                        
+            }
+            else {
+                this.startAngle = _calcAngle(params.x1, params.y1);
+                this.endAngle = _calcAngle(params.x2, params.y2);            
+                this.x1 = params.x1;
+                this.y1 = params.y1;
+                this.x2 = params.x2;
+                this.y2 = params.y2;            
+            }
+            
+            if (this.endAngle < 0) this.endAngle += TWO_PI;
+            if (this.startAngle < 0) this.startAngle += TWO_PI;   
+
+            // segment is used by vml     
+            this.segment = Biltong.quadrant([this.x1, this.y1], [this.x2, this.y2]);
+            
+            // we now have startAngle and endAngle as positive numbers, meaning the
+            // absolute difference (|d|) between them is the sweep (s) of this arc, unless the
+            // arc is 'anticlockwise' in which case 's' is given by 2PI - |d|.
+            
+            var ea = this.endAngle < this.startAngle ? this.endAngle + TWO_PI : this.endAngle;
+            this.sweep = Math.abs (ea - this.startAngle);
+            if (this.anticlockwise) this.sweep = TWO_PI - this.sweep;
+            var circumference = 2 * Math.PI * this.radius,
+                frac = this.sweep / TWO_PI,
+                length = circumference * frac;
+            
+            this.getLength = function() {
+                return length;
+            };
+
+            this.getBounds = function() {
+                return {
+                    minX:params.cx - params.r,
+                    maxX:params.cx + params.r,
+                    minY:params.cy - params.r,
+                    maxY:params.cy + params.r
+                };
+            };
+            
+            var VERY_SMALL_VALUE = 0.0000000001,
+                gentleRound = function(n) {
+                    var f = Math.floor(n), r = Math.ceil(n);
+                    if (n - f < VERY_SMALL_VALUE) 
+                        return f;    
+                    else if (r - n < VERY_SMALL_VALUE)
+                        return r;
+                    return n;
+                };
+            
+            /**
+             * returns the point on the segment's path that is 'location' along the length of the path, where 'location' is a decimal from
+             * 0 to 1 inclusive. 
+             */
+            this.pointOnPath = function(location, absolute) {            
+                
+                if (location === 0) {
+                    return { x:this.x1, y:this.y1, theta:this.startAngle };    
+                }
+                else if (location == 1) {
+                    return { x:this.x2, y:this.y2, theta:this.endAngle };                    
+                }
+                
+                if (absolute) {
+                    location = location / length;
+                }
+    
+                var angle = _calcAngleForLocation(this, location),
+                    _x = params.cx + (params.r * Math.cos(angle)),
+                    _y  = params.cy + (params.r * Math.sin(angle));					
+    
+                return { x:gentleRound(_x), y:gentleRound(_y), theta:angle };
+            };
+            
+            /**
+             * returns the gradient of the segment at the given point.
+             */
+            this.gradientAtPoint = function(location, absolute) {
+                var p = this.pointOnPath(location, absolute);
+                var m = Biltong.normal( [ params.cx, params.cy ], [p.x, p.y ] );
+                if (!this.anticlockwise && (m == Infinity || m == -Infinity)) m *= -1;
+                return m;
+            };	              
+                    
+            this.pointAlongPathFrom = function(location, distance, absolute) {
+                var p = this.pointOnPath(location, absolute),
+                    arcSpan = distance / circumference * 2 * Math.PI,
+                    dir = this.anticlockwise ? -1 : 1,
+                    startAngle = p.theta + (dir * arcSpan),				
+                    startX = params.cx + (this.radius * Math.cos(startAngle)),
+                    startY = params.cy + (this.radius * Math.sin(startAngle));	
+    
+                return {x:startX, y:startY};
+            };	            
+        },
+	
+        Bezier : function(params) {
+            this.curve = [
+                { x:params.x1, y:params.y1},
+                { x:params.cp1x, y:params.cp1y },
+                { x:params.cp2x, y:params.cp2y },
+                { x:params.x2, y:params.y2 }
+            ];
+
+            var _super = jsPlumb.Segments.AbstractSegment.apply(this, arguments);
+            // although this is not a strictly rigorous determination of bounds
+            // of a bezier curve, it works for the types of curves that this segment
+            // type produces.
+            this.bounds = {
+                minX:Math.min(params.x1, params.x2, params.cp1x, params.cp2x),
+                minY:Math.min(params.y1, params.y2, params.cp1y, params.cp2y),
+                maxX:Math.max(params.x1, params.x2, params.cp1x, params.cp2x),
+                maxY:Math.max(params.y1, params.y2, params.cp1y, params.cp2y)
+            };
+                
+            this.type = "Bezier";            
+            
+            var _translateLocation = function(_curve, location, absolute) {
+                if (absolute)
+                    location = jsBezier.locationAlongCurveFrom(_curve, location > 0 ? 0 : 1, location);
+    
+                return location;
+            };		
+            
+            /**
+             * returns the point on the segment's path that is 'location' along the length of the path, where 'location' is a decimal from
+             * 0 to 1 inclusive. 
+             */
+            this.pointOnPath = function(location, absolute) {
+                location = _translateLocation(this.curve, location, absolute);
+                return jsBezier.pointOnCurve(this.curve, location);
+            };
+            
+            /**
+             * returns the gradient of the segment at the given point.
+             */
+            this.gradientAtPoint = function(location, absolute) {
+                location = _translateLocation(this.curve, location, absolute);
+                return jsBezier.gradientAtPoint(this.curve, location);
+            };	              
+            
+            this.pointAlongPathFrom = function(location, distance, absolute) {
+                location = _translateLocation(this.curve, location, absolute);
+                return jsBezier.pointAlongCurveFrom(this.curve, location, distance);
+            };
+            
+            this.getLength = function() {
+                return jsBezier.getLength(this.curve);
+            };
+
+            this.getBounds = function() {
+                return this.bounds;
+            };
+        }
+    };
+
+	/*
+		Class: AbstractComponent
+		Superclass for AbstractConnector and AbstractEndpoint.
+	*/
+	var AbstractComponent = function() {
+		this.resetBounds = function() {
+			this.bounds = { minX:Infinity, minY:Infinity, maxX:-Infinity, maxY:-Infinity };
+		};
+		this.resetBounds();
+	};
+
+	/*
+	 * Class: AbstractConnector
+	 * Superclass for all Connectors; here is where Segments are managed.  This is exposed on jsPlumb just so it
+	 * can be accessed from other files. You should not try to instantiate one of these directly.
+	 *
+	 * When this class is asked for a pointOnPath, or gradient etc, it must first figure out which segment to dispatch
+	 * that request to. This is done by keeping track of the total connector length as segments are added, and also
+	 * their cumulative ratios to the total length.  Then when the right segment is found it is a simple case of dispatching
+	 * the request to it (and adjusting 'location' so that it is relative to the beginning of that segment.)
+	 */ 
+	jsPlumb.Connectors.AbstractConnector = function(params) {
+		
+		AbstractComponent.apply(this, arguments);
+
+		var segments = [],
+			totalLength = 0,
+			segmentProportions = [],
+			segmentProportionalLengths = [],
+			stub = params.stub || 0, 
+			sourceStub = jsPlumbUtil.isArray(stub) ? stub[0] : stub,
+			targetStub = jsPlumbUtil.isArray(stub) ? stub[1] : stub,
+			gap = params.gap || 0,
+			sourceGap = jsPlumbUtil.isArray(gap) ? gap[0] : gap,
+			targetGap = jsPlumbUtil.isArray(gap) ? gap[1] : gap,
+			userProvidedSegments = null,
+			edited = false,
+			paintInfo = null;
+
+		// to be overridden by subclasses.
+		this.getPath = function() { };
+		this.setPath = function(path) { };
+        
+        /**
+        * Function: findSegmentForPoint
+        * Returns the segment that is closest to the given [x,y],
+        * null if nothing found.  This function returns a JS 
+        * object with:
+        *
+        *   d   -   distance from segment
+        *   l   -   proportional location in segment
+        *   x   -   x point on the segment
+        *   y   -   y point on the segment
+        *   s   -   the segment itself.
+        */ 
+        this.findSegmentForPoint = function(x, y) {
+            var out = { d:Infinity, s:null, x:null, y:null, l:null };
+            for (var i = 0; i < segments.length; i++) {
+                var _s = segments[i].findClosestPointOnPath(x, y);
+                if (_s.d < out.d) {
+                    out.d = _s.d; 
+                    out.l = _s.l; 
+                    out.x = _s.x;
+                    out.y = _s.y; 
+                    out.s = segments[i];
+                    out.x1 = _s.x1;
+                    out.x2 = _s.x2;
+                    out.y1 = _s.y1;
+                    out.y2 = _s.y2;
+                    out.index = i;
+                }
+            }
+            
+            return out;
+        };
+
+		var _updateSegmentProportions = function() {
+                var curLoc = 0;
+                for (var i = 0; i < segments.length; i++) {
+                    var sl = segments[i].getLength();
+                    segmentProportionalLengths[i] = sl / totalLength;
+                    segmentProportions[i] = [curLoc, (curLoc += (sl / totalLength)) ];
+                }
+            },
+		
+            /**
+             * returns [segment, proportion of travel in segment, segment index] for the segment 
+             * that contains the point which is 'location' distance along the entire path, where 
+             * 'location' is a decimal between 0 and 1 inclusive. in this connector type, paths 
+             * are made up of a list of segments, each of which contributes some fraction to
+             * the total length. 
+             * From 1.3.10 this also supports the 'absolute' property, which lets us specify a location
+             * as the absolute distance in pixels, rather than a proportion of the total path. 
+             */
+            _findSegmentForLocation = function(location, absolute) {
+				if (absolute) {
+					location = location > 0 ? location / totalLength : (totalLength + location) / totalLength;
+				}
+				var idx = segmentProportions.length - 1, inSegmentProportion = 1;
+				for (var i = 0; i < segmentProportions.length; i++) {
+					if (segmentProportions[i][1] >= location) {
+						idx = i;
+						// todo is this correct for all connector path types?
+						inSegmentProportion = location == 1 ? 1 : location === 0 ? 0 : (location - segmentProportions[i][0]) / segmentProportionalLengths[i];                    
+						break;
+					}
+				}
+				return { segment:segments[idx], proportion:inSegmentProportion, index:idx };
+			},
+			_addSegment = function(conn, type, params) {
+				if (params.x1 == params.x2 && params.y1 == params.y2) return;
+				var s = new jsPlumb.Segments[type](params);
+				segments.push(s);
+				totalLength += s.getLength();
+				conn.updateBounds(s);
+			},
+			_clearSegments = function() {
+				totalLength = segments.length = segmentProportions.length = segmentProportionalLengths.length = 0;
+			};
+
+		this.setSegments = function(_segs) {
+			userProvidedSegments = [];
+			totalLength = 0;
+			for (var i = 0; i < _segs.length; i++) {
+				userProvidedSegments.push(_segs[i]);
+				totalLength += _segs[i].getLength();
+			}
+		};
+
+        var _prepareCompute = function(params) {
+            this.lineWidth = params.lineWidth;
+            var segment = Biltong.quadrant(params.sourcePos, params.targetPos),
+                swapX = params.targetPos[0] < params.sourcePos[0],
+                swapY = params.targetPos[1] < params.sourcePos[1],
+                lw = params.lineWidth || 1,       
+                so = params.sourceEndpoint.anchor.getOrientation(params.sourceEndpoint), 
+                to = params.targetEndpoint.anchor.getOrientation(params.targetEndpoint),
+                x = swapX ? params.targetPos[0] : params.sourcePos[0], 
+                y = swapY ? params.targetPos[1] : params.sourcePos[1],
+                w = Math.abs(params.targetPos[0] - params.sourcePos[0]),
+                h = Math.abs(params.targetPos[1] - params.sourcePos[1]);
+
+            // if either anchor does not have an orientation set, we derive one from their relative
+            // positions.  we fix the axis to be the one in which the two elements are further apart, and
+            // point each anchor at the other element.  this is also used when dragging a new connection.
+            if (so[0] === 0 && so[1] === 0 || to[0] === 0 && to[1] === 0) {
+                var index = w > h ? 0 : 1, oIndex = [1,0][index];
+                so = []; to = [];
+                so[index] = params.sourcePos[index] > params.targetPos[index] ? -1 : 1;
+                to[index] = params.sourcePos[index] > params.targetPos[index] ? 1 : -1;
+                so[oIndex] = 0; to[oIndex] = 0;
+            }                    
+            
+            var sx = swapX ? w + (sourceGap * so[0])  : sourceGap * so[0], 
+                sy = swapY ? h + (sourceGap * so[1])  : sourceGap * so[1], 
+                tx = swapX ? targetGap * to[0] : w + (targetGap * to[0]),
+                ty = swapY ? targetGap * to[1] : h + (targetGap * to[1]),
+                oProduct = ((so[0] * to[0]) + (so[1] * to[1]));        
+            
+            var result = {
+                sx:sx, sy:sy, tx:tx, ty:ty, lw:lw, 
+                xSpan:Math.abs(tx - sx),
+                ySpan:Math.abs(ty - sy),                
+                mx:(sx + tx) / 2,
+                my:(sy + ty) / 2,                
+                so:so, to:to, x:x, y:y, w:w, h:h,
+                segment : segment,
+                startStubX : sx + (so[0] * sourceStub), 
+                startStubY : sy + (so[1] * sourceStub),
+                endStubX : tx + (to[0] * targetStub), 
+                endStubY : ty + (to[1] * targetStub),
+                isXGreaterThanStubTimes2 : Math.abs(sx - tx) > (sourceStub + targetStub),
+                isYGreaterThanStubTimes2 : Math.abs(sy - ty) > (sourceStub + targetStub),
+                opposite:oProduct == -1,
+                perpendicular:oProduct === 0,
+                orthogonal:oProduct == 1,
+                sourceAxis : so[0] === 0 ? "y" : "x",
+                points:[x, y, w, h, sx, sy, tx, ty ]
+            };
+            result.anchorOrientation = result.opposite ? "opposite" : result.orthogonal ? "orthogonal" : "perpendicular";
+            return result;
+        };
+		
+		this.getSegments = function() { return segments; };
+
+        this.updateBounds = function(segment) {
+            var segBounds = segment.getBounds();
+            this.bounds.minX = Math.min(this.bounds.minX, segBounds.minX);
+            this.bounds.maxX = Math.max(this.bounds.maxX, segBounds.maxX);
+            this.bounds.minY = Math.min(this.bounds.minY, segBounds.minY);
+            this.bounds.maxY = Math.max(this.bounds.maxY, segBounds.maxY);              
+        };
+        
+        var dumpSegmentsToConsole = function() {
+            console.log("SEGMENTS:");
+            for (var i = 0; i < segments.length; i++) {
+                console.log(segments[i].type, segments[i].getLength(), segmentProportions[i]);
+            }
+        };
+
+		this.pointOnPath = function(location, absolute) {
+            var seg = _findSegmentForLocation(location, absolute);
+            return seg.segment && seg.segment.pointOnPath(seg.proportion, false) || [0,0];
+        };
+        
+        this.gradientAtPoint = function(location, absolute) {
+            var seg = _findSegmentForLocation(location, absolute);          
+            return seg.segment && seg.segment.gradientAtPoint(seg.proportion, false) || 0;
+        };
+        
+        this.pointAlongPathFrom = function(location, distance, absolute) {
+            var seg = _findSegmentForLocation(location, absolute);
+            // TODO what happens if this crosses to the next segment?
+            return seg.segment && seg.segment.pointAlongPathFrom(seg.proportion, distance, false) || [0,0];
+        };
+		
+		this.compute = function(params)  {
+            if (!edited)
+                paintInfo = _prepareCompute.call(this, params);
+            
+            _clearSegments();
+            this._compute(paintInfo, params);
+            this.x = paintInfo.points[0];
+            this.y = paintInfo.points[1];
+            this.w = paintInfo.points[2];
+            this.h = paintInfo.points[3];               
+            this.segment = paintInfo.segment;         
+            _updateSegmentProportions();            
+		};
+		
+		return {
+			addSegment:_addSegment,
+            prepareCompute:_prepareCompute,
+            sourceStub:sourceStub,
+            targetStub:targetStub,
+            maxStub:Math.max(sourceStub, targetStub),            
+            sourceGap:sourceGap,
+            targetGap:targetGap,
+            maxGap:Math.max(sourceGap, targetGap)
+		};		
+	};
+    jsPlumbUtil.extend(jsPlumb.Connectors.AbstractConnector, AbstractComponent);
+	
+    /**
+     * Class: Connectors.Straight
+     * The Straight connector draws a simple straight line between the two anchor points.  It does not have any constructor parameters.
+     */
+    var Straight = jsPlumb.Connectors.Straight = function() {
+    	this.type = "Straight";
+		var _super =  jsPlumb.Connectors.AbstractConnector.apply(this, arguments);		
+
+        this._compute = function(paintInfo, _) {                        
+            _super.addSegment(this, "Straight", {x1:paintInfo.sx, y1:paintInfo.sy, x2:paintInfo.startStubX, y2:paintInfo.startStubY});                                                
+            _super.addSegment(this, "Straight", {x1:paintInfo.startStubX, y1:paintInfo.startStubY, x2:paintInfo.endStubX, y2:paintInfo.endStubY});                        
+            _super.addSegment(this, "Straight", {x1:paintInfo.endStubX, y1:paintInfo.endStubY, x2:paintInfo.tx, y2:paintInfo.ty});                                    
+        };                    
+    };
+    jsPlumbUtil.extend(jsPlumb.Connectors.Straight, jsPlumb.Connectors.AbstractConnector);
+    jsPlumb.registerConnectorType(Straight, "Straight");
+
+
+ // ********************************* END OF CONNECTOR TYPES *******************************************************************
+    
+ // ********************************* ENDPOINT TYPES *******************************************************************
+    
+    jsPlumb.Endpoints.AbstractEndpoint = function(params) {
+        AbstractComponent.apply(this, arguments);
+        var compute = this.compute = function(anchorPoint, orientation, endpointStyle, connectorPaintStyle) {    
+            var out = this._compute.apply(this, arguments);
+            this.x = out[0];
+            this.y = out[1];
+            this.w = out[2];
+            this.h = out[3];
+            this.bounds.minX = this.x;
+            this.bounds.minY = this.y;
+            this.bounds.maxX = this.x + this.w;
+            this.bounds.maxY = this.y + this.h;
+            return out;
+        };
+        return {
+            compute:compute,
+            cssClass:params.cssClass
+        };
+    };
+    jsPlumbUtil.extend(jsPlumb.Endpoints.AbstractEndpoint, AbstractComponent);
+    
+    /**
+     * Class: Endpoints.Dot
+     * A round endpoint, with default radius 10 pixels.
+     */    	
+    	
+	/**
+	 * Function: Constructor
+	 * 
+	 * Parameters:
+	 * 
+	 * 	radius	-	radius of the endpoint.  defaults to 10 pixels.
+	 */
+	jsPlumb.Endpoints.Dot = function(params) {        
+		this.type = "Dot";
+		var _super = jsPlumb.Endpoints.AbstractEndpoint.apply(this, arguments);
+		params = params || {};				
+		this.radius = params.radius || 10;
+		this.defaultOffset = 0.5 * this.radius;
+		this.defaultInnerRadius = this.radius / 3;			
+		
+		this._compute = function(anchorPoint, orientation, endpointStyle, connectorPaintStyle) {
+			this.radius = endpointStyle.radius || this.radius;
+			var	x = anchorPoint[0] - this.radius,
+				y = anchorPoint[1] - this.radius,
+                w = this.radius * 2,
+                h = this.radius * 2;
+
+            if (endpointStyle.strokeStyle) {
+                var lw = endpointStyle.lineWidth || 1;
+                x -= lw;
+                y -= lw;
+                w += (lw * 2);
+                h += (lw * 2);
+            }
+			return [ x, y, w, h, this.radius ];
+		};
+	};
+    jsPlumbUtil.extend(jsPlumb.Endpoints.Dot, jsPlumb.Endpoints.AbstractEndpoint);
+
+	jsPlumb.Endpoints.Rectangle = function(params) {
+		this.type = "Rectangle";
+		var _super = jsPlumb.Endpoints.AbstractEndpoint.apply(this, arguments);
+		params = params || {};
+		this.width = params.width || 20;
+		this.height = params.height || 20;
+
+		this._compute = function(anchorPoint, orientation, endpointStyle, connectorPaintStyle) {
+			var width = endpointStyle.width || this.width,
+				height = endpointStyle.height || this.height,
+				x = anchorPoint[0] - (width/2),
+				y = anchorPoint[1] - (height/2);
+
+			return [ x, y, width, height];
+		};
+	};
+	jsPlumbUtil.extend(jsPlumb.Endpoints.Rectangle, jsPlumb.Endpoints.AbstractEndpoint);
+
+	var DOMElementEndpoint = function(params) {
+        jsPlumb.jsPlumbUIComponent.apply(this, arguments);
+		this._jsPlumb.displayElements = [];
+	};
+	jsPlumbUtil.extend(DOMElementEndpoint, jsPlumb.jsPlumbUIComponent, {
+		getDisplayElements : function() { 
+			return this._jsPlumb.displayElements; 
+		},
+		appendDisplayElement : function(el) {
+			this._jsPlumb.displayElements.push(el);
+		}
+	});
+
+	/**
+	 * Class: Endpoints.Image
+	 * Draws an image as the Endpoint.
+	 */
+	/**
+	 * Function: Constructor
+	 * 
+	 * Parameters:
+	 * 
+	 * 	src	-	location of the image to use.
+
+    TODO: multiple references to self. not sure quite how to get rid of them entirely. perhaps self = null in the cleanup
+    function will suffice
+
+    TODO this class still leaks memory.
+
+	 */
+	jsPlumb.Endpoints.Image = function(params) {
+
+		this.type = "Image";
+		DOMElementEndpoint.apply(this, arguments);
+		jsPlumb.Endpoints.AbstractEndpoint.apply(this, arguments);
+
+		var _onload = params.onload, 
+			src = params.src || params.url,
+			clazz = params.cssClass ? " " + params.cssClass : "";
+
+		this._jsPlumb.img = new Image();
+		this._jsPlumb.ready = false;
+		this._jsPlumb.initialized = false;
+		this._jsPlumb.deleted = false;
+		this._jsPlumb.widthToUse = params.width;
+		this._jsPlumb.heightToUse = params.height;
+		this._jsPlumb.endpoint = params.endpoint;
+
+		this._jsPlumb.img.onload = function() {
+			if (this._jsPlumb != null) {
+				this._jsPlumb.ready = true;
+				this._jsPlumb.widthToUse = this._jsPlumb.widthToUse || this._jsPlumb.img.width;
+				this._jsPlumb.heightToUse = this._jsPlumb.heightToUse || this._jsPlumb.img.height;
+				if (_onload) {
+					_onload(this);
+				}
+			}
+		}.bind(this);
+
+        /*
+            Function: setImage
+            Sets the Image to use in this Endpoint.  
+
+            Parameters:
+            img         -   may be a URL or an Image object
+            onload      -   optional; a callback to execute once the image has loaded.
+        */
+        this._jsPlumb.endpoint.setImage = function(_img, onload) {
+            var s = _img.constructor == String ? _img : _img.src;
+            _onload = onload; 
+            this._jsPlumb.img.src = s;
+
+            if (this.canvas != null)
+                this.canvas.setAttribute("src", this._jsPlumb.img.src);
+        }.bind(this);
+
+		this._jsPlumb.endpoint.setImage(src, _onload);
+		this._compute = function(anchorPoint, orientation, endpointStyle, connectorPaintStyle) {
+			this.anchorPoint = anchorPoint;
+			if (this._jsPlumb.ready) return [anchorPoint[0] - this._jsPlumb.widthToUse / 2, anchorPoint[1] - this._jsPlumb.heightToUse / 2, 
+									this._jsPlumb.widthToUse, this._jsPlumb.heightToUse];
+			else return [0,0,0,0];
+		};
+		
+		this.canvas = document.createElement("img");
+		this.canvas.style.margin = 0;
+		this.canvas.style.padding = 0;
+		this.canvas.style.outline = 0;
+		this.canvas.style.position = "absolute";		
+		this.canvas.className = this._jsPlumb.instance.endpointClass + clazz;
+		if (this._jsPlumb.widthToUse) this.canvas.setAttribute("width", this._jsPlumb.widthToUse);
+		if (this._jsPlumb.heightToUse) this.canvas.setAttribute("height", this._jsPlumb.heightToUse);		
+		this._jsPlumb.instance.appendElement(this.canvas);
+		
+		this.actuallyPaint = function(d, style, anchor) {
+			if (!this._jsPlumb.deleted) {
+				if (!this._jsPlumb.initialized) {
+					this.canvas.setAttribute("src", this._jsPlumb.img.src);
+					this.appendDisplayElement(this.canvas);
+					this._jsPlumb.initialized = true;
+				}
+				var x = this.anchorPoint[0] - (this._jsPlumb.widthToUse / 2),
+					y = this.anchorPoint[1] - (this._jsPlumb.heightToUse / 2);
+				jsPlumbUtil.sizeElement(this.canvas, x, y, this._jsPlumb.widthToUse, this._jsPlumb.heightToUse);
+			}
+		};
+		
+		this.paint = function(style, anchor) {
+            if (this._jsPlumb != null) {  // may have been deleted
+    			if (this._jsPlumb.ready) {
+        			this.actuallyPaint(style, anchor);
+    			}
+    			else { 
+    				window.setTimeout(function() {
+    					this.paint(style, anchor);
+    				}.bind(this), 200);
+    			}
+            }
+		};				
+	};
+    jsPlumbUtil.extend(jsPlumb.Endpoints.Image, [ DOMElementEndpoint, jsPlumb.Endpoints.AbstractEndpoint ], {
+        cleanup : function() {            
+            this._jsPlumb.deleted = true;
+            if (this.canvas) this.canvas.parentNode.removeChild(this.canvas);
+            this.canvas = null;
+        } 
+    });
+	
+	/*
+	 * Class: Endpoints.Blank
+	 * An Endpoint that paints nothing (visible) on the screen.  Supports cssClass and hoverClass parameters like all Endpoints.
+	 */
+	jsPlumb.Endpoints.Blank = function(params) {
+		var _super = jsPlumb.Endpoints.AbstractEndpoint.apply(this, arguments);
+		this.type = "Blank";
+		DOMElementEndpoint.apply(this, arguments);		
+		this._compute = function(anchorPoint, orientation, endpointStyle, connectorPaintStyle) {
+			return [anchorPoint[0], anchorPoint[1],10,0];
+		};
+
+        var clazz = params.cssClass ? " " + params.cssClass : "";
+		
+		this.canvas = document.createElement("div");
+		this.canvas.style.display = "block";
+		this.canvas.style.width = "1px";
+		this.canvas.style.height = "1px";
+		this.canvas.style.background = "transparent";
+		this.canvas.style.position = "absolute";
+		this.canvas.className = this._jsPlumb.instance.endpointClass + clazz;
+		this._jsPlumb.instance.appendElement(this.canvas);
+		
+		this.paint = function(style, anchor) {
+			jsPlumbUtil.sizeElement(this.canvas, this.x, this.y, this.w, this.h);	
+		};
+	};
+    jsPlumbUtil.extend(jsPlumb.Endpoints.Blank, [jsPlumb.Endpoints.AbstractEndpoint, DOMElementEndpoint], {
+        cleanup:function() {
+            if (this.canvas && this.canvas.parentNode) {
+                this.canvas.parentNode.removeChild(this.canvas);
+            }
+        }
+    });
+	
+	/*
+	 * Class: Endpoints.Triangle
+	 * A triangular Endpoint.  
+	 */
+	/*
+	 * Function: Constructor
+	 * 
+	 * Parameters:
+	 * 
+	 * 	width	-	width of the triangle's base.  defaults to 55 pixels.
+	 * 	height	-	height of the triangle from base to apex.  defaults to 55 pixels.
+	 */
+	jsPlumb.Endpoints.Triangle = function(params) {        
+		this.type = "Triangle";
+        jsPlumb.Endpoints.AbstractEndpoint.apply(this, arguments);
+		params = params || {  };
+		params.width = params.width || 55;
+		params.height = params.height || 55;
+		this.width = params.width;
+		this.height = params.height;
+		this._compute = function(anchorPoint, orientation, endpointStyle, connectorPaintStyle) {
+			var width = endpointStyle.width || self.width,
+			height = endpointStyle.height || self.height,
+			x = anchorPoint[0] - (width/2),
+			y = anchorPoint[1] - (height/2);
+			return [ x, y, width, height ];
+		};
+	};
+// ********************************* END OF ENDPOINT TYPES *******************************************************************
+	
+
+// ********************************* OVERLAY DEFINITIONS ***********************************************************************    
+
+	var AbstractOverlay = jsPlumb.Overlays.AbstractOverlay = function(params) {
+		this.visible = true;
+        this.isAppendedAtTopLevel = true;
+		this.component = params.component;
+		this.loc = params.location == null ? 0.5 : params.location;
+        this.endpointLoc = params.endpointLocation == null ? [ 0.5, 0.5] : params.endpointLocation;
+	};
+    AbstractOverlay.prototype = {
+        cleanup:function() {  
+           this.component = null;
+           this.canvas = null;
+           this.endpointLoc = null;
+        },
+        setVisible : function(val) { 
+            this.visible = val;
+            this.component.repaint();
+        },
+        isVisible : function() { return this.visible; },
+        hide : function() { this.setVisible(false); },
+        show : function() { this.setVisible(true); },        
+        incrementLocation : function(amount) {
+            this.loc += amount;
+            this.component.repaint();
+        },
+        setLocation : function(l) {
+            this.loc = l;
+            this.component.repaint();
+        },
+        getLocation : function() {
+            return this.loc;
+        }
+    };
+	
+	
+	/*
+	 * Class: Overlays.Arrow
+	 * 
+	 * An arrow overlay, defined by four points: the head, the two sides of the tail, and a 'foldback' point at some distance along the length
+	 * of the arrow that lines from each tail point converge into.  The foldback point is defined using a decimal that indicates some fraction
+	 * of the length of the arrow and has a default value of 0.623.  A foldback point value of 1 would mean that the arrow had a straight line
+	 * across the tail.  
+	 */
+	/*
+	 * Function: Constructor
+	 * 
+	 * Parameters:
+	 * 
+	 * 	length - distance in pixels from head to tail baseline. default 20.
+	 * 	width - width in pixels of the tail baseline. default 20.
+	 * 	fillStyle - style to use when filling the arrow.  defaults to "black".
+	 * 	strokeStyle - style to use when stroking the arrow. defaults to null, which means the arrow is not stroked.
+	 * 	lineWidth - line width to use when stroking the arrow. defaults to 1, but only used if strokeStyle is not null.
+	 * 	foldback - distance (as a decimal from 0 to 1 inclusive) along the length of the arrow marking the point the tail points should fold back to.  defaults to 0.623.
+	 * 	location - distance (as a decimal from 0 to 1 inclusive) marking where the arrow should sit on the connector. defaults to 0.5.
+	 * 	direction - indicates the direction the arrow points in. valid values are -1 and 1; 1 is default.
+	 */
+	jsPlumb.Overlays.Arrow = function(params) {
+		this.type = "Arrow";
+		AbstractOverlay.apply(this, arguments);
+        this.isAppendedAtTopLevel = false;
+		params = params || {};
+		var _ju = jsPlumbUtil, _jg = Biltong;
+		
+    	this.length = params.length || 20;
+    	this.width = params.width || 20;
+    	this.id = params.id;
+    	var direction = (params.direction || 1) < 0 ? -1 : 1,
+    	    paintStyle = params.paintStyle || { lineWidth:1 },
+    	    // how far along the arrow the lines folding back in come to. default is 62.3%.
+    	    foldback = params.foldback || 0.623;
+    	    	
+    	this.computeMaxSize = function() { return self.width * 1.5; };    	
+    	this.draw = function(component, currentConnectionPaintStyle) {
+
+            var hxy, mid, txy, tail, cxy;
+            if (component.pointAlongPathFrom) {
+
+                if (_ju.isString(this.loc) || this.loc > 1 || this.loc < 0) {                    
+                    var l = parseInt(this.loc, 10),
+                        fromLoc = this.loc < 0 ? 1 : 0;
+                    hxy = component.pointAlongPathFrom(fromLoc, l, false);
+                    mid = component.pointAlongPathFrom(fromLoc, l - (direction * this.length / 2), false);
+                    txy = _jg.pointOnLine(hxy, mid, this.length);
+                }
+                else if (this.loc == 1) {                
+					hxy = component.pointOnPath(this.loc);					           
+                    mid = component.pointAlongPathFrom(this.loc, -(this.length));
+					txy = _jg.pointOnLine(hxy, mid, this.length);
+					
+					if (direction == -1) {
+						var _ = txy;
+						txy = hxy;
+						hxy = _;
+					}
+                }
+                else if (this.loc === 0) {					                    
+					txy = component.pointOnPath(this.loc);                    
+					mid = component.pointAlongPathFrom(this.loc, this.length);                    
+					hxy = _jg.pointOnLine(txy, mid, this.length);                    
+					if (direction == -1) {
+						var __ = txy;
+						txy = hxy;
+						hxy = __;
+					}
+                }
+                else {                    
+    			    hxy = component.pointAlongPathFrom(this.loc, direction * this.length / 2);
+                    mid = component.pointOnPath(this.loc);
+                    txy = _jg.pointOnLine(hxy, mid, this.length);
+                }
+
+                tail = _jg.perpendicularLineTo(hxy, txy, this.width);
+                cxy = _jg.pointOnLine(hxy, txy, foldback * this.length);    			
+    			
+    			var d = { hxy:hxy, tail:tail, cxy:cxy },
+    			    strokeStyle = paintStyle.strokeStyle || currentConnectionPaintStyle.strokeStyle,
+    			    fillStyle = paintStyle.fillStyle || currentConnectionPaintStyle.strokeStyle,
+    			    lineWidth = paintStyle.lineWidth || currentConnectionPaintStyle.lineWidth;
+
+                return {
+                    component:component,
+                    d:d,
+                    lineWidth:lineWidth,
+                    strokeStyle:strokeStyle,
+                    fillStyle:fillStyle,
+                    minX:Math.min(hxy.x, tail[0].x, tail[1].x),
+                    maxX:Math.max(hxy.x, tail[0].x, tail[1].x),
+                    minY:Math.min(hxy.y, tail[0].y, tail[1].y),
+                    maxY:Math.max(hxy.y, tail[0].y, tail[1].y)
+                };
+            }
+            else return {component:component, minX:0,maxX:0,minY:0,maxY:0};
+    	};
+    };    
+    jsPlumbUtil.extend(jsPlumb.Overlays.Arrow, AbstractOverlay);      
+    
+    /*
+     * Class: Overlays.PlainArrow
+	 * 
+	 * A basic arrow.  This is in fact just one instance of the more generic case in which the tail folds back on itself to some
+	 * point along the length of the arrow: in this case, that foldback point is the full length of the arrow.  so it just does
+	 * a 'call' to Arrow with foldback set appropriately.       
+	 */
+    /*
+     * Function: Constructor
+     * See <Overlays.Arrow> for allowed parameters for this overlay.
+     */
+    jsPlumb.Overlays.PlainArrow = function(params) {
+    	params = params || {};    	
+    	var p = jsPlumb.extend(params, {foldback:1});
+    	jsPlumb.Overlays.Arrow.call(this, p);
+    	this.type = "PlainArrow";
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.PlainArrow, jsPlumb.Overlays.Arrow);
+        
+    /*
+     * Class: Overlays.Diamond
+     * 
+	 * A diamond. Like PlainArrow, this is a concrete case of the more generic case of the tail points converging on some point...it just
+	 * happens that in this case, that point is greater than the length of the the arrow.    
+	 * 
+	 *      this could probably do with some help with positioning...due to the way it reuses the Arrow paint code, what Arrow thinks is the
+	 *      center is actually 1/4 of the way along for this guy.  but we don't have any knowledge of pixels at this point, so we're kind of
+	 *      stuck when it comes to helping out the Arrow class. possibly we could pass in a 'transpose' parameter or something. the value
+	 *      would be -l/4 in this case - move along one quarter of the total length.
+	 */
+    /*
+     * Function: Constructor
+     * See <Overlays.Arrow> for allowed parameters for this overlay.
+     */
+    jsPlumb.Overlays.Diamond = function(params) {
+    	params = params || {};    	
+    	var l = params.length || 40,
+    	    p = jsPlumb.extend(params, {length:l/2, foldback:2});
+    	jsPlumb.Overlays.Arrow.call(this, p);
+    	this.type = "Diamond";
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.Diamond, jsPlumb.Overlays.Arrow);
+
+    var _getDimensions = function(component, forceRefresh) {
+        if (component._jsPlumb.cachedDimensions == null || forceRefresh)
+            component._jsPlumb.cachedDimensions = component.getDimensions();
+        return component._jsPlumb.cachedDimensions;
+    };      
+	
+	// abstract superclass for overlays that add an element to the DOM.
+    var AbstractDOMOverlay = function(params) {
+        jsPlumb.jsPlumbUIComponent.apply(this, arguments);
+    	AbstractOverlay.apply(this, arguments);
+
+        // hand off fired events to associated component.
+        var _f = this.fire;
+        this.fire = function() {
+            _f.apply(this, arguments);
+            if (this.component) this.component.fire.apply(this.component, arguments);
+        };
+
+		this.id = params.id;
+        this._jsPlumb.div = null;
+        this._jsPlumb.initialised = false;
+        this._jsPlumb.component = params.component;
+        this._jsPlumb.cachedDimensions = null;
+        this._jsPlumb.create = params.create;
+        this._jsPlumb.initiallyInvisible = params.visible === false;
+
+		this.getElement = function() {
+			if (this._jsPlumb.div == null) {
+                var div = this._jsPlumb.div = jsPlumb.getDOMElement(this._jsPlumb.create(this._jsPlumb.component));
+                div.style.position   =   "absolute";     
+                div.className = this._jsPlumb.instance.overlayClass + " " +
+                    (this.cssClass ? this.cssClass :
+                        params.cssClass ? params.cssClass : "");
+                this._jsPlumb.instance.appendElement(div);
+                this._jsPlumb.instance.getId(div);
+                this.canvas = div;
+
+                // in IE the top left corner is what it placed at the desired location.  This will not
+                // be fixed. IE8 is not going to be supported for much longer.
+                var ts = "translate(-50%, -50%)";
+                div.style.webkitTransform = ts;
+                div.style.mozTransform = ts;
+                div.style.msTransform = ts;
+                div.style.oTransform = ts;
+                div.style.transform = ts;
+
+                // write the related component into the created element
+                div._jsPlumb = this;
+
+                if (params.visible === false)
+                    div.style.display = "none";
+			}
+    		return this._jsPlumb.div;
+    	};
+
+		this.draw = function(component, currentConnectionPaintStyle, absolutePosition) {
+	    	var td = _getDimensions(this);
+	    	if (td != null && td.length == 2) {
+				var cxy = { x:0,y:0 };
+
+                // absolutePosition would have been set by a call to connection.setAbsoluteOverlayPosition.
+                if (absolutePosition) {
+                    cxy = { x:absolutePosition[0], y:absolutePosition[1] };
+                }
+                else if (component.pointOnPath) {
+                    var loc = this.loc, absolute = false;
+                    if (jsPlumbUtil.isString(this.loc) || this.loc < 0 || this.loc > 1) {
+                        loc = parseInt(this.loc, 10);
+                        absolute = true;
+                    }
+                    cxy = component.pointOnPath(loc, absolute);  // a connection
+                }
+                else {
+                    var locToUse = this.loc.constructor == Array ? this.loc : this.endpointLoc;
+                    cxy = { x:locToUse[0] * component.w,
+                            y:locToUse[1] * component.h };
+                } 
+
+				var minx = cxy.x - (td[0] / 2),
+				    miny = cxy.y - (td[1] / 2);
+
+                return {
+                    component:component, 
+                    d:{ minx:minx, miny:miny, td:td, cxy:cxy },
+                    minX:minx, 
+                    maxX:minx + td[0], 
+                    minY:miny, 
+                    maxY:miny + td[1]
+                };
+        	}
+	    	else return {minX:0,maxX:0,minY:0,maxY:0};
+	    };
+	};
+    jsPlumbUtil.extend(AbstractDOMOverlay, [jsPlumb.jsPlumbUIComponent, AbstractOverlay], {
+        getDimensions : function() {
+// still support the old way, for now, for IE8. But from 2.0.0 this whole method will be gone. 
+            return jsPlumbUtil.oldIE ? jsPlumb.getSize(this.getElement()) : [1,1];
+        },
+        setVisible : function(state) {
+            this._jsPlumb.div.style.display = state ? "block" : "none";
+            // if initially invisible, dimensions are 0,0 and never get updated
+            if (state && this._jsPlumb.initiallyInvisible) {
+                _getDimensions(this, true);
+                this.component.repaint();
+                this._jsPlumb.initiallyInvisible = false;
+            }
+        },
+        /*
+         * Function: clearCachedDimensions
+         * Clears the cached dimensions for the label. As a performance enhancement, label dimensions are
+         * cached from 1.3.12 onwards. The cache is cleared when you change the label text, of course, but
+         * there are other reasons why the text dimensions might change - if you make a change through CSS, for
+         * example, you might change the font size.  in that case you should explicitly call this method.
+         */
+        clearCachedDimensions : function() {
+            this._jsPlumb.cachedDimensions = null;
+        },
+        cleanup : function() {
+            if (this._jsPlumb.div != null) {
+                this._jsPlumb.div._jsPlumb = null;
+                this._jsPlumb.instance.removeElement(this._jsPlumb.div);
+            }
+        },
+        computeMaxSize : function() {
+            var td = _getDimensions(this);
+            return Math.max(td[0], td[1]);
+        },
+        paint : function(p, containerExtents) {
+            if (!this._jsPlumb.initialised) {
+                this.getElement();
+                p.component.appendDisplayElement(this._jsPlumb.div);
+                this._jsPlumb.initialised = true;
+            }
+            this._jsPlumb.div.style.left = (p.component.x + p.d.minx) + "px";
+            this._jsPlumb.div.style.top = (p.component.y + p.d.miny) + "px";
+        }
+    });
+	
+	/*
+     * Class: Overlays.Custom
+     * A Custom overlay. You supply a 'create' function which returns some DOM element, and jsPlumb positions it.
+     * The 'create' function is passed a Connection or Endpoint.
+     */
+    /*
+     * Function: Constructor
+     * 
+     * Parameters:
+     * 	create - function for jsPlumb to call that returns a DOM element.
+     * 	location - distance (as a decimal from 0 to 1 inclusive) marking where the label should sit on the connector. defaults to 0.5.
+     * 	id - optional id to use for later retrieval of this overlay.
+     * 	
+     */
+    jsPlumb.Overlays.Custom = function(params) {
+    	this.type = "Custom";    	
+    	AbstractDOMOverlay.apply(this, arguments);		    	        		    	    		
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.Custom, AbstractDOMOverlay);
+
+    jsPlumb.Overlays.GuideLines = function() {
+        var self = this;
+        self.length = 50;
+        self.lineWidth = 5;
+        this.type = "GuideLines";
+        AbstractOverlay.apply(this, arguments);
+        jsPlumb.jsPlumbUIComponent.apply(this, arguments);
+        this.draw = function(connector, currentConnectionPaintStyle) {
+
+            var head = connector.pointAlongPathFrom(self.loc, self.length / 2),
+                mid = connector.pointOnPath(self.loc),
+                tail = Biltong.pointOnLine(head, mid, self.length),
+                tailLine = Biltong.perpendicularLineTo(head, tail, 40),
+                headLine = Biltong.perpendicularLineTo(tail, head, 20);
+
+            return {
+                connector:connector,
+                head:head,
+                tail:tail,
+                headLine:headLine,
+                tailLine:tailLine,                
+                minX:Math.min(head.x, tail.x, headLine[0].x, headLine[1].x), 
+                minY:Math.min(head.y, tail.y, headLine[0].y, headLine[1].y), 
+                maxX:Math.max(head.x, tail.x, headLine[0].x, headLine[1].x), 
+                maxY:Math.max(head.y, tail.y, headLine[0].y, headLine[1].y)
+            };
+        };
+
+       // this.cleanup = function() { };  // nothing to clean up for GuideLines
+    };
+    
+    /*
+     * Class: Overlays.Label
+     
+     */
+    /*
+     * Function: Constructor
+     * 
+     * Parameters:
+     * 	cssClass - optional css class string to append to css class. This string is appended "as-is", so you can of course have multiple classes
+     *             defined.  This parameter is preferred to using labelStyle, borderWidth and borderStyle.
+     * 	label - the label to paint.  May be a string or a function that returns a string.  Nothing will be painted if your label is null or your
+     *         label function returns null.  empty strings _will_ be painted.
+     * 	location - distance (as a decimal from 0 to 1 inclusive) marking where the label should sit on the connector. defaults to 0.5.
+     * 	id - optional id to use for later retrieval of this overlay.
+     * 
+     * 	
+     */
+    jsPlumb.Overlays.Label =  function(params) {		   
+		this.labelStyle = params.labelStyle;
+        
+        var labelWidth = null, labelHeight =  null, labelText = null, labelPadding = null;
+		this.cssClass = this.labelStyle != null ? this.labelStyle.cssClass : null;
+		var p = jsPlumb.extend({
+            create : function() {
+                return document.createElement("div");
+            }}, params);
+    	jsPlumb.Overlays.Custom.call(this, p);
+		this.type = "Label";    	
+        this.label = params.label || "";
+        this.labelText = null;
+        if (this.labelStyle) {
+            var el = this.getElement();            
+            this.labelStyle.font = this.labelStyle.font || "12px sans-serif";
+            el.style.font = this.labelStyle.font;
+            el.style.color = this.labelStyle.color || "black";
+            if (this.labelStyle.fillStyle) el.style.background = this.labelStyle.fillStyle;
+            if (this.labelStyle.borderWidth > 0) {
+                var dStyle = this.labelStyle.borderStyle ? this.labelStyle.borderStyle : "black";
+                el.style.border = this.labelStyle.borderWidth  + "px solid " + dStyle;
+            }
+            if (this.labelStyle.padding) el.style.padding = this.labelStyle.padding;            
+        }
+
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.Label, jsPlumb.Overlays.Custom, {
+        cleanup:function() {
+            this.div = null;
+            this.label = null;
+            this.labelText = null;
+            this.cssClass = null;
+            this.labelStyle = null;
+        },
+        getLabel : function() {
+            return this.label;
+        },
+        /*
+         * Function: setLabel
+         * sets the label's, um, label.  you would think i'd call this function
+         * 'setText', but you can pass either a Function or a String to this, so
+         * it makes more sense as 'setLabel'. This uses innerHTML on the label div, so keep
+         * that in mind if you need escaped HTML.
+         */
+        setLabel : function(l) {
+            this.label = l;
+            this.labelText = null;
+            this.clearCachedDimensions();
+            this.update();
+            this.component.repaint();
+        },
+        getDimensions : function() {                
+            this.update();
+            return AbstractDOMOverlay.prototype.getDimensions.apply(this, arguments);
+        },
+        update : function() {
+            if (typeof this.label == "function") {
+                var lt = this.label(this);
+                this.getElement().innerHTML = lt.replace(/\r\n/g, "<br/>");
+            }
+            else {
+                if (this.labelText == null) {
+                    this.labelText = this.label;
+                    this.getElement().innerHTML = this.labelText.replace(/\r\n/g, "<br/>");
+                }
+            }
+        }
+    });		
+
+ // ********************************* END OF OVERLAY DEFINITIONS ***********************************************************************
+    
+})();
+
+/*
+ * jsPlumb
+ *
+ * Title:jsPlumb 1.7.2
+ *
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.
+ *
+ * This file contains the base class for library adapters. From 1.7.2 onwards all event management internal to jsPlumb is handled
+ * through Mottle, regardless of the underlying library. Dragging - and the events associated with it - is still handled
+ * by the library.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ *
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ *
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+;(function() {
+    "use strict";
+
+    var _getEventManager = function(instance) {
+        var e = instance._mottle;
+        if (!e) {
+            e = instance._mottle = new Mottle();
+        }
+        return e;
+    };
+
+    jsPlumb.extend(jsPlumbInstance.prototype, {
+        getEventManager:function() {
+            return _getEventManager(this);
+        },
+        //           EVENTS
+        // e.originalEvent is for jQuery; in Vanilla jsPlumb we get the native event.
+
+        on : function(el, event, callback) {
+            // TODO: here we would like to map the tap event if we know its
+            // an internal bind to a click. we have to know its internal because only
+            // then can we be sure that the UP event wont be consumed (tap is a synthesized
+            // event from a mousedown followed by a mouseup).
+            //event = { "click":"tap", "dblclick":"dbltap"}[event] || event;
+            this.getEventManager().on.apply(this, arguments);
+        },
+        off : function(el, event, callback) {
+            this.getEventManager().off.apply(this, arguments);
+        }
+    });
+
+
+}).call(this);
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the 'flowchart' connectors, consisting of vertical and horizontal line segments.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+;(function() {
+    
+    "use strict";
+   
+    /**
+     * Function: Constructor
+     * 
+     * Parameters:
+     * 	stub - minimum length for the stub at each end of the connector. This can be an integer, giving a value for both ends of the connections, 
+     * or an array of two integers, giving separate values for each end. The default is an integer with value 30 (pixels). 
+     *  gap  - gap to leave between the end of the connector and the element on which the endpoint resides. if you make this larger than stub then you will see some odd looking behaviour.  
+                Like stub, this can be an array or a single value. defaults to 0 pixels for each end.     
+     * cornerRadius - optional, defines the radius of corners between segments. defaults to 0 (hard edged corners).
+     * alwaysRespectStubs - defaults to false. whether or not the connectors should always draw the stub, or, if the two elements
+                            are in close proximity to each other (closer than the sum of the two stubs), to adjust the stubs.
+     */
+    var Flowchart = function(params) {
+        this.type = "Flowchart";
+        params = params || {};
+        params.stub = params.stub == null ? 30 : params.stub;
+        var self = this,
+            _super =  jsPlumb.Connectors.AbstractConnector.apply(this, arguments),		
+            midpoint = params.midpoint == null ? 0.5 : params.midpoint,
+            points = [], segments = [],
+            grid = params.grid,
+            alwaysRespectStubs = params.alwaysRespectStubs,
+            userSuppliedSegments = null,
+            lastx = null, lasty = null, lastOrientation,	
+            cornerRadius = params.cornerRadius != null ? params.cornerRadius : 0,	
+            sgn = function(n) { return n < 0 ? -1 : n === 0 ? 0 : 1; },            
+            /**
+             * helper method to add a segment.
+             */
+            addSegment = function(segments, x, y, paintInfo) {
+                if (lastx == x && lasty == y) return;
+                var lx = lastx == null ? paintInfo.sx : lastx,
+                    ly = lasty == null ? paintInfo.sy : lasty,
+                    o = lx == x ? "v" : "h",
+                    sgnx = sgn(x - lx),
+                    sgny = sgn(y - ly);
+                    
+                lastx = x;
+                lasty = y;				    		                
+                segments.push([lx, ly, x, y, o, sgnx, sgny]);
+            },
+            segLength = function(s) {
+                return Math.sqrt(Math.pow(s[0] - s[2], 2) + Math.pow(s[1] - s[3], 2));    
+            },
+            _cloneArray = function(a) { var _a = []; _a.push.apply(_a, a); return _a;},
+            updateMinMax = function(a1) {
+                self.bounds.minX = Math.min(self.bounds.minX, a1[2]);
+                self.bounds.maxX = Math.max(self.bounds.maxX, a1[2]);
+                self.bounds.minY = Math.min(self.bounds.minY, a1[3]);
+                self.bounds.maxY = Math.max(self.bounds.maxY, a1[3]);    
+            },
+            writeSegments = function(conn, segments, paintInfo) {
+                var current, next;                
+                for (var i = 0; i < segments.length - 1; i++) {
+                    
+                    current = current || _cloneArray(segments[i]);
+                    next = _cloneArray(segments[i + 1]);
+                    if (cornerRadius > 0 && current[4] != next[4]) {
+                        var radiusToUse = Math.min(cornerRadius, segLength(current), segLength(next));
+                        // right angle. adjust current segment's end point, and next segment's start point.
+                        current[2] -= current[5] * radiusToUse;
+                        current[3] -= current[6] * radiusToUse;
+                        next[0] += next[5] * radiusToUse;
+                        next[1] += next[6] * radiusToUse;														                         			
+                        var ac = (current[6] == next[5] && next[5] == 1) ||
+                                 ((current[6] == next[5] && next[5] === 0) && current[5] != next[6]) ||
+                                 (current[6] == next[5] && next[5] == -1),
+                            sgny = next[1] > current[3] ? 1 : -1,
+                            sgnx = next[0] > current[2] ? 1 : -1,
+                            sgnEqual = sgny == sgnx,
+                            cx = (sgnEqual && ac || (!sgnEqual && !ac)) ? next[0] : current[2],
+                            cy = (sgnEqual && ac || (!sgnEqual && !ac)) ? current[3] : next[1];                                                        
+                        
+                        _super.addSegment(conn, "Straight", {
+                            x1:current[0], y1:current[1], x2:current[2], y2:current[3]
+                        });
+                            
+                        _super.addSegment(conn, "Arc", {
+                            r:radiusToUse, 
+                            x1:current[2], 
+                            y1:current[3], 
+                            x2:next[0], 
+                            y2:next[1],
+                            cx:cx,
+                            cy:cy,
+                            ac:ac
+                        });	                                            
+                    }
+                    else {                 
+                        // dx + dy are used to adjust for line width.
+                        var dx = (current[2] == current[0]) ? 0 : (current[2] > current[0]) ? (paintInfo.lw / 2) : -(paintInfo.lw / 2),
+                            dy = (current[3] == current[1]) ? 0 : (current[3] > current[1]) ? (paintInfo.lw / 2) : -(paintInfo.lw / 2);
+                        _super.addSegment(conn, "Straight", {
+                            x1:current[0]- dx, y1:current[1]-dy, x2:current[2] + dx, y2:current[3] + dy
+                        });
+                    }                    
+                    current = next;
+                }
+                if (next != null) {
+                    // last segment
+                    _super.addSegment(conn, "Straight", {
+                        x1:next[0], y1:next[1], x2:next[2], y2:next[3]
+                    });                             
+                }
+            };
+        
+        this.setSegments = function(s) {
+            userSuppliedSegments = s;
+        };
+        
+        this.isEditable = function() { return true; };
+        
+        /*
+            Function: getOriginalSegments
+            Gets the segments before the addition of rounded corners. This is used by the flowchart
+            connector editor, since it only wants to concern itself with the original segments.
+        */
+        this.getOriginalSegments = function() {
+            return userSuppliedSegments || segments;
+        };
+        
+        this._compute = function(paintInfo, params) {
+            
+            if (params.clearEdits)
+                userSuppliedSegments = null;
+            
+            if (userSuppliedSegments != null) {
+                writeSegments(this, userSuppliedSegments, paintInfo);                
+                return;
+            }
+            
+            segments = [];
+            lastx = null; lasty = null;
+            lastOrientation = null;          
+            
+            var midx = paintInfo.startStubX + ((paintInfo.endStubX - paintInfo.startStubX) * midpoint),
+                midy = paintInfo.startStubY + ((paintInfo.endStubY - paintInfo.startStubY) * midpoint);                                                                                                    
+    
+            var findClearedLine = function(start, mult, anchorPos, dimension) {
+                    return start + (mult * (( 1 - anchorPos) * dimension) + _super.maxStub);
+                },
+                orientations = { x:[ 0, 1 ], y:[ 1, 0 ] },
+                commonStubCalculator = function(axis) {
+                    return [ paintInfo.startStubX, paintInfo.startStubY, paintInfo.endStubX, paintInfo.endStubY ];                    
+                },
+                stubCalculators = {
+                    perpendicular:commonStubCalculator,
+                    orthogonal:commonStubCalculator,
+                    opposite:function(axis) {  
+                        var pi = paintInfo,
+                            idx = axis == "x" ? 0 : 1, 
+                            areInProximity = {
+                                "x":function() {                                    
+                                    return ( (pi.so[idx] == 1 && ( 
+                                        ( (pi.startStubX > pi.endStubX) && (pi.tx > pi.startStubX) ) ||
+                                        ( (pi.sx > pi.endStubX) && (pi.tx > pi.sx))))) ||
+
+                                        ( (pi.so[idx] == -1 && ( 
+                                            ( (pi.startStubX < pi.endStubX) && (pi.tx < pi.startStubX) ) ||
+                                            ( (pi.sx < pi.endStubX) && (pi.tx < pi.sx)))));
+                                },
+                                "y":function() {                                     
+                                    return ( (pi.so[idx] == 1 && ( 
+                                        ( (pi.startStubY > pi.endStubY) && (pi.ty > pi.startStubY) ) ||
+                                        ( (pi.sy > pi.endStubY) && (pi.ty > pi.sy))))) ||
+
+                                        ( (pi.so[idx] == -1 && ( 
+                                        ( (pi.startStubY < pi.endStubY) && (pi.ty < pi.startStubY) ) ||
+                                        ( (pi.sy < pi.endStubY) && (pi.ty < pi.sy)))));
+                                }
+                            };
+
+                        if (!alwaysRespectStubs && areInProximity[axis]()) {                   
+                            return {
+                                "x":[(paintInfo.sx + paintInfo.tx) / 2, paintInfo.startStubY, (paintInfo.sx + paintInfo.tx) / 2, paintInfo.endStubY],
+                                "y":[paintInfo.startStubX, (paintInfo.sy + paintInfo.ty) / 2, paintInfo.endStubX, (paintInfo.sy + paintInfo.ty) / 2]
+                            }[axis];
+                        }
+                        else {
+                            return [ paintInfo.startStubX, paintInfo.startStubY, paintInfo.endStubX, paintInfo.endStubY ];   
+                        }
+                    }
+                },
+                lineCalculators = {
+                    perpendicular : function(axis, ss, oss, es, oes) {
+                        var pi = paintInfo, 
+                            sis = {
+                                x:[ [ [ 1,2,3,4 ], null, [ 2,1,4,3 ] ], null, [ [ 4,3,2,1 ], null, [ 3,4,1,2 ] ] ],
+                                y:[ [ [ 3,2,1,4 ], null, [ 2,3,4,1 ] ], null, [ [ 4,1,2,3 ], null, [ 1,4,3,2 ] ] ]
+                            },
+                            stubs = { 
+                                x:[ [ pi.startStubX, pi.endStubX ] , null, [ pi.endStubX, pi.startStubX ] ],
+                                y:[ [ pi.startStubY, pi.endStubY ] , null, [ pi.endStubY, pi.startStubY ] ]
+                            },
+                            midLines = {
+                                x:[ [ midx, pi.startStubY ], [ midx, pi.endStubY ] ],
+                                y:[ [ pi.startStubX, midy ], [ pi.endStubX, midy ] ]
+                            },
+                            linesToEnd = {
+                                x:[ [ pi.endStubX, pi.startStubY ] ],
+                                y:[ [ pi.startStubX, pi.endStubY ] ]
+                            },
+                            startToEnd = {
+                                x:[ [ pi.startStubX, pi.endStubY ], [ pi.endStubX, pi.endStubY ] ],        
+                                y:[ [ pi.endStubX, pi.startStubY ], [ pi.endStubX, pi.endStubY ] ]
+                            },
+                            startToMidToEnd = {
+                                x:[ [ pi.startStubX, midy ], [ pi.endStubX, midy ], [ pi.endStubX, pi.endStubY ] ],
+                                y:[ [ midx, pi.startStubY ], [ midx, pi.endStubY ], [ pi.endStubX, pi.endStubY ] ]
+                            },
+                            otherStubs = {
+                                x:[ pi.startStubY, pi.endStubY ],
+                                y:[ pi.startStubX, pi.endStubX ]                                    
+                            },
+                            soIdx = orientations[axis][0], toIdx = orientations[axis][1],
+                            _so = pi.so[soIdx] + 1,
+                            _to = pi.to[toIdx] + 1,
+                            otherFlipped = (pi.to[toIdx] == -1 && (otherStubs[axis][1] < otherStubs[axis][0])) || (pi.to[toIdx] == 1 && (otherStubs[axis][1] > otherStubs[axis][0])),
+                            stub1 = stubs[axis][_so][0],
+                            stub2 = stubs[axis][_so][1],
+                            segmentIndexes = sis[axis][_so][_to];
+
+                        if (pi.segment == segmentIndexes[3] || (pi.segment == segmentIndexes[2] && otherFlipped)) {
+                            return midLines[axis];       
+                        }
+                        else if (pi.segment == segmentIndexes[2] && stub2 < stub1) {
+                            return linesToEnd[axis];
+                        }
+                        else if ((pi.segment == segmentIndexes[2] && stub2 >= stub1) || (pi.segment == segmentIndexes[1] && !otherFlipped)) {
+                            return startToMidToEnd[axis];
+                        }
+                        else if (pi.segment == segmentIndexes[0] || (pi.segment == segmentIndexes[1] && otherFlipped)) {
+                            return startToEnd[axis];  
+                        }                                
+                    },
+                    orthogonal : function(axis, startStub, otherStartStub, endStub, otherEndStub) {                    
+                        var pi = paintInfo,                                            
+                            extent = {
+                                "x":pi.so[0] == -1 ? Math.min(startStub, endStub) : Math.max(startStub, endStub),
+                                "y":pi.so[1] == -1 ? Math.min(startStub, endStub) : Math.max(startStub, endStub)
+                            }[axis];
+                                                
+                        return {
+                            "x":[ [ extent, otherStartStub ],[ extent, otherEndStub ], [ endStub, otherEndStub ] ],
+                            "y":[ [ otherStartStub, extent ], [ otherEndStub, extent ], [ otherEndStub, endStub ] ]
+                        }[axis];                    
+                    },
+                    opposite : function(axis, ss, oss, es, oes) {                                                
+                        var pi = paintInfo,
+                            otherAxis = {"x":"y","y":"x"}[axis], 
+                            dim = {"x":"height","y":"width"}[axis],
+                            comparator = pi["is" + axis.toUpperCase() + "GreaterThanStubTimes2"];
+
+                        if (params.sourceEndpoint.elementId == params.targetEndpoint.elementId) {
+                            var _val = oss + ((1 - params.sourceEndpoint.anchor[otherAxis]) * params.sourceInfo[dim]) + _super.maxStub;
+                            return {
+                                "x":[ [ ss, _val ], [ es, _val ] ],
+                                "y":[ [ _val, ss ], [ _val, es ] ]
+                            }[axis];
+                            
+                        }                                                        
+                        else if (!comparator || (pi.so[idx] == 1 && ss > es) || (pi.so[idx] == -1 && ss < es)) {                                            
+                            return {
+                                "x":[[ ss, midy ], [ es, midy ]],
+                                "y":[[ midx, ss ], [ midx, es ]]
+                            }[axis];
+                        }
+                        else if ((pi.so[idx] == 1 && ss < es) || (pi.so[idx] == -1 && ss > es)) {
+                            return {
+                                "x":[[ midx, pi.sy ], [ midx, pi.ty ]],
+                                "y":[[ pi.sx, midy ], [ pi.tx, midy ]]
+                            }[axis];
+                        }                        
+                    }
+                };
+
+            var stubs = stubCalculators[paintInfo.anchorOrientation](paintInfo.sourceAxis),
+                idx = paintInfo.sourceAxis == "x" ? 0 : 1,
+                oidx = paintInfo.sourceAxis == "x" ? 1 : 0,                            
+                ss = stubs[idx],
+                oss = stubs[oidx],
+                es = stubs[idx + 2],
+                oes = stubs[oidx + 2];
+
+            // add the start stub segment.
+            addSegment(segments, stubs[0], stubs[1], paintInfo);           
+
+            // compute the rest of the line
+            var p = lineCalculators[paintInfo.anchorOrientation](paintInfo.sourceAxis, ss, oss, es, oes);            
+            if (p) {
+                for (var i = 0; i < p.length; i++) {                	
+                    addSegment(segments, p[i][0], p[i][1], paintInfo);
+                }
+            }          
+            
+            // line to end stub
+            addSegment(segments, stubs[2], stubs[3], paintInfo);
+    
+            // end stub to end
+            addSegment(segments, paintInfo.tx, paintInfo.ty, paintInfo);               
+            
+            writeSegments(this, segments, paintInfo);                            
+        };	
+
+        this.getPath = function() {
+            var _last = null, _lastAxis = null, s = [], segs = userSuppliedSegments || segments;
+            for (var i = 0; i < segs.length; i++) {
+                var seg = segs[i], axis = seg[4], axisIndex = (axis == "v" ? 3 : 2);
+                if (_last != null && _lastAxis === axis) {
+                    _last[axisIndex] = seg[axisIndex];                            
+                }
+                else {
+                    if (seg[0] != seg[2] || seg[1] != seg[3]) {
+                        s.push({
+                            start:[ seg[0], seg[1] ],
+                            end:[ seg[2], seg[3] ]
+                        });                    
+                        _last = seg;
+                        _lastAxis = seg[4];
+                    }
+                }
+            }
+            return s;
+        };	
+
+        this.setPath = function(path) {
+            userSuppliedSegments = [];
+            for (var i = 0; i < path.length; i++) {
+                 var lx = path[i].start[0],
+                    ly = path[i].start[1],
+                    x = path[i].end[0],
+                    y = path[i].end[1],
+                    o = lx == x ? "v" : "h",
+                    sgnx = sgn(x - lx),
+                    sgny = sgn(y - ly);
+
+                userSuppliedSegments.push([lx, ly, x, y, o, sgnx, sgny]);
+            }
+        };
+    };
+
+    jsPlumbUtil.extend(Flowchart, jsPlumb.Connectors.AbstractConnector);
+    jsPlumb.registerConnectorType(Flowchart, "Flowchart");
+})();
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the state machine connectors.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+ ;(function() {
+	 
+	"use strict";
+
+	var Line = function(x1, y1, x2, y2) {
+
+		this.m = (y2 - y1) / (x2 - x1);
+		this.b = -1 * ((this.m * x1) - y1);
+	
+		this.rectIntersect = function(x,y,w,h) {
+			var results = [], xInt, yInt;
+		
+			// 	try top face
+			// 	the equation of the top face is y = (0 * x) + b; y = b.
+			xInt = (y - this.b) / this.m;
+			// test that the X value is in the line's range.
+			if (xInt >= x && xInt <= (x + w)) results.push([ xInt, (this.m * xInt) + this.b ]);
+		
+			// try right face
+			yInt = (this.m * (x + w)) + this.b;
+			if (yInt >= y && yInt <= (y + h)) results.push([ (yInt - this.b) / this.m, yInt ]);
+		
+			// 	bottom face
+			xInt = ((y + h) - this.b) / this.m;
+			// test that the X value is in the line's range.
+			if (xInt >= x && xInt <= (x + w)) results.push([ xInt, (this.m * xInt) + this.b ]);
+		
+			// try left face
+			yInt = (this.m * x) + this.b;
+			if (yInt >= y && yInt <= (y + h)) results.push([ (yInt - this.b) / this.m, yInt ]);
+
+			if (results.length == 2) {
+				var midx = (results[0][0] + results[1][0]) / 2, midy = (results[0][1] + results[1][1]) / 2;
+				results.push([ midx,midy ]);
+				// now calculate the segment inside the rectangle where the midpoint lies.
+				var xseg = midx <= x + (w / 2) ? -1 : 1,
+					yseg = midy <= y + (h / 2) ? -1 : 1;
+				results.push([xseg, yseg]);
+				return results;
+			}
+		
+			return null;
+
+		};
+	},
+	_segment = function(x1, y1, x2, y2) {
+		if (x1 <= x2 && y2 <= y1) return 1;
+		else if (x1 <= x2 && y1 <= y2) return 2;
+		else if (x2 <= x1 && y2 >= y1) return 3;
+		return 4;
+	},
+		
+		// the control point we will use depends on the faces to which each end of the connection is assigned, specifically whether or not the
+		// two faces are parallel or perpendicular.  if they are parallel then the control point lies on the midpoint of the axis in which they
+		// are parellel and varies only in the other axis; this variation is proportional to the distance that the anchor points lie from the
+		// center of that face.  if the two faces are perpendicular then the control point is at some distance from both the midpoints; the amount and
+		// direction are dependent on the orientation of the two elements. 'seg', passed in to this method, tells you which segment the target element
+		// lies in with respect to the source: 1 is top right, 2 is bottom right, 3 is bottom left, 4 is top left.
+		//
+		// sourcePos and targetPos are arrays of info about where on the source and target each anchor is located.  their contents are:
+		//
+		// 0 - absolute x
+		// 1 - absolute y
+		// 2 - proportional x in element (0 is left edge, 1 is right edge)
+		// 3 - proportional y in element (0 is top edge, 1 is bottom edge)
+		// 	
+	_findControlPoint = function(midx, midy, segment, sourceEdge, targetEdge, dx, dy, distance, proximityLimit) {
+        // TODO (maybe)
+        // - if anchor pos is 0.5, make the control point take into account the relative position of the elements.
+        if (distance <= proximityLimit) return [midx, midy];
+
+        if (segment === 1) {
+            if (sourceEdge[3] <= 0 && targetEdge[3] >= 1) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ];
+            else if (sourceEdge[2] >= 1 && targetEdge[2] <= 0) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ];
+            else return [ midx + (-1 * dx) , midy + (-1 * dy) ];
+        }
+        else if (segment === 2) {
+            if (sourceEdge[3] >= 1 && targetEdge[3] <= 0) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ];
+            else if (sourceEdge[2] >= 1 && targetEdge[2] <= 0) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ];
+            else return [ midx + (1 * dx) , midy + (-1 * dy) ];
+        }
+        else if (segment === 3) {
+            if (sourceEdge[3] >= 1 && targetEdge[3] <= 0) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ];
+            else if (sourceEdge[2] <= 0 && targetEdge[2] >= 1) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ];
+            else return [ midx + (-1 * dx) , midy + (-1 * dy) ];
+        }
+        else if (segment === 4) {
+            if (sourceEdge[3] <= 0 && targetEdge[3] >= 1) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ];
+            else if (sourceEdge[2] <= 0 && targetEdge[2] >= 1) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ];
+            else return [ midx + (1 * dx) , midy + (-1 * dy) ];
+        }
+
+	};	
+	
+	/**
+     * Class: Connectors.StateMachine
+     * Provides 'state machine' connectors.
+     */
+	/*
+	 * Function: Constructor
+	 * 
+	 * Parameters:
+	 * curviness -	measure of how "curvy" the connectors will be.  this is translated as the distance that the
+     *                Bezier curve's control point is from the midpoint of the straight line connecting the two
+     *              endpoints, and does not mean that the connector is this wide.  The Bezier curve never reaches
+     *              its control points; they act as gravitational masses. defaults to 10.
+	 * margin	-	distance from element to start and end connectors, in pixels.  defaults to 5.
+	 * proximityLimit  -   sets the distance beneath which the elements are consider too close together to bother
+	 *						with fancy curves. by default this is 80 pixels.
+	 * loopbackRadius	-	the radius of a loopback connector.  optional; defaults to 25.
+	 * showLoopback   -   If set to false this tells the connector that it is ok to paint connections whose source and target is the same element with a connector running through the element. The default value for this is true; the connector always makes a loopback connection loop around the element rather than passing through it.
+	*/
+	var StateMachine = function(params) {
+		params = params || {};
+		this.type = "StateMachine";
+
+		var self = this,
+			_super =  jsPlumb.Connectors.AbstractConnector.apply(this, arguments),
+			curviness = params.curviness || 10,
+			margin = params.margin || 5,
+			proximityLimit = params.proximityLimit || 80,
+			clockwise = params.orientation && params.orientation === "clockwise",
+			loopbackRadius = params.loopbackRadius || 25,
+			showLoopback = params.showLoopback !== false;
+		
+		this._compute = function(paintInfo, params) {
+			var w = Math.abs(params.sourcePos[0] - params.targetPos[0]),
+				h = Math.abs(params.sourcePos[1] - params.targetPos[1]),
+				x = Math.min(params.sourcePos[0], params.targetPos[0]),
+				y = Math.min(params.sourcePos[1], params.targetPos[1]);				
+		
+			if (!showLoopback || (params.sourceEndpoint.elementId !== params.targetEndpoint.elementId)) {                            
+				var _sx = params.sourcePos[0] < params.targetPos[0] ? 0  : w,
+					_sy = params.sourcePos[1] < params.targetPos[1] ? 0:h,
+					_tx = params.sourcePos[0] < params.targetPos[0] ? w : 0,
+					_ty = params.sourcePos[1] < params.targetPos[1] ? h : 0;
+            
+				// now adjust for the margin
+				if (params.sourcePos[2] === 0) _sx -= margin;
+            	if (params.sourcePos[2] === 1) _sx += margin;
+            	if (params.sourcePos[3] === 0) _sy -= margin;
+            	if (params.sourcePos[3] === 1) _sy += margin;
+            	if (params.targetPos[2] === 0) _tx -= margin;
+            	if (params.targetPos[2] === 1) _tx += margin;
+            	if (params.targetPos[3] === 0) _ty -= margin;
+            	if (params.targetPos[3] === 1) _ty += margin;
+
+            	//
+	            // these connectors are quadratic bezier curves, having a single control point. if both anchors 
+    	        // are located at 0.5 on their respective faces, the control point is set to the midpoint and you
+        	    // get a straight line.  this is also the case if the two anchors are within 'proximityLimit', since
+           	 	// it seems to make good aesthetic sense to do that. outside of that, the control point is positioned 
+           	 	// at 'curviness' pixels away along the normal to the straight line connecting the two anchors.
+	            // 
+   	        	// there may be two improvements to this.  firstly, we might actually support the notion of avoiding nodes
+            	// in the UI, or at least making a good effort at doing so.  if a connection would pass underneath some node,
+            	// for example, we might increase the distance the control point is away from the midpoint in a bid to
+            	// steer it around that node.  this will work within limits, but i think those limits would also be the likely
+            	// limits for, once again, aesthetic good sense in the layout of a chart using these connectors.
+            	//
+            	// the second possible change is actually two possible changes: firstly, it is possible we should gradually
+            	// decrease the 'curviness' as the distance between the anchors decreases; start tailing it off to 0 at some
+            	// point (which should be configurable).  secondly, we might slightly increase the 'curviness' for connectors
+            	// with respect to how far their anchor is from the center of its respective face. this could either look cool,
+            	// or stupid, and may indeed work only in a way that is so subtle as to have been a waste of time.
+            	//
+
+				var _midx = (_sx + _tx) / 2, _midy = (_sy + _ty) / 2, 
+            	    m2 = (-1 * _midx) / _midy, theta2 = Math.atan(m2),
+            	    dy =  (m2 == Infinity || m2 == -Infinity) ? 0 : Math.abs(curviness / 2 * Math.sin(theta2)),
+				    dx =  (m2 == Infinity || m2 == -Infinity) ? 0 : Math.abs(curviness / 2 * Math.cos(theta2)),
+				    segment = _segment(_sx, _sy, _tx, _ty),
+				    distance = Math.sqrt(Math.pow(_tx - _sx, 2) + Math.pow(_ty - _sy, 2)),			
+	            	// calculate the control point.  this code will be where we'll put in a rudimentary element avoidance scheme; it
+	            	// will work by extending the control point to force the curve to be, um, curvier.
+					_controlPoint = _findControlPoint(_midx,
+                                                  _midy,
+                                                  segment,
+                                                  params.sourcePos,
+                                                  params.targetPos,
+                                                  curviness, curviness,
+                                                  distance,
+                                                  proximityLimit);
+
+				_super.addSegment(this, "Bezier", {
+					x1:_tx, y1:_ty, x2:_sx, y2:_sy,
+					cp1x:_controlPoint[0], cp1y:_controlPoint[1],
+					cp2x:_controlPoint[0], cp2y:_controlPoint[1]
+				});				
+            }
+            else {
+            	// a loopback connector.  draw an arc from one anchor to the other.            	
+        		var x1 = params.sourcePos[0], x2 = params.sourcePos[0], y1 = params.sourcePos[1] - margin, y2 = params.sourcePos[1] - margin, 				
+					cx = x1, cy = y1 - loopbackRadius,				
+					// canvas sizing stuff, to ensure the whole painted area is visible.
+					_w = 2 * loopbackRadius, 
+					_h = 2 * loopbackRadius,
+					_x = cx - loopbackRadius, 
+					_y = cy - loopbackRadius;
+
+				paintInfo.points[0] = _x;
+				paintInfo.points[1] = _y;
+				paintInfo.points[2] = _w;
+				paintInfo.points[3] = _h;
+				
+				// ADD AN ARC SEGMENT.
+				_super.addSegment(this, "Arc", {
+					loopback:true,
+					x1:(x1 - _x) + 4,
+					y1:y1 - _y,
+					startAngle:0,
+					endAngle: 2 * Math.PI,
+					r:loopbackRadius,
+					ac:!clockwise,
+					x2:(x1 - _x) - 4,
+					y2:y1 - _y,
+					cx:cx - _x,
+					cy:cy - _y
+				});
+            }                           
+        };                        
+	};
+	jsPlumb.registerConnectorType(StateMachine, "StateMachine");
+})();
+
+/*
+    	// a possible rudimentary avoidance scheme, old now, perhaps not useful.
+        //      if (avoidSelector) {
+		//		    var testLine = new Line(sourcePos[0] + _sx,sourcePos[1] + _sy,sourcePos[0] + _tx,sourcePos[1] + _ty);
+		//		    var sel = jsPlumb.getSelector(avoidSelector);
+		//		    for (var i = 0; i < sel.length; i++) {
+		//			    var id = jsPlumb.getId(sel[i]);
+		//			    if (id != sourceEndpoint.elementId && id != targetEndpoint.elementId) {
+		//				    o = jsPlumb.getOffset(id), s = jsPlumb.getSize(id);
+//
+//						    if (o && s) {
+//							    var collision = testLine.rectIntersect(o.left,o.top,s[0],s[1]);
+//							    if (collision) {
+								    // set the control point to be a certain distance from the midpoint of the two points that
+								    // the line crosses on the rectangle.
+								    // TODO where will this 75 number come from?
+					//			    _controlX = collision[2][0] + (75 * collision[3][0]);
+				//	/			    _controlY = collision[2][1] + (75 * collision[3][1]);
+//							    }
+//						    }
+					//  }
+	//			    }
+              //}
+    */
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the code for the Bezier connector type.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+;(function() {
+
+	var Bezier = function(params) {
+		params = params || {};
+
+		var _super =  jsPlumb.Connectors.AbstractConnector.apply(this, arguments),
+			stub = params.stub || 50,
+			majorAnchor = params.curviness || 150,
+			minorAnchor = 10;
+
+		this.type = "Bezier";
+		this.getCurviness = function() { return majorAnchor; };
+
+		this._findControlPoint = function(point, sourceAnchorPosition, targetAnchorPosition, sourceEndpoint, targetEndpoint) {
+			// determine if the two anchors are perpendicular to each other in their orientation.  we swap the control 
+			// points around if so (code could be tightened up)
+			var soo = sourceEndpoint.anchor.getOrientation(sourceEndpoint),
+				too = targetEndpoint.anchor.getOrientation(targetEndpoint),
+				perpendicular = soo[0] != too[0] || soo[1] == too[1],
+				p = [];
+
+			if (!perpendicular) {
+				if (soo[0] === 0) // X
+					p.push(sourceAnchorPosition[0] < targetAnchorPosition[0] ? point[0] + minorAnchor : point[0] - minorAnchor);
+				else p.push(point[0] - (majorAnchor * soo[0]));
+
+				if (soo[1] === 0) // Y
+					p.push(sourceAnchorPosition[1] < targetAnchorPosition[1] ? point[1] + minorAnchor : point[1] - minorAnchor);
+				else p.push(point[1] + (majorAnchor * too[1]));
+			}
+			else {
+				if (too[0] === 0) // X
+					p.push(targetAnchorPosition[0] < sourceAnchorPosition[0] ? point[0] + minorAnchor : point[0] - minorAnchor);
+				else p.push(point[0] + (majorAnchor * too[0]));
+
+				if (too[1] === 0) // Y
+					p.push(targetAnchorPosition[1] < sourceAnchorPosition[1] ? point[1] + minorAnchor : point[1] - minorAnchor);
+				else p.push(point[1] + (majorAnchor * soo[1]));
+			}
+
+			return p;
+		};
+
+		this._compute = function(paintInfo, p) {
+
+			var sp = p.sourcePos,
+				tp = p.targetPos,
+				_w = Math.abs(sp[0] - tp[0]),
+				_h = Math.abs(sp[1] - tp[1]),
+				_sx = sp[0] < tp[0] ? _w : 0,
+				_sy = sp[1] < tp[1] ? _h : 0,
+				_tx = sp[0] < tp[0] ? 0 : _w,
+				_ty = sp[1] < tp[1] ? 0 : _h,
+				_CP = this._findControlPoint([_sx, _sy], sp, tp, p.sourceEndpoint, p.targetEndpoint, paintInfo.so, paintInfo.to),
+				_CP2 = this._findControlPoint([_tx, _ty], tp, sp, p.targetEndpoint, p.sourceEndpoint, paintInfo.so, paintInfo.to);
+
+			_super.addSegment(this, "Bezier", {
+				x1:_sx, y1:_sy, x2:_tx, y2:_ty,
+				cp1x:_CP[0], cp1y:_CP[1], cp2x:_CP2[0], cp2y:_CP2[1]
+			});
+		};
+	};
+
+	jsPlumbUtil.extend(Bezier, jsPlumb.Connectors.AbstractConnector);
+	jsPlumb.registerConnectorType(Bezier, "Bezier");
+
+})();
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the SVG renderers.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+;(function() {
+	
+// ************************** SVG utility methods ********************************************	
+
+	"use strict";
+	
+	var svgAttributeMap = {
+		"joinstyle":"stroke-linejoin",
+		"stroke-linejoin":"stroke-linejoin",		
+		"stroke-dashoffset":"stroke-dashoffset",
+		"stroke-linecap":"stroke-linecap"
+	},
+	STROKE_DASHARRAY = "stroke-dasharray",
+	DASHSTYLE = "dashstyle",
+	LINEAR_GRADIENT = "linearGradient",
+	RADIAL_GRADIENT = "radialGradient",
+	DEFS = "defs",
+	FILL = "fill",
+	STOP = "stop",
+	STROKE = "stroke",
+	STROKE_WIDTH = "stroke-width",
+	STYLE = "style",
+	NONE = "none",
+	JSPLUMB_GRADIENT = "jsplumb_gradient_",
+	LINE_WIDTH = "lineWidth",
+	ns = {
+		svg:"http://www.w3.org/2000/svg",
+		xhtml:"http://www.w3.org/1999/xhtml"
+	},
+	_attr = function(node, attributes) {
+		for (var i in attributes)
+			node.setAttribute(i, "" + attributes[i]);
+	},	
+	_node = function(name, attributes) {
+		var n = document.createElementNS(ns.svg, name);
+		attributes = attributes || {};
+		attributes.version = "1.1";
+		attributes.xmlns = ns.xhtml;
+		_attr(n, attributes);
+		return n;
+	},
+	_pos = function(d) { return "position:absolute;left:" + d[0] + "px;top:" + d[1] + "px"; },	
+	_clearGradient = function(parent) {
+        // TODO use querySelectorAll here instead?
+		for (var i = 0; i < parent.childNodes.length; i++) {
+			if (parent.childNodes[i].tagName == DEFS || parent.childNodes[i].tagName == LINEAR_GRADIENT || parent.childNodes[i].tagName == RADIAL_GRADIENT)
+				parent.removeChild(parent.childNodes[i]);
+		}
+	},		
+	_updateGradient = function(parent, node, style, dimensions, uiComponent) {
+		var id = JSPLUMB_GRADIENT + uiComponent._jsPlumb.instance.idstamp();
+		// first clear out any existing gradient
+		_clearGradient(parent);
+		// this checks for an 'offset' property in the gradient, and in the absence of it, assumes
+		// we want a linear gradient. if it's there, we create a radial gradient.
+		// it is possible that a more explicit means of defining the gradient type would be
+		// better. relying on 'offset' means that we can never have a radial gradient that uses
+		// some default offset, for instance.
+		// issue 244 suggested the 'gradientUnits' attribute; without this, straight/flowchart connectors with gradients would
+		// not show gradients when the line was perfectly horizontal or vertical.
+		var g;
+		if (!style.gradient.offset)
+			g = _node(LINEAR_GRADIENT, {id:id, gradientUnits:"userSpaceOnUse"});
+		else
+			g = _node(RADIAL_GRADIENT, { id:id });
+		
+		var defs = _node(DEFS);
+		parent.appendChild(defs);
+		defs.appendChild(g);
+		//parent.appendChild(g);
+		
+		// the svg radial gradient seems to treat stops in the reverse 
+		// order to how canvas does it.  so we want to keep all the maths the same, but
+		// iterate the actual style declarations in reverse order, if the x indexes are not in order.
+		for (var i = 0; i < style.gradient.stops.length; i++) {
+			var styleToUse = uiComponent.segment == 1 ||  uiComponent.segment == 2 ? i: style.gradient.stops.length - 1 - i,			
+				stopColor = jsPlumbUtil.convertStyle(style.gradient.stops[styleToUse][1], true),
+				s = _node(STOP, {"offset":Math.floor(style.gradient.stops[i][0] * 100) + "%", "stop-color":stopColor});
+
+			g.appendChild(s);
+		}
+		var applyGradientTo = style.strokeStyle ? STROKE : FILL;
+        //node.setAttribute(STYLE, applyGradientTo + ":url(" + /[^#]+/.exec(document.location.toString()) + "#" + id + ")");
+		//node.setAttribute(STYLE, applyGradientTo + ":url(#" + id + ")");
+		//node.setAttribute(applyGradientTo,  "url(" + /[^#]+/.exec(document.location.toString()) + "#" + id + ")");
+		node.setAttribute(applyGradientTo,  "url(#" + id + ")");
+	},
+	_applyStyles = function(parent, node, style, dimensions, uiComponent) {
+		
+		node.setAttribute(FILL, style.fillStyle ? jsPlumbUtil.convertStyle(style.fillStyle, true) : NONE);
+		node.setAttribute(STROKE, style.strokeStyle ? jsPlumbUtil.convertStyle(style.strokeStyle, true) : NONE);
+			
+		if (style.gradient) {
+			_updateGradient(parent, node, style, dimensions, uiComponent);			
+		}
+		else {
+			// make sure we clear any existing gradient
+			_clearGradient(parent);
+			node.setAttribute(STYLE, "");
+		}
+		
+		
+		if (style.lineWidth) {
+			node.setAttribute(STROKE_WIDTH, style.lineWidth);
+		}
+	
+		// in SVG there is a stroke-dasharray attribute we can set, and its syntax looks like
+		// the syntax in VML but is actually kind of nasty: values are given in the pixel
+		// coordinate space, whereas in VML they are multiples of the width of the stroked
+		// line, which makes a lot more sense.  for that reason, jsPlumb is supporting both
+		// the native svg 'stroke-dasharray' attribute, and also the 'dashstyle' concept from
+		// VML, which will be the preferred method.  the code below this converts a dashstyle
+		// attribute given in terms of stroke width into a pixel representation, by using the
+		// stroke's lineWidth. 
+		if (style[DASHSTYLE] && style[LINE_WIDTH] && !style[STROKE_DASHARRAY]) {
+			var sep = style[DASHSTYLE].indexOf(",") == -1 ? " " : ",",
+			parts = style[DASHSTYLE].split(sep),
+			styleToUse = "";
+			parts.forEach(function(p) {
+				styleToUse += (Math.floor(p * style.lineWidth) + sep);
+			});
+			node.setAttribute(STROKE_DASHARRAY, styleToUse);
+		}		
+		else if(style[STROKE_DASHARRAY]) {
+			node.setAttribute(STROKE_DASHARRAY, style[STROKE_DASHARRAY]);
+		}
+		
+		// extra attributes such as join type, dash offset.
+		for (var i in svgAttributeMap) {
+			if (style[i]) {
+				node.setAttribute(svgAttributeMap[i], style[i]);
+			}
+		}
+	},
+	_decodeFont = function(f) {
+		var r = /([0-9].)(p[xt])\s(.*)/, 
+			bits = f.match(r);
+
+		return {size:bits[1] + bits[2], font:bits[3]};		
+	},
+	_appendAtIndex = function(svg, path, idx) {
+		if (svg.childNodes.length > idx) {
+			svg.insertBefore(path, svg.childNodes[idx]);
+		}
+		else svg.appendChild(path);
+	};
+	
+	/**
+		utility methods for other objects to use.
+	*/
+	jsPlumbUtil.svg = {
+		node:_node,
+		attr:_attr,
+		pos:_pos
+	};
+	
+ // ************************** / SVG utility methods ********************************************	
+	
+	/*
+	 * Base class for SVG components.
+	 */	
+	var SvgComponent = function(params) {
+		var pointerEventsSpec = params.pointerEventsSpec || "all", renderer = {};
+			
+		jsPlumb.jsPlumbUIComponent.apply(this, params.originalArgs);
+		this.canvas = null;this.path = null;this.svg = null; this.bgCanvas = null;
+	
+		var clazz = params.cssClass + " " + (params.originalArgs[0].cssClass || ""),		
+			svgParams = {
+				"style":"",
+				"width":0,
+				"height":0,
+				"pointer-events":pointerEventsSpec,
+				"position":"absolute"
+			};				
+		
+		this.svg = _node("svg", svgParams);
+		
+		if (params.useDivWrapper) {
+			this.canvas = document.createElement("div");
+			this.canvas.style.position = "absolute";
+			jsPlumbUtil.sizeElement(this.canvas,0,0,1,1);
+			this.canvas.className = clazz;
+		}
+		else {
+			_attr(this.svg, { "class":clazz });
+			this.canvas = this.svg;
+		}
+			
+		params._jsPlumb.appendElement(this.canvas, params.originalArgs[0].parent);
+		if (params.useDivWrapper) this.canvas.appendChild(this.svg);
+		
+		// TODO this displayElement stuff is common between all components, across all
+		// renderers.  would be best moved to jsPlumbUIComponent.
+		var displayElements = [ this.canvas ];
+		this.getDisplayElements = function() { 
+			return displayElements; 
+		};
+		
+		this.appendDisplayElement = function(el) {
+			displayElements.push(el);
+		};	
+		
+		this.paint = function(style, anchor, extents) {	   			
+			if (style != null) {
+				
+				var xy = [ this.x, this.y ], wh = [ this.w, this.h ], p;
+				if (extents != null) {
+					if (extents.xmin < 0) xy[0] += extents.xmin;
+					if (extents.ymin < 0) xy[1] += extents.ymin;
+					wh[0] = extents.xmax + ((extents.xmin < 0) ? -extents.xmin : 0);
+					wh[1] = extents.ymax + ((extents.ymin < 0) ? -extents.ymin : 0);
+				}
+
+				if (params.useDivWrapper) {					
+					jsPlumbUtil.sizeElement(this.canvas, xy[0], xy[1], wh[0], wh[1]);
+					xy[0] = 0; xy[1] = 0;
+					p = _pos([ 0, 0 ]);
+				}
+				else
+					p = _pos([ xy[0], xy[1] ]);
+                
+                renderer.paint.apply(this, arguments);		    			    	
+                
+		    	_attr(this.svg, {
+	    			"style":p,
+	    			"width": wh[0],
+	    			"height": wh[1]
+	    		});		    		    		    	
+			}
+	    };
+		
+		return {
+			renderer:renderer
+		};
+	};
+	
+	jsPlumbUtil.extend(SvgComponent, jsPlumb.jsPlumbUIComponent, {
+		cleanup:function() {
+            if (this.canvas) this.canvas._jsPlumb = null;
+            if (this.svg) this.svg._jsPlumb = null;
+            if (this.bgCanvas) this.bgCanvas._jsPlumb = null;
+
+			if (this.canvas && this.canvas.parentNode) this.canvas.parentNode.removeChild(this.canvas);
+            if (this.bgCanvas && this. bgCanvas.parentNode) this.canvas.parentNode.removeChild(this.canvas);
+
+			this.svg = null;
+			this.canvas = null;
+			this.path = null;			
+			this.group = null;
+		},
+		setVisible:function(v) {
+			if (this.canvas) {
+				this.canvas.style.display = v ? "block" : "none";
+			}
+		}
+	});
+	
+	/*
+	 * Base class for SVG connectors.
+	 */ 
+	jsPlumb.ConnectorRenderers.svg = function(params) {
+		var self = this,
+			_super = SvgComponent.apply(this, [ { 
+				cssClass:params._jsPlumb.connectorClass, 
+				originalArgs:arguments, 
+				pointerEventsSpec:"none", 
+				_jsPlumb:params._jsPlumb
+			} ]);	
+
+		/*this.pointOnPath = function(location, absolute) {
+			if (!self.path) return [0,0];
+			var p = absolute ? location : location * self.path.getTotalLength();
+			return self.path.getPointAtLength(p);
+		};*/			
+
+		_super.renderer.paint = function(style, anchor, extents) {
+			
+			var segments = self.getSegments(), p = "", offset = [0,0];			
+			if (extents.xmin < 0) offset[0] = -extents.xmin;
+			if (extents.ymin < 0) offset[1] = -extents.ymin;			
+
+			if (segments.length > 0) {
+			
+				// create path from segments.	
+				for (var i = 0; i < segments.length; i++) {
+					p += jsPlumb.Segments.svg.SegmentRenderer.getPath(segments[i]);
+					p += " ";
+				}			
+				
+				var a = { 
+						d:p,
+						transform:"translate(" + offset[0] + "," + offset[1] + ")",
+						"pointer-events":params["pointer-events"] || "visibleStroke"
+					}, 
+	                outlineStyle = null,
+	                d = [self.x,self.y,self.w,self.h];
+
+				// outline style.  actually means drawing an svg object underneath the main one.
+				if (style.outlineColor) {
+					var outlineWidth = style.outlineWidth || 1,
+						outlineStrokeWidth = style.lineWidth + (2 * outlineWidth);
+					outlineStyle = jsPlumb.extend({}, style);
+                    delete outlineStyle.gradient;
+					outlineStyle.strokeStyle = jsPlumbUtil.convertStyle(style.outlineColor);
+					outlineStyle.lineWidth = outlineStrokeWidth;
+					
+					if (self.bgPath == null) {
+						self.bgPath = _node("path", a);
+                        _appendAtIndex(self.svg, self.bgPath, 0);
+					}
+					else {
+						_attr(self.bgPath, a);
+					}
+					
+					_applyStyles(self.svg, self.bgPath, outlineStyle, d, self);
+				}			
+				
+		    	if (self.path == null) {
+			    	self.path = _node("path", a);
+                    _appendAtIndex(self.svg, self.path, style.outlineColor ? 1 : 0);
+		    	}
+		    	else {
+		    		_attr(self.path, a);
+		    	}
+		    		    	
+		    	_applyStyles(self.svg, self.path, style, d, self);
+		    }
+		};		
+	};
+	jsPlumbUtil.extend(jsPlumb.ConnectorRenderers.svg, SvgComponent);
+
+// ******************************* svg segment renderer *****************************************************	
+		
+	jsPlumb.Segments.svg = {
+		SegmentRenderer : {		
+			getPath : function(segment) {
+				return ({
+					"Straight":function() {
+						var d = segment.getCoordinates();
+						return "M " + d.x1 + " " + d.y1 + " L " + d.x2 + " " + d.y2;	
+					},
+					"Bezier":function() {
+						var d = segment.params;
+						return "M " + d.x1 + " " + d.y1 + 
+							" C " + d.cp1x + " " + d.cp1y + " " + d.cp2x + " " + d.cp2y + " " + d.x2 + " " + d.y2;			
+					},
+					"Arc":function() {
+						var d = segment.params,
+							laf = segment.sweep > Math.PI ? 1 : 0,
+							sf = segment.anticlockwise ? 0 : 1;			
+
+						return "M" + segment.x1 + " " + segment.y1 + " A " + segment.radius + " " + d.r + " 0 " + laf + "," + sf + " " + segment.x2 + " " + segment.y2;
+					}
+				})[segment.type]();	
+			}
+		}
+	};
+	
+// ******************************* /svg segments *****************************************************
+   
+    /*
+	 * Base class for SVG endpoints.
+	 */
+	var SvgEndpoint = window.SvgEndpoint = function(params) {
+		var _super = SvgComponent.apply(this, [ {
+				cssClass:params._jsPlumb.endpointClass, 
+				originalArgs:arguments, 
+				pointerEventsSpec:"all",
+				useDivWrapper:true,
+				_jsPlumb:params._jsPlumb
+			} ]);
+			
+		_super.renderer.paint = function(style) {
+			var s = jsPlumb.extend({}, style);
+			if (s.outlineColor) {
+				s.strokeWidth = s.outlineWidth;
+				s.strokeStyle = jsPlumbUtil.convertStyle(s.outlineColor, true);
+			}
+			
+			if (this.node == null) {
+				this.node = this.makeNode(s);
+				this.svg.appendChild(this.node);
+			}
+			else if (this.updateNode != null) {
+				this.updateNode(this.node);
+			}
+			_applyStyles(this.svg, this.node, s, [ this.x, this.y, this.w, this.h ], this);
+			_pos(this.node, [ this.x, this.y ]);
+		}.bind(this);
+				
+	};
+	jsPlumbUtil.extend(SvgEndpoint, SvgComponent);
+	
+	/*
+	 * SVG Dot Endpoint
+	 */
+	jsPlumb.Endpoints.svg.Dot = function() {
+		jsPlumb.Endpoints.Dot.apply(this, arguments);
+		SvgEndpoint.apply(this, arguments);		
+		this.makeNode = function(style) { 
+			return _node("circle", {
+                "cx"	:	this.w / 2,
+                "cy"	:	this.h / 2,
+                "r"		:	this.radius
+            });			
+		};
+		this.updateNode = function(node) {
+			_attr(node, {
+				"cx":this.w / 2,
+				"cy":this.h  / 2,
+				"r":this.radius
+			});
+		};
+	};
+	jsPlumbUtil.extend(jsPlumb.Endpoints.svg.Dot, [jsPlumb.Endpoints.Dot, SvgEndpoint]);
+	
+	/*
+	 * SVG Rectangle Endpoint 
+	 */
+	jsPlumb.Endpoints.svg.Rectangle = function() {
+		jsPlumb.Endpoints.Rectangle.apply(this, arguments);
+		SvgEndpoint.apply(this, arguments);		
+		this.makeNode = function(style) {
+			return _node("rect", {
+				"width"     :   this.w,
+				"height"    :   this.h
+			});
+		};
+		this.updateNode = function(node) {
+			_attr(node, {
+				"width":this.w,
+				"height":this.h
+			});
+		};			
+	};		
+	jsPlumbUtil.extend(jsPlumb.Endpoints.svg.Rectangle, [jsPlumb.Endpoints.Rectangle, SvgEndpoint]);
+	
+	/*
+	 * SVG Image Endpoint is the default image endpoint.
+	 */
+	jsPlumb.Endpoints.svg.Image = jsPlumb.Endpoints.Image;
+	/*
+	 * Blank endpoint in svg renderer is the default Blank endpoint.
+	 */
+	jsPlumb.Endpoints.svg.Blank = jsPlumb.Endpoints.Blank;	
+	/*
+	 * Label overlay in svg renderer is the default Label overlay.
+	 */
+	jsPlumb.Overlays.svg.Label = jsPlumb.Overlays.Label;
+	/*
+	 * Custom overlay in svg renderer is the default Custom overlay.
+	 */
+	jsPlumb.Overlays.svg.Custom = jsPlumb.Overlays.Custom;
+		
+	var AbstractSvgArrowOverlay = function(superclass, originalArgs) {
+    	superclass.apply(this, originalArgs);
+    	jsPlumb.jsPlumbUIComponent.apply(this, originalArgs);
+        this.isAppendedAtTopLevel = false;
+    	var self = this;
+    	this.path = null;
+    	this.paint = function(params, containerExtents) {
+    		// only draws on connections, not endpoints.
+    		if (params.component.svg && containerExtents) {
+	    		if (this.path == null) {
+	    			this.path = _node("path", {
+	    				"pointer-events":"all"	
+	    			});
+	    			params.component.svg.appendChild(this.path);
+	    			
+	    			this.canvas = params.component.svg; // for the sake of completeness; this behaves the same as other overlays
+	    		}
+	    		var clazz = originalArgs && (originalArgs.length == 1) ? (originalArgs[0].cssClass || "") : "",
+	    			offset = [0,0];
+
+	    		if (containerExtents.xmin < 0) offset[0] = -containerExtents.xmin;
+	    		if (containerExtents.ymin < 0) offset[1] = -containerExtents.ymin;
+	    		
+	    		_attr(this.path, { 
+	    			"d"			:	makePath(params.d),
+	    			"class" 	:	clazz,
+	    			stroke 		: 	params.strokeStyle ? params.strokeStyle : null,
+	    			fill 		: 	params.fillStyle ? params.fillStyle : null,
+	    			transform	: 	"translate(" + offset[0] + "," + offset[1] + ")"
+	    		});    		
+	    	}
+    	};
+    	var makePath = function(d) {
+    		return "M" + d.hxy.x + "," + d.hxy.y +
+    				" L" + d.tail[0].x + "," + d.tail[0].y + 
+    				" L" + d.cxy.x + "," + d.cxy.y + 
+    				" L" + d.tail[1].x + "," + d.tail[1].y + 
+    				" L" + d.hxy.x + "," + d.hxy.y;
+    	};
+    };
+    jsPlumbUtil.extend(AbstractSvgArrowOverlay, [jsPlumb.jsPlumbUIComponent, jsPlumb.Overlays.AbstractOverlay], {
+    	cleanup : function() {
+    		if (this.path != null) this._jsPlumb.instance.removeElement(this.path);
+    	},
+    	setVisible:function(v) {
+    		if(this.path != null) (this.path.style.display = (v ? "block" : "none"));
+    	}
+    });
+    
+    jsPlumb.Overlays.svg.Arrow = function() {
+    	AbstractSvgArrowOverlay.apply(this, [jsPlumb.Overlays.Arrow, arguments]);    	
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.svg.Arrow, [ jsPlumb.Overlays.Arrow, AbstractSvgArrowOverlay ]);
+    
+    jsPlumb.Overlays.svg.PlainArrow = function() {
+    	AbstractSvgArrowOverlay.apply(this, [jsPlumb.Overlays.PlainArrow, arguments]);    	
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.svg.PlainArrow, [ jsPlumb.Overlays.PlainArrow, AbstractSvgArrowOverlay ]);
+    
+    jsPlumb.Overlays.svg.Diamond = function() {
+    	AbstractSvgArrowOverlay.apply(this, [jsPlumb.Overlays.Diamond, arguments]);    	
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.svg.Diamond, [ jsPlumb.Overlays.Diamond, AbstractSvgArrowOverlay ]);
+
+    // a test
+    jsPlumb.Overlays.svg.GuideLines = function() {
+        var path = null, self = this, p1_1, p1_2;        
+        jsPlumb.Overlays.GuideLines.apply(this, arguments);
+        this.paint = function(params, containerExtents) {
+    		if (path == null) {
+    			path = _node("path");
+    			params.connector.svg.appendChild(path);
+    			self.attachListeners(path, params.connector);
+    			self.attachListeners(path, self);
+
+                p1_1 = _node("path");
+    			params.connector.svg.appendChild(p1_1);
+    			self.attachListeners(p1_1, params.connector);
+    			self.attachListeners(p1_1, self);
+
+                p1_2 = _node("path");
+    			params.connector.svg.appendChild(p1_2);
+    			self.attachListeners(p1_2, params.connector);
+    			self.attachListeners(p1_2, self);
+    		}
+
+    		var offset =[0,0];
+    		if (containerExtents.xmin < 0) offset[0] = -containerExtents.xmin;
+    		if (containerExtents.ymin < 0) offset[1] = -containerExtents.ymin;
+
+    		_attr(path, {
+    			"d"		:	makePath(params.head, params.tail),
+    			stroke 	: 	"red",
+    			fill 	: 	null,
+    			transform:"translate(" + offset[0] + "," + offset[1] + ")"
+    		});
+
+            _attr(p1_1, {
+    			"d"		:	makePath(params.tailLine[0], params.tailLine[1]),
+    			stroke 	: 	"blue",
+    			fill 	: 	null,
+    			transform:"translate(" + offset[0] + "," + offset[1] + ")"
+    		});
+
+            _attr(p1_2, {
+    			"d"		:	makePath(params.headLine[0], params.headLine[1]),
+    			stroke 	: 	"green",
+    			fill 	: 	null,
+    			transform:"translate(" + offset[0] + "," + offset[1] + ")"
+    		});
+    	};
+
+        var makePath = function(d1, d2) {
+            return "M " + d1.x + "," + d1.y +
+                   " L" + d2.x + "," + d2.y;
+        };        
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.svg.GuideLines, jsPlumb.Overlays.GuideLines);
+})();
+
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the VML renderers.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */
+
+;(function() {
+	
+	"use strict";
+	
+	// http://ajaxian.com/archives/the-vml-changes-in-ie-8
+	// http://www.nczonline.net/blog/2010/01/19/internet-explorer-8-document-and-browser-modes/
+	// http://www.louisremi.com/2009/03/30/changes-in-vml-for-ie8-or-what-feature-can-the-ie-dev-team-break-for-you-today/
+	
+	var vmlAttributeMap = {
+		"stroke-linejoin":"joinstyle",
+		"joinstyle":"joinstyle",		
+		"endcap":"endcap",
+		"miterlimit":"miterlimit"
+	},
+	jsPlumbStylesheet = null;
+	
+	if (document.createStyleSheet && document.namespaces) {			
+		
+		var ruleClasses = [
+				".jsplumb_vml", "jsplumb\\:textbox", "jsplumb\\:oval", "jsplumb\\:rect", 
+				"jsplumb\\:stroke", "jsplumb\\:shape", "jsplumb\\:group"
+			],
+			rule = "behavior:url(#default#VML);position:absolute;";
+
+		jsPlumbStylesheet = document.createStyleSheet();
+
+		for (var i = 0; i < ruleClasses.length; i++)
+			jsPlumbStylesheet.addRule(ruleClasses[i], rule);
+
+		// in this page it is also mentioned that IE requires the extra arg to the namespace
+		// http://www.louisremi.com/2009/03/30/changes-in-vml-for-ie8-or-what-feature-can-the-ie-dev-team-break-for-you-today/
+		// but someone commented saying they didn't need it, and it seems jsPlumb doesnt need it either.
+		// var iev = document.documentMode;
+		//if (!iev || iev < 8)
+			document.namespaces.add("jsplumb", "urn:schemas-microsoft-com:vml");
+		//else
+		//	document.namespaces.add("jsplumb", "urn:schemas-microsoft-com:vml", "#default#VML");
+	}
+	
+	jsPlumb.vml = {};
+	
+	var scale = 1000,
+    
+	_atts = function(o, atts) {
+		for (var i in atts) { 
+			// IE8 fix: setattribute does not work after an element has been added to the dom!
+			// http://www.louisremi.com/2009/03/30/changes-in-vml-for-ie8-or-what-feature-can-the-ie-dev-team-break-for-you-today/
+			//o.setAttribute(i, atts[i]);
+
+			/*There is an additional problem when accessing VML elements by using get/setAttribute. The simple solution is following:
+
+			if (document.documentMode==8) {
+			ele.opacity=1;
+			} else {
+			ele.setAttribute(‘opacity’,1);
+			}
+			*/
+
+			o[i] = atts[i];
+		}
+	},
+	_node = function(name, d, atts, parent, _jsPlumb, deferToJsPlumbContainer) {
+		atts = atts || {};
+		var o = document.createElement("jsplumb:" + name);
+		if (deferToJsPlumbContainer)
+			_jsPlumb.appendElement(o, parent);
+		else
+			// TODO is this failing? that would be because parent is not a plain DOM element.
+			// IF SO, uncomment the line below this one and remove this one.
+			parent.appendChild(o);
+			//jsPlumb.getDOMElement(parent).appendChild(o);
+			
+		o.className = (atts["class"] ? atts["class"] + " " : "") + "jsplumb_vml";
+		_pos(o, d);
+		_atts(o, atts);
+		return o;
+	},
+	_pos = function(o,d, zIndex) {
+		o.style.left = d[0] + "px";		
+		o.style.top =  d[1] + "px";
+		o.style.width= d[2] + "px";
+		o.style.height= d[3] + "px";
+		o.style.position = "absolute";
+		if (zIndex)
+			o.style.zIndex = zIndex;
+	},
+	_conv = jsPlumb.vml.convertValue = function(v) {
+		return Math.floor(v * scale);
+	},	
+	// tests if the given style is "transparent" and then sets the appropriate opacity node to 0 if so,
+	// or 1 if not.  TODO in the future, support variable opacity.
+	_maybeSetOpacity = function(styleToWrite, styleToCheck, type, component) {
+		if ("transparent" === styleToCheck)
+			component.setOpacity(type, "0.0");
+		else
+			component.setOpacity(type, "1.0");
+	},
+	_applyStyles = function(node, style, component, _jsPlumb) {
+		var styleToWrite = {};
+		if (style.strokeStyle) {
+			styleToWrite.stroked = "true";
+			var strokeColor = jsPlumbUtil.convertStyle(style.strokeStyle, true);
+			styleToWrite.strokecolor = strokeColor;
+			_maybeSetOpacity(styleToWrite, strokeColor, "stroke", component);
+			styleToWrite.strokeweight = style.lineWidth + "px";
+		}
+		else styleToWrite.stroked = "false";
+		
+		if (style.fillStyle) {
+			styleToWrite.filled = "true";
+			var fillColor = jsPlumbUtil.convertStyle(style.fillStyle, true);
+			styleToWrite.fillcolor = fillColor;
+			_maybeSetOpacity(styleToWrite, fillColor, "fill", component);
+		}
+		else styleToWrite.filled = "false";
+		
+		if(style.dashstyle) {
+			if (component.strokeNode == null) {
+				component.strokeNode = _node("stroke", [0,0,0,0], { dashstyle:style.dashstyle }, node, _jsPlumb);				
+			}
+			else
+				component.strokeNode.dashstyle = style.dashstyle;
+		}					
+		else if (style["stroke-dasharray"] && style.lineWidth) {
+			var sep = style["stroke-dasharray"].indexOf(",") == -1 ? " " : ",",
+			parts = style["stroke-dasharray"].split(sep),
+			styleToUse = "";
+			for(var i = 0; i < parts.length; i++) {
+				styleToUse += (Math.floor(parts[i] / style.lineWidth) + sep);
+			}
+			if (component.strokeNode == null) {
+				component.strokeNode = _node("stroke", [0,0,0,0], { dashstyle:styleToUse }, node, _jsPlumb);				
+			}
+			else
+				component.strokeNode.dashstyle = styleToUse;
+		}
+		
+		_atts(node, styleToWrite);
+	},
+	/*
+	 * Base class for Vml endpoints and connectors. Extends jsPlumbUIComponent. 
+	 */
+	VmlComponent = function() {				
+		var self = this, renderer = {};
+		jsPlumb.jsPlumbUIComponent.apply(this, arguments);	
+
+		this.opacityNodes = {
+			"stroke":null,
+			"fill":null
+		};
+		this.initOpacityNodes = function(vml) {
+			self.opacityNodes.stroke = _node("stroke", [0,0,1,1], {opacity:"0.0"}, vml, self._jsPlumb.instance);
+			self.opacityNodes.fill = _node("fill", [0,0,1,1], {opacity:"0.0"}, vml, self._jsPlumb.instance);							
+		};
+		this.setOpacity = function(type, value) {
+			var node = self.opacityNodes[type];
+			if (node) node.opacity = "" + value;
+		};
+		var displayElements = [ ];
+		this.getDisplayElements = function() { 
+			return displayElements; 
+		};
+		
+		this.appendDisplayElement = function(el, doNotAppendToCanvas) {
+			if (!doNotAppendToCanvas) self.canvas.parentNode.appendChild(el);
+			displayElements.push(el);
+		};
+	};
+	jsPlumbUtil.extend(VmlComponent, jsPlumb.jsPlumbUIComponent, {
+		cleanup:function() {			
+			if (this.bgCanvas) this.bgCanvas.parentNode.removeChild(this.bgCanvas);
+			if (this.canvas) this.canvas.parentNode.removeChild(this.canvas);
+		}
+	});
+
+	/*
+	 * Base class for Vml connectors. extends VmlComponent.
+	 */
+	var VmlConnector = jsPlumb.ConnectorRenderers.vml = function(params, component) {
+		this.strokeNode = null;
+		this.canvas = null;
+		VmlComponent.apply(this, arguments);
+		var clazz = this._jsPlumb.instance.connectorClass + (params.cssClass ? (" " + params.cssClass) : "");
+		this.paint = function(style) {		
+			if (style !== null) {			
+
+				// we need to be at least 1 pixel in each direction, because otherwise coordsize gets set to
+				// 0 and overlays cannot paint.
+				this.w = Math.max(this.w, 1);
+				this.h = Math.max(this.h, 1);
+
+				var segments = this.getSegments(), p = { "path":"" },
+                    d = [this.x, this.y, this.w, this.h];
+				
+				// create path from segments.	
+				for (var i = 0; i < segments.length; i++) {
+					p.path += jsPlumb.Segments.vml.SegmentRenderer.getPath(segments[i]);
+					p.path += " ";
+				}
+
+                //*
+				if (style.outlineColor) {
+					var outlineWidth = style.outlineWidth || 1,
+					outlineStrokeWidth = style.lineWidth + (2 * outlineWidth),
+					outlineStyle = {
+						strokeStyle : jsPlumbUtil.convertStyle(style.outlineColor),
+						lineWidth : outlineStrokeWidth
+					};
+					for (var aa in vmlAttributeMap) outlineStyle[aa] = style[aa];
+					
+					if (this.bgCanvas == null) {						
+						p["class"] = clazz;
+						p.coordsize = (d[2] * scale) + "," + (d[3] * scale);
+						this.bgCanvas = _node("shape", d, p, params.parent, this._jsPlumb.instance, true);						
+						_pos(this.bgCanvas, d);
+						this.appendDisplayElement(this.bgCanvas, true);
+						this.initOpacityNodes(this.bgCanvas, ["stroke"]);
+                        this.bgCanvas._jsPlumb = component;
+					}
+					else {
+						p.coordsize = (d[2] * scale) + "," + (d[3] * scale);
+						_pos(this.bgCanvas, d);
+						_atts(this.bgCanvas, p);
+					}
+					
+					_applyStyles(this.bgCanvas, outlineStyle, this);
+				}
+				//*/
+				
+				if (this.canvas == null) {										
+					p["class"] = clazz;
+					p.coordsize = (d[2] * scale) + "," + (d[3] * scale);					
+					this.canvas = _node("shape", d, p, params.parent, this._jsPlumb.instance, true);					                                    
+					this.appendDisplayElement(this.canvas, true);
+					this.initOpacityNodes(this.canvas, ["stroke"]);
+                    this.canvas._jsPlumb = component;
+				}
+				else {
+					p.coordsize = (d[2] * scale) + "," + (d[3] * scale);
+					_pos(this.canvas, d);
+					_atts(this.canvas, p);
+				}
+				
+				_applyStyles(this.canvas, style, this, this._jsPlumb.instance);
+			}
+		};	
+				
+	};
+	jsPlumbUtil.extend(VmlConnector, VmlComponent, {
+		setVisible:function(v) {
+			if (this.canvas) {
+				this.canvas.style.display = v ? "block" : "none";
+			}
+			if (this.bgCanvas) {
+				this.bgCanvas.style.display = v ? "block" : "none";
+			}
+		}
+	});	
+	
+	/*
+	 * 
+	 * Base class for Vml Endpoints. extends VmlComponent.
+	 * 
+	 */
+	var VmlEndpoint = window.VmlEndpoint = function(params) {
+		VmlComponent.apply(this, arguments);
+		this._jsPlumb.vml = null;//, opacityStrokeNode = null, opacityFillNode = null;
+		this.canvas = document.createElement("div");
+		this.canvas.style.position = "absolute";
+		this._jsPlumb.clazz = this._jsPlumb.instance.endpointClass + (params.cssClass ? (" " + params.cssClass) : "");
+
+		// TODO vml endpoint adds class to VML at constructor time.  but the addClass method adds VML
+		// to the enclosing DIV. what to do?  seems like it would be better to just target the div.
+		// HOWEVER...vml connection has no containing div.  why not? it feels like it should.
+
+		params._jsPlumb.appendElement(this.canvas, params.parent);
+
+		this.paint = function(style, anchor) {
+			var p = { }, vml = this._jsPlumb.vml;				
+			
+			jsPlumbUtil.sizeElement(this.canvas, this.x, this.y, this.w, this.h);
+			if (this._jsPlumb.vml == null) {
+				p["class"] = this._jsPlumb.clazz;
+				vml = this._jsPlumb.vml = this.getVml([0,0, this.w, this.h], p, anchor, this.canvas, this._jsPlumb.instance);				
+
+                this.appendDisplayElement(vml, true);
+				this.appendDisplayElement(this.canvas, true);
+				
+				this.initOpacityNodes(vml, ["fill"]);			
+			}
+			else {				
+				_pos(vml, [0,0, this.w, this.h]);
+				_atts(vml, p);
+			}
+			
+			_applyStyles(vml, style, this);
+		};		
+	};
+	jsPlumbUtil.extend(VmlEndpoint, VmlComponent);
+	
+// ******************************* vml segments *****************************************************	
+		
+	jsPlumb.Segments.vml = {
+		SegmentRenderer : {		
+			getPath : function(segment) {
+				return ({
+					"Straight":function(segment) {
+						var d = segment.params;
+						return "m" + _conv(d.x1) + "," + _conv(d.y1) + " l" + _conv(d.x2) + "," + _conv(d.y2) + " e";
+					},
+					"Bezier":function(segment) {
+						var d = segment.params;
+						return "m" + _conv(d.x1) + "," + _conv(d.y1) + 
+				   			" c" + _conv(d.cp1x) + "," + _conv(d.cp1y) + "," + _conv(d.cp2x) + "," + _conv(d.cp2y) + "," + _conv(d.x2) + "," + _conv(d.y2) + " e";
+					},
+					"Arc":function(segment) {					
+						var d = segment.params,
+							xmin = Math.min(d.x1, d.x2),
+							xmax = Math.max(d.x1, d.x2),
+							ymin = Math.min(d.y1, d.y2),
+							ymax = Math.max(d.y1, d.y2),														
+							sf = segment.anticlockwise ? 1 : 0,
+							pathType = (segment.anticlockwise ? "at " : "wa "),
+							makePosString = function() {
+								if (d.loopback)
+									return "0,0," + _conv(2*d.r) + "," + _conv(2 * d.r);
+
+								var xy = [
+										null,
+										[ function() { return [xmin, ymin ];}, function() { return [xmin - d.r, ymin - d.r ];}],
+										[ function() { return [xmin - d.r, ymin ];}, function() { return [xmin, ymin - d.r ];}],
+										[ function() { return [xmin - d.r, ymin - d.r ];}, function() { return [xmin, ymin ];}],
+										[ function() { return [xmin, ymin - d.r ];}, function() { return [xmin - d.r, ymin ];}]
+									][segment.segment][sf]();
+
+								return _conv(xy[0]) + "," + _conv(xy[1]) + "," + _conv(xy[0] + (2*d.r)) + "," + _conv(xy[1] + (2*d.r));
+							};
+
+						return pathType + " " + makePosString() + "," + _conv(d.x1) + "," + _conv(d.y1) + "," + _conv(d.x2) + "," + _conv(d.y2) + " e";												
+					}
+						
+				})[segment.type](segment);	
+			}
+		}
+	};
+	
+// ******************************* /vml segments *****************************************************	
+
+// ******************************* vml endpoints *****************************************************
+	
+	jsPlumb.Endpoints.vml.Dot = function() {
+		jsPlumb.Endpoints.Dot.apply(this, arguments);
+		VmlEndpoint.apply(this, arguments);
+		this.getVml = function(d, atts, anchor, parent, _jsPlumb) { return _node("oval", d, atts, parent, _jsPlumb); };
+	};
+	jsPlumbUtil.extend(jsPlumb.Endpoints.vml.Dot, VmlEndpoint);
+	
+	jsPlumb.Endpoints.vml.Rectangle = function() {
+		jsPlumb.Endpoints.Rectangle.apply(this, arguments);
+		VmlEndpoint.apply(this, arguments);
+		this.getVml = function(d, atts, anchor, parent, _jsPlumb) { return _node("rect", d, atts, parent, _jsPlumb); };
+	};
+	jsPlumbUtil.extend(jsPlumb.Endpoints.vml.Rectangle, VmlEndpoint);
+	
+	/*
+	 * VML Image Endpoint is the same as the default image endpoint.
+	 */
+	jsPlumb.Endpoints.vml.Image = jsPlumb.Endpoints.Image;
+	
+	/**
+	 * placeholder for Blank endpoint in vml renderer.
+	 */
+	jsPlumb.Endpoints.vml.Blank = jsPlumb.Endpoints.Blank;
+	
+// ******************************* /vml endpoints *****************************************************	
+
+// ******************************* vml overlays *****************************************************
+	
+	/**
+	 * VML Label renderer. uses the default label renderer (which adds an element to the DOM)
+	 */
+	jsPlumb.Overlays.vml.Label  = jsPlumb.Overlays.Label;
+	
+	/**
+	 * VML Custom renderer. uses the default Custom renderer (which adds an element to the DOM)
+	 */
+	jsPlumb.Overlays.vml.Custom = jsPlumb.Overlays.Custom;
+	
+	/**
+	 * Abstract VML arrow superclass
+	 */
+	var AbstractVmlArrowOverlay = function(superclass, originalArgs) {
+    	superclass.apply(this, originalArgs);
+    	VmlComponent.apply(this, originalArgs);
+    	var self = this, path = null;
+    	this.canvas = null; 
+    	this.isAppendedAtTopLevel = true;
+    	var getPath = function(d) {    		
+    		return "m " + _conv(d.hxy.x) + "," + _conv(d.hxy.y) +
+    		       " l " + _conv(d.tail[0].x) + "," + _conv(d.tail[0].y) + 
+    		       " " + _conv(d.cxy.x) + "," + _conv(d.cxy.y) + 
+    		       " " + _conv(d.tail[1].x) + "," + _conv(d.tail[1].y) + 
+    		       " x e";
+    	};
+    	this.paint = function(params, containerExtents) {
+    		// only draws for connectors, not endpoints.
+    		if (params.component.canvas && containerExtents) {
+	    		var p = {}, d = params.d, connector = params.component;
+				if (params.strokeStyle) {
+					p.stroked = "true";
+					p.strokecolor = jsPlumbUtil.convertStyle(params.strokeStyle, true);    				
+				}
+				if (params.lineWidth) p.strokeweight = params.lineWidth + "px";
+				if (params.fillStyle) {
+					p.filled = "true";
+					p.fillcolor = params.fillStyle;
+				}			
+
+				var xmin = Math.min(d.hxy.x, d.tail[0].x, d.tail[1].x, d.cxy.x),
+					ymin = Math.min(d.hxy.y, d.tail[0].y, d.tail[1].y, d.cxy.y),
+					xmax = Math.max(d.hxy.x, d.tail[0].x, d.tail[1].x, d.cxy.x),
+					ymax = Math.max(d.hxy.y, d.tail[0].y, d.tail[1].y, d.cxy.y),
+					w = Math.abs(xmax - xmin),
+					h = Math.abs(ymax - ymin),
+					dim = [xmin, ymin, w, h];
+
+				// for VML, we create overlays using shapes that have the same dimensions and
+				// coordsize as their connector - overlays calculate themselves relative to the
+				// connector (it's how it's been done since the original canvas implementation, because
+				// for canvas that makes sense).
+				p.path = getPath(d);
+				p.coordsize = (connector.w * scale) + "," + (connector.h * scale);			
+				
+				dim[0] = connector.x;
+				dim[1] = connector.y;
+				dim[2] = connector.w;
+				dim[3] = connector.h;
+				
+	    		if (self.canvas == null) {
+	    			var overlayClass = connector._jsPlumb.overlayClass || "";
+	    			var clazz = originalArgs && (originalArgs.length == 1) ? (originalArgs[0].cssClass || "") : "";
+	    			p["class"] = clazz + " " + overlayClass;
+					self.canvas = _node("shape", dim, p, connector.canvas.parentNode, connector._jsPlumb.instance, true);								
+					connector.appendDisplayElement(self.canvas, true);
+				}
+				else {				
+					_pos(self.canvas, dim);
+					_atts(self.canvas, p);
+				}    		
+			}
+    	};
+		this.cleanup = function() {
+    		if (this.canvas != null) this._jsPlumb.instance.removeElement(this.canvas);
+    	};
+    };
+    jsPlumbUtil.extend(AbstractVmlArrowOverlay, [VmlComponent, jsPlumb.Overlays.AbstractOverlay], {
+    	setVisible : function(state) {
+    	    this.canvas.style.display = state ? "block" : "none";
+    	}
+    });
+	
+	jsPlumb.Overlays.vml.Arrow = function() {
+    	AbstractVmlArrowOverlay.apply(this, [jsPlumb.Overlays.Arrow, arguments]);    	
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.vml.Arrow, [ jsPlumb.Overlays.Arrow, AbstractVmlArrowOverlay ]);
+    
+    jsPlumb.Overlays.vml.PlainArrow = function() {
+    	AbstractVmlArrowOverlay.apply(this, [jsPlumb.Overlays.PlainArrow, arguments]);    	
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.vml.PlainArrow, [ jsPlumb.Overlays.PlainArrow, AbstractVmlArrowOverlay ]);
+    
+    jsPlumb.Overlays.vml.Diamond = function() {
+    	AbstractVmlArrowOverlay.apply(this, [jsPlumb.Overlays.Diamond, arguments]);    	
+    };
+    jsPlumbUtil.extend(jsPlumb.Overlays.vml.Diamond, [ jsPlumb.Overlays.Diamond, AbstractVmlArrowOverlay ]);
+    
+// ******************************* /vml overlays *****************************************************    
+    
+})();
+
+/*
+ * jsPlumb
+ * 
+ * Title:jsPlumb 1.7.2
+ * 
+ * Provides a way to visually connect elements on an HTML page, using SVG or VML.  
+ * 
+ * This file contains the jQuery adapter.
+ *
+ * Copyright (c) 2010 - 2014 Simon Porritt (simon@jsplumbtoolkit.com)
+ * 
+ * http://jsplumbtoolkit.com
+ * http://github.com/sporritt/jsplumb
+ * 
+ * Dual licensed under the MIT and GPL2 licenses.
+ */  
+;(function($) {
+	
+	"use strict";
+
+	var _getElementObject = function(el) {
+		return typeof(el) == "string" ? $("#" + el) : $(el);
+	};
+
+	$.extend(jsPlumbInstance.prototype, {
+
+// ---------------------------- DOM MANIPULATION ---------------------------------------		
+				
+		
+		/**
+		* gets a DOM element from the given input, which might be a string (in which case we just do document.getElementById),
+		* a selector (in which case we return el[0]), or a DOM element already (we assume this if it's not either of the other
+		* two cases).  this is the opposite of getElementObject below.
+		*/
+		getDOMElement : function(el) {
+			if (el == null) return null;
+			if (typeof(el) == "string") return document.getElementById(el);
+			else if (el.context || el.length != null) return el[0];
+			else return el;
+		},
+		
+		/**
+		 * gets an "element object" from the given input.  this means an object that is used by the
+		 * underlying library on which jsPlumb is running.  'el' may already be one of these objects,
+		 * in which case it is returned as-is.  otherwise, 'el' is a String, the library's lookup 
+		 * function is used to find the element, using the given String as the element's id.
+		 * 
+		 */
+		getElementObject : _getElementObject,
+
+		/**
+		* removes an element from the DOM.  doing it via the library is
+		* safer from a memory perspective, as it ix expected that the library's 
+		* remove method will unbind any event listeners before removing the element from the DOM.
+		*/
+		removeElement:function(element) {
+			_getElementObject(element).remove();
+		},
+
+// ---------------------------- END DOM MANIPULATION ---------------------------------------
+
+// ---------------------------- MISCELLANEOUS ---------------------------------------
+
+		/**
+		 * animates the given element.
+		 */
+		doAnimate : function(el, properties, options) {
+			el.animate(properties, options);
+		},	
+		getSelector : function(context, spec) {
+            if (arguments.length == 2)
+                return _getElementObject(context).find(spec);
+            else
+                return $(context);
+		},
+
+// ---------------------------- END MISCELLANEOUS ---------------------------------------		
+
+// -------------------------------------- DRAG/DROP	---------------------------------
+		
+		destroyDraggable : function(el) {
+			if ($(el).data("draggable"))
+				$(el).draggable("destroy");
+		},
+
+		destroyDroppable : function(el) {
+			if ($(el).data("droppable"))
+				$(el).droppable("destroy");
+		},
+		/**
+		 * initialises the given element to be draggable.
+		 */
+		initDraggable : function(el, options, isPlumbedComponent) {
+			options = options || {};
+			el = $(el);
+
+			options.start = jsPlumbUtil.wrap(options.start, function() {
+				$("body").addClass(this.dragSelectClass);
+			}, false);
+
+			options.stop = jsPlumbUtil.wrap(options.stop, function() {
+				$("body").removeClass(this.dragSelectClass);
+			});
+
+			// remove helper directive if present and no override
+			if (!options.doNotRemoveHelper)
+				options.helper = null;
+
+
+			if (isPlumbedComponent == "internal")
+				options.scope = options.scope || jsPlumb.Defaults.Scope;
+
+			el.draggable(options);
+		},
+		
+		/**
+		 * initialises the given element to be droppable.
+		 */
+		initDroppable : function(el, options) {
+			options.scope = options.scope || jsPlumb.Defaults.Scope;
+            $(el).droppable(options);
+		},
+		
+		isAlreadyDraggable : function(el) {
+			return $(el).hasClass("ui-draggable");
+		},
+		
+		/**
+		 * returns whether or not drag is supported (by the library, not whether or not it is disabled) for the given element.
+		 */
+		isDragSupported : function(el, options) {
+			return $(el).draggable;
+		},
+
+		/**
+		 * returns whether or not drop is supported (by the library, not whether or not it is disabled) for the given element.
+		 */
+		isDropSupported : function(el, options) {
+			return $(el).droppable;
+		},
+		/**
+		 * takes the args passed to an event function and returns you an object representing that which is being dragged.
+		 */
+		getDragObject : function(eventArgs) {
+			//return eventArgs[1].draggable || eventArgs[1].helper;
+			return eventArgs[1].helper || eventArgs[1].draggable;
+		},
+		
+		getDragScope : function(el) {
+			return $(el).draggable("option", "scope");
+		},
+
+		getDropEvent : function(args) {
+			return args[0];
+		},
+		
+		getDropScope : function(el) {
+			return $(el).droppable("option", "scope");
+		},
+		/**
+		 * takes the args passed to an event function and returns you an object that gives the
+		 * position of the object being moved, as a js object with the same params as the result of
+		 * getOffset, ie: { left: xxx, top: xxx }.
+		 * 
+		 * different libraries have different signatures for their event callbacks.  
+		 * see getDragObject as well
+		 */
+		getUIPosition : function(eventArgs, zoom, dontAdjustHelper) {
+			var ret;
+			zoom = zoom || 1;
+			if (eventArgs.length == 1) {
+				ret = { left: eventArgs[0].pageX, top:eventArgs[0].pageY };
+			}
+			else {
+				var ui = eventArgs[1],
+				  _offset = ui.position;//ui.offset;
+				  
+				ret = _offset || ui.absolutePosition;
+				
+				// adjust ui position to account for zoom, because jquery ui does not do this.
+				if (!dontAdjustHelper) {
+					ui.position.left /= zoom;
+					ui.position.top /= zoom;
+				}
+			}
+			return { left:ret.left, top: ret.top  };
+		},
+		
+		isDragFilterSupported:function() { return true; },
+		
+		setDragFilter : function(el, filter) {
+			if (jsPlumb.isAlreadyDraggable(el))
+				$(el).draggable("option", "cancel", filter);
+		},
+		
+		setElementDraggable : function(el, draggable) {
+			$(el).draggable("option", "disabled", !draggable);
+		},
+		
+		setDragScope : function(el, scope) {
+			$(el).draggable("option", "scope", scope);
+		},
+		/**
+         * mapping of drag events for jQuery
+         */
+		dragEvents : {
+			'start':'start', 'stop':'stop', 'drag':'drag', 'step':'step',
+			'over':'over', 'out':'out', 'drop':'drop', 'complete':'complete'
+		},
+		animEvents:{
+			'step':"step", 'complete':'complete'
+		},
+        getOriginalEvent : function(e) { return e.originalEvent || e; },
+        /**
+         * note that jquery ignores the name of the event you wanted to trigger, and figures it out for itself.
+         * the other libraries do not.  yui, in fact, cannot even pass an original event.  we have to pull out stuff
+         * from the originalEvent to put in an options object for YUI.
+         * @param el
+         * @param event
+         * @param originalEvent
+         */
+        trigger : function(el, event, originalEvent) {
+            var h = jQuery._data(_getElementObject(el)[0], "handle");
+            h(originalEvent);
+        }
+		
+// -------------------------------------- END DRAG/DROP	---------------------------------		
+
+	});
+
+	$(document).ready(jsPlumb.init);
+
+})(jQuery);
+

+ 8 - 0
course-design/libs/jsBezier-0.6-min.js

@@ -0,0 +1,8 @@
+(function(){"undefined"==typeof Math.sgn&&(Math.sgn=function(a){return 0==a?0:0<a?1:-1});var q={subtract:function(a,b){return{x:a.x-b.x,y:a.y-b.y}},dotProduct:function(a,b){return a.x*b.x+a.y*b.y},square:function(a){return Math.sqrt(a.x*a.x+a.y*a.y)},scale:function(a,b){return{x:a.x*b,y:a.y*b}}},B=Math.pow(2,-65),x=function(a,b){for(var f=[],d=b.length-1,g=2*d-1,h=[],e=[],m=[],k=[],l=[[1,0.6,0.3,0.1],[0.4,0.6,0.6,0.4],[0.1,0.3,0.6,1]],c=0;c<=d;c++)h[c]=q.subtract(b[c],a);for(c=0;c<=d-1;c++)e[c]=q.subtract(b[c+
+1],b[c]),e[c]=q.scale(e[c],3);for(c=0;c<=d-1;c++)for(var n=0;n<=d;n++)m[c]||(m[c]=[]),m[c][n]=q.dotProduct(e[c],h[n]);for(c=0;c<=g;c++)k[c]||(k[c]=[]),k[c].y=0,k[c].x=parseFloat(c)/g;g=d-1;for(h=0;h<=d+g;h++){c=Math.max(0,h-g);for(e=Math.min(h,d);c<=e;c++)j=h-c,k[c+j].y+=m[j][c]*l[j][c]}d=b.length-1;k=u(k,2*d-1,f,0);g=q.subtract(a,b[0]);m=q.square(g);for(c=l=0;c<k;c++)g=q.subtract(a,v(b,d,f[c],null,null)),g=q.square(g),g<m&&(m=g,l=f[c]);g=q.subtract(a,b[d]);g=q.square(g);g<m&&(m=g,l=1);return{location:l,
+distance:m}},u=function(a,b,f,d){var g=[],h=[],e=[],m=[],k=0,l,c;c=Math.sgn(a[0].y);for(var n=1;n<=b;n++)l=Math.sgn(a[n].y),l!=c&&k++,c=l;switch(k){case 0:return 0;case 1:if(64<=d)return f[0]=(a[0].x+a[b].x)/2,1;var r,p,k=a[0].y-a[b].y;c=a[b].x-a[0].x;n=a[0].x*a[b].y-a[b].x*a[0].y;l=max_distance_below=0;for(r=1;r<b;r++)p=k*a[r].x+c*a[r].y+n,p>l?l=p:p<max_distance_below&&(max_distance_below=p);p=c;r=0*p-1*k;l=(1*(n-l)-0*p)*(1/r);p=c;c=n-max_distance_below;r=0*p-1*k;k=(1*c-0*p)*(1/r);c=Math.min(l,k);
+if(Math.max(l,k)-c<B)return e=a[b].x-a[0].x,m=a[b].y-a[0].y,f[0]=0+1*(e*(a[0].y-0)-m*(a[0].x-0))*(1/(0*e-1*m)),1}v(a,b,0.5,g,h);a=u(g,b,e,d+1);b=u(h,b,m,d+1);for(d=0;d<a;d++)f[d]=e[d];for(d=0;d<b;d++)f[d+a]=m[d];return a+b},v=function(a,b,f,d,g){for(var h=[[]],e=0;e<=b;e++)h[0][e]=a[e];for(a=1;a<=b;a++)for(e=0;e<=b-a;e++)h[a]||(h[a]=[]),h[a][e]||(h[a][e]={}),h[a][e].x=(1-f)*h[a-1][e].x+f*h[a-1][e+1].x,h[a][e].y=(1-f)*h[a-1][e].y+f*h[a-1][e+1].y;if(null!=d)for(e=0;e<=b;e++)d[e]=h[e][0];if(null!=g)for(e=
+0;e<=b;e++)g[e]=h[b-e][e];return h[b][0]},y={},s=function(a,b){var f,d=a.length-1;f=y[d];if(!f){f=[];var g=function(a){return function(){return a}},h=function(){return function(a){return a}},e=function(){return function(a){return 1-a}},m=function(a){return function(b){for(var c=1,d=0;d<a.length;d++)c*=a[d](b);return c}};f.push(new function(){return function(a){return Math.pow(a,d)}});for(var k=1;k<d;k++){for(var l=[new g(d)],c=0;c<d-k;c++)l.push(new h);for(c=0;c<k;c++)l.push(new e);f.push(new m(l))}f.push(new function(){return function(a){return Math.pow(1-
+a,d)}});y[d]=f}for(e=h=g=0;e<a.length;e++)g+=a[e].x*f[e](b),h+=a[e].y*f[e](b);return{x:g,y:h}},z=function(a,b){return Math.sqrt(Math.pow(a.x-b.x,2)+Math.pow(a.y-b.y,2))},A=function(a){return a[0].x==a[1].x&&a[0].y==a[1].y},t=function(a,b,f){if(A(a))return{point:a[0],location:b};for(var d=s(a,b),g=0,h=0<f?1:-1,e=null;g<Math.abs(f);)b+=0.005*h,e=s(a,b),g+=z(e,d),d=e;return{point:e,location:b}},w=function(a,b){var f=s(a,b),d=s(a.slice(0,a.length-1),b),g=d.y-f.y,f=d.x-f.x;return 0==g?Infinity:Math.atan(g/
+f)};window.jsBezier={distanceFromCurve:x,gradientAtPoint:w,gradientAtPointAlongCurveFrom:function(a,b,f){b=t(a,b,f);1<b.location&&(b.location=1);0>b.location&&(b.location=0);return w(a,b.location)},nearestPointOnCurve:function(a,b){var f=x(a,b);return{point:v(b,b.length-1,f.location,null,null),location:f.location}},pointOnCurve:s,pointAlongCurveFrom:function(a,b,f){return t(a,b,f).point},perpendicularToCurveAt:function(a,b,f,d){b=t(a,b,null==d?0:d);a=w(a,b.location);d=Math.atan(-1/a);a=f/2*Math.sin(d);
+f=f/2*Math.cos(d);return[{x:b.point.x+f,y:b.point.y+a},{x:b.point.x-f,y:b.point.y-a}]},locationAlongCurveFrom:function(a,b,f){return t(a,b,f).location},getLength:function(a){if(A(a))return 0;for(var b=s(a,0),f=0,d=0,g=null;1>d;)d+=0.005,g=s(a,d),f+=z(g,b),b=g;return f}}})();

+ 422 - 0
course-design/libs/jsBezier-0.6.js

@@ -0,0 +1,422 @@
+/**
+* jsBezier-0.6
+*
+* Copyright (c) 2010 - 2013 Simon Porritt (simon.porritt@gmail.com)
+*
+* licensed under the MIT license.
+* 
+* a set of Bezier curve functions that deal with Beziers, used by jsPlumb, and perhaps useful for other people.  These functions work with Bezier
+* curves of arbitrary degree.
+*
+* - functions are all in the 'jsBezier' namespace.  
+* 
+* - all input points should be in the format {x:.., y:..}. all output points are in this format too.
+* 
+* - all input curves should be in the format [ {x:.., y:..}, {x:.., y:..}, {x:.., y:..}, {x:.., y:..} ]
+* 
+* - 'location' as used as an input here refers to a decimal in the range 0-1 inclusive, which indicates a point some proportion along the length
+* of the curve.  location as output has the same format and meaning.
+* 
+* 
+* Function List:
+* --------------
+* 
+* distanceFromCurve(point, curve)
+* 
+* 	Calculates the distance that the given point lies from the given Bezier.  Note that it is computed relative to the center of the Bezier,
+* so if you have stroked the curve with a wide pen you may wish to take that into account!  The distance returned is relative to the values 
+* of the curve and the point - it will most likely be pixels.
+* 
+* gradientAtPoint(curve, location)
+* 
+* 	Calculates the gradient to the curve at the given location, as a decimal between 0 and 1 inclusive.
+*
+* gradientAtPointAlongCurveFrom (curve, location)
+*
+*	Calculates the gradient at the point on the given curve that is 'distance' units from location. 
+* 
+* nearestPointOnCurve(point, curve) 
+* 
+*	Calculates the nearest point to the given point on the given curve.  The return value of this is a JS object literal, containing both the
+*point's coordinates and also the 'location' of the point (see above), for example:  { point:{x:551,y:150}, location:0.263365 }.
+* 
+* pointOnCurve(curve, location)
+* 
+* 	Calculates the coordinates of the point on the given Bezier curve at the given location.  
+* 		
+* pointAlongCurveFrom(curve, location, distance)
+* 
+* 	Calculates the coordinates of the point on the given curve that is 'distance' units from location.  'distance' should be in the same coordinate
+* space as that used to construct the Bezier curve.  For an HTML Canvas usage, for example, distance would be a measure of pixels.
+*
+* locationAlongCurveFrom(curve, location, distance)
+* 
+* 	Calculates the location on the given curve that is 'distance' units from location.  'distance' should be in the same coordinate
+* space as that used to construct the Bezier curve.  For an HTML Canvas usage, for example, distance would be a measure of pixels.
+* 
+* perpendicularToCurveAt(curve, location, length, distance)
+* 
+* 	Calculates the perpendicular to the given curve at the given location.  length is the length of the line you wish for (it will be centered
+* on the point at 'location'). distance is optional, and allows you to specify a point along the path from the given location as the center of
+* the perpendicular returned.  The return value of this is an array of two points: [ {x:...,y:...}, {x:...,y:...} ].  
+*  
+* 
+*/
+
+(function() {
+	
+	if(typeof Math.sgn == "undefined") {
+		Math.sgn = function(x) { return x == 0 ? 0 : x > 0 ? 1 :-1; };
+	}
+	
+	var Vectors = {
+			subtract 	: 	function(v1, v2) { return {x:v1.x - v2.x, y:v1.y - v2.y }; },
+			dotProduct	: 	function(v1, v2) { return (v1.x * v2.x)  + (v1.y * v2.y); },
+			square		:	function(v) { return Math.sqrt((v.x * v.x) + (v.y * v.y)); },
+			scale		:	function(v, s) { return {x:v.x * s, y:v.y * s }; }
+		},
+		
+		maxRecursion = 64, 
+		flatnessTolerance = Math.pow(2.0,-maxRecursion-1);
+
+	/**
+	 * Calculates the distance that the point lies from the curve.
+	 * 
+	 * @param point a point in the form {x:567, y:3342}
+	 * @param curve a Bezier curve in the form [{x:..., y:...}, {x:..., y:...}, {x:..., y:...}, {x:..., y:...}].  note that this is currently
+	 * hardcoded to assume cubiz beziers, but would be better off supporting any degree. 
+	 * @return a JS object literal containing location and distance, for example: {location:0.35, distance:10}.  Location is analogous to the location
+	 * argument you pass to the pointOnPath function: it is a ratio of distance travelled along the curve.  Distance is the distance in pixels from
+	 * the point to the curve. 
+	 */
+	var _distanceFromCurve = function(point, curve) {
+		var candidates = [],     
+	    	w = _convertToBezier(point, curve),
+	    	degree = curve.length - 1, higherDegree = (2 * degree) - 1,
+	    	numSolutions = _findRoots(w, higherDegree, candidates, 0),
+			v = Vectors.subtract(point, curve[0]), dist = Vectors.square(v), t = 0.0;
+
+	    for (var i = 0; i < numSolutions; i++) {
+			v = Vectors.subtract(point, _bezier(curve, degree, candidates[i], null, null));
+	    	var newDist = Vectors.square(v);
+	    	if (newDist < dist) {
+	            dist = newDist;
+	        	t = candidates[i];
+		    }
+	    }
+	    v = Vectors.subtract(point, curve[degree]);
+		newDist = Vectors.square(v);
+	    if (newDist < dist) {
+	        dist = newDist;
+	    	t = 1.0;
+	    }
+		return {location:t, distance:dist};
+	};
+	/**
+	 * finds the nearest point on the curve to the given point.
+	 */
+	var _nearestPointOnCurve = function(point, curve) {    
+		var td = _distanceFromCurve(point, curve);
+	    return {point:_bezier(curve, curve.length - 1, td.location, null, null), location:td.location};
+	};
+	var _convertToBezier = function(point, curve) {
+		var degree = curve.length - 1, higherDegree = (2 * degree) - 1,
+	    	c = [], d = [], cdTable = [], w = [],
+	    	z = [ [1.0, 0.6, 0.3, 0.1], [0.4, 0.6, 0.6, 0.4], [0.1, 0.3, 0.6, 1.0] ];	
+	    	
+	    for (var i = 0; i <= degree; i++) c[i] = Vectors.subtract(curve[i], point);
+	    for (var i = 0; i <= degree - 1; i++) { 
+			d[i] = Vectors.subtract(curve[i+1], curve[i]);
+			d[i] = Vectors.scale(d[i], 3.0);
+	    }
+	    for (var row = 0; row <= degree - 1; row++) {
+			for (var column = 0; column <= degree; column++) {
+				if (!cdTable[row]) cdTable[row] = [];
+		    	cdTable[row][column] = Vectors.dotProduct(d[row], c[column]);
+			}
+	    }
+	    for (i = 0; i <= higherDegree; i++) {
+			if (!w[i]) w[i] = [];
+			w[i].y = 0.0;
+			w[i].x = parseFloat(i) / higherDegree;
+	    }
+	    var n = degree, m = degree-1;
+	    for (var k = 0; k <= n + m; k++) {
+			var lb = Math.max(0, k - m),
+				ub = Math.min(k, n);
+			for (i = lb; i <= ub; i++) {
+		    	j = k - i;
+		    	w[i+j].y += cdTable[j][i] * z[j][i];
+			}
+	    }
+	    return w;
+	};
+	/**
+	 * counts how many roots there are.
+	 */
+	var _findRoots = function(w, degree, t, depth) {  
+	    var left = [], right = [],	
+	    	left_count, right_count,	
+	    	left_t = [], right_t = [];
+	    	
+	    switch (_getCrossingCount(w, degree)) {
+	       	case 0 : {	
+	       		return 0;	
+	       	}
+	       	case 1 : {	
+	       		if (depth >= maxRecursion) {
+	       			t[0] = (w[0].x + w[degree].x) / 2.0;
+	       			return 1;
+	       		}
+	       		if (_isFlatEnough(w, degree)) {
+	       			t[0] = _computeXIntercept(w, degree);
+	       			return 1;
+	       		}
+	       		break;
+	       	}
+	    }
+	    _bezier(w, degree, 0.5, left, right);
+	    left_count  = _findRoots(left,  degree, left_t, depth+1);
+	    right_count = _findRoots(right, degree, right_t, depth+1);
+	    for (var i = 0; i < left_count; i++) t[i] = left_t[i];
+	    for (var i = 0; i < right_count; i++) t[i+left_count] = right_t[i];    
+		return (left_count+right_count);
+	};
+	var _getCrossingCount = function(curve, degree) {
+	    var n_crossings = 0, sign, old_sign;		    	
+	    sign = old_sign = Math.sgn(curve[0].y);
+	    for (var i = 1; i <= degree; i++) {
+			sign = Math.sgn(curve[i].y);
+			if (sign != old_sign) n_crossings++;
+			old_sign = sign;
+	    }
+	    return n_crossings;
+	};
+	var _isFlatEnough = function(curve, degree) {
+	    var  error,
+	    	intercept_1, intercept_2, left_intercept, right_intercept,
+	    	a, b, c, det, dInv, a1, b1, c1, a2, b2, c2;
+	    a = curve[0].y - curve[degree].y;
+	    b = curve[degree].x - curve[0].x;
+	    c = curve[0].x * curve[degree].y - curve[degree].x * curve[0].y;
+	
+	    var max_distance_above = max_distance_below = 0.0;
+	    
+	    for (var i = 1; i < degree; i++) {
+	        var value = a * curve[i].x + b * curve[i].y + c;       
+	        if (value > max_distance_above)
+	            max_distance_above = value;
+	        else if (value < max_distance_below)
+	        	max_distance_below = value;
+	    }
+	    
+	    a1 = 0.0; b1 = 1.0; c1 = 0.0; a2 = a; b2 = b;
+	    c2 = c - max_distance_above;
+	    det = a1 * b2 - a2 * b1;
+	    dInv = 1.0/det;
+	    intercept_1 = (b1 * c2 - b2 * c1) * dInv;
+	    a2 = a; b2 = b; c2 = c - max_distance_below;
+	    det = a1 * b2 - a2 * b1;
+	    dInv = 1.0/det;
+	    intercept_2 = (b1 * c2 - b2 * c1) * dInv;
+	    left_intercept = Math.min(intercept_1, intercept_2);
+	    right_intercept = Math.max(intercept_1, intercept_2);
+	    error = right_intercept - left_intercept;
+	    return (error < flatnessTolerance)? 1 : 0;
+	};
+	var _computeXIntercept = function(curve, degree) {
+	    var XLK = 1.0, YLK = 0.0,
+	    	XNM = curve[degree].x - curve[0].x, YNM = curve[degree].y - curve[0].y,
+	    	XMK = curve[0].x - 0.0, YMK = curve[0].y - 0.0,
+	    	det = XNM*YLK - YNM*XLK, detInv = 1.0/det,
+	    	S = (XNM*YMK - YNM*XMK) * detInv; 
+	    return 0.0 + XLK * S;
+	};
+	var _bezier = function(curve, degree, t, left, right) {
+	    var temp = [[]];
+	    for (var j =0; j <= degree; j++) temp[0][j] = curve[j];
+	    for (var i = 1; i <= degree; i++) {	
+			for (var j =0 ; j <= degree - i; j++) {
+				if (!temp[i]) temp[i] = [];
+				if (!temp[i][j]) temp[i][j] = {};
+		    	temp[i][j].x = (1.0 - t) * temp[i-1][j].x + t * temp[i-1][j+1].x;
+		    	temp[i][j].y = (1.0 - t) * temp[i-1][j].y + t * temp[i-1][j+1].y;
+			}
+	    }    
+	    if (left != null) 
+	    	for (j = 0; j <= degree; j++) left[j]  = temp[j][0];
+	    if (right != null)
+			for (j = 0; j <= degree; j++) right[j] = temp[degree-j][j];
+	    
+	    return (temp[degree][0]);
+	};
+	
+	var _curveFunctionCache = {};
+	var _getCurveFunctions = function(order) {
+		var fns = _curveFunctionCache[order];
+		if (!fns) {
+			fns = [];			
+			var f_term = function() { return function(t) { return Math.pow(t, order); }; },
+				l_term = function() { return function(t) { return Math.pow((1-t), order); }; },
+				c_term = function(c) { return function(t) { return c; }; },
+				t_term = function() { return function(t) { return t; }; },
+				one_minus_t_term = function() { return function(t) { return 1-t; }; },
+				_termFunc = function(terms) {
+					return function(t) {
+						var p = 1;
+						for (var i = 0; i < terms.length; i++) p = p * terms[i](t);
+						return p;
+					};
+				};
+			
+			fns.push(new f_term());  // first is t to the power of the curve order		
+			for (var i = 1; i < order; i++) {
+				var terms = [new c_term(order)];
+				for (var j = 0 ; j < (order - i); j++) terms.push(new t_term());
+				for (var j = 0 ; j < i; j++) terms.push(new one_minus_t_term());
+				fns.push(new _termFunc(terms));
+			}
+			fns.push(new l_term());  // last is (1-t) to the power of the curve order
+		
+			_curveFunctionCache[order] = fns;
+		}
+			
+		return fns;
+	};
+	
+	
+	/**
+	 * calculates a point on the curve, for a Bezier of arbitrary order.
+	 * @param curve an array of control points, eg [{x:10,y:20}, {x:50,y:50}, {x:100,y:100}, {x:120,y:100}].  For a cubic bezier this should have four points.
+	 * @param location a decimal indicating the distance along the curve the point should be located at.  this is the distance along the curve as it travels, taking the way it bends into account.  should be a number from 0 to 1, inclusive.
+	 */
+	var _pointOnPath = function(curve, location) {		
+		var cc = _getCurveFunctions(curve.length - 1),
+			_x = 0, _y = 0;
+		for (var i = 0; i < curve.length ; i++) {
+			_x = _x + (curve[i].x * cc[i](location));
+			_y = _y + (curve[i].y * cc[i](location));
+		}
+		
+		return {x:_x, y:_y};
+	};
+	
+	var _dist = function(p1,p2) {
+		return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
+	};
+
+	var _isPoint = function(curve) {
+		return curve[0].x == curve[1].x && curve[0].y == curve[1].y;
+	};
+	
+	/**
+	 * finds the point that is 'distance' along the path from 'location'.  this method returns both the x,y location of the point and also
+	 * its 'location' (proportion of travel along the path); the method below - _pointAlongPathFrom - calls this method and just returns the
+	 * point.
+	 */
+	var _pointAlongPath = function(curve, location, distance) {
+
+		if (_isPoint(curve)) {
+			return {
+				point:curve[0],
+				location:location
+			};
+		}
+
+		var prev = _pointOnPath(curve, location), 
+			tally = 0, 
+			curLoc = location, 
+			direction = distance > 0 ? 1 : -1, 
+			cur = null;
+			
+		while (tally < Math.abs(distance)) {
+			curLoc += (0.005 * direction);
+			cur = _pointOnPath(curve, curLoc);
+			tally += _dist(cur, prev);	
+			prev = cur;
+		}
+		return {point:cur, location:curLoc};        	
+	};
+	
+	var _length = function(curve) {
+		if (_isPoint(curve)) return 0;
+
+		var prev = _pointOnPath(curve, 0),
+			tally = 0,
+			curLoc = 0,
+			direction = 1,
+			cur = null;
+			
+		while (curLoc < 1) {
+			curLoc += (0.005 * direction);
+			cur = _pointOnPath(curve, curLoc);
+			tally += _dist(cur, prev);	
+			prev = cur;
+		}
+		return tally;
+	};
+	
+	/**
+	 * finds the point that is 'distance' along the path from 'location'.  
+	 */
+	var _pointAlongPathFrom = function(curve, location, distance) {
+		return _pointAlongPath(curve, location, distance).point;
+	};
+
+	/**
+	 * finds the location that is 'distance' along the path from 'location'.  
+	 */
+	var _locationAlongPathFrom = function(curve, location, distance) {
+		return _pointAlongPath(curve, location, distance).location;
+	};
+	
+	/**
+	 * returns the gradient of the curve at the given location, which is a decimal between 0 and 1 inclusive.
+	 * 
+	 * thanks // http://bimixual.org/AnimationLibrary/beziertangents.html
+	 */
+	var _gradientAtPoint = function(curve, location) {
+		var p1 = _pointOnPath(curve, location),	
+			p2 = _pointOnPath(curve.slice(0, curve.length - 1), location),
+			dy = p2.y - p1.y, dx = p2.x - p1.x;
+		return dy == 0 ? Infinity : Math.atan(dy / dx);		
+	};
+	
+	/**
+	returns the gradient of the curve at the point which is 'distance' from the given location.
+	if this point is greater than location 1, the gradient at location 1 is returned.
+	if this point is less than location 0, the gradient at location 0 is returned.
+	*/
+	var _gradientAtPointAlongPathFrom = function(curve, location, distance) {
+		var p = _pointAlongPath(curve, location, distance);
+		if (p.location > 1) p.location = 1;
+		if (p.location < 0) p.location = 0;		
+		return _gradientAtPoint(curve, p.location);		
+	};
+
+	/**
+	 * calculates a line that is 'length' pixels long, perpendicular to, and centered on, the path at 'distance' pixels from the given location.
+	 * if distance is not supplied, the perpendicular for the given location is computed (ie. we set distance to zero).
+	 */
+	var _perpendicularToPathAt = function(curve, location, length, distance) {
+		distance = distance == null ? 0 : distance;
+		var p = _pointAlongPath(curve, location, distance),
+			m = _gradientAtPoint(curve, p.location),
+			_theta2 = Math.atan(-1 / m),
+			y =  length / 2 * Math.sin(_theta2),
+			x =  length / 2 * Math.cos(_theta2);
+		return [{x:p.point.x + x, y:p.point.y + y}, {x:p.point.x - x, y:p.point.y - y}];
+	};
+	
+	var jsBezier = window.jsBezier = {
+		distanceFromCurve : _distanceFromCurve,
+		gradientAtPoint : _gradientAtPoint,
+		gradientAtPointAlongCurveFrom : _gradientAtPointAlongPathFrom,
+		nearestPointOnCurve : _nearestPointOnCurve,
+		pointOnCurve : _pointOnPath,		
+		pointAlongCurveFrom : _pointAlongPathFrom,
+		perpendicularToCurveAt : _perpendicularToPathAt,
+		locationAlongCurveFrom:_locationAlongPathFrom,
+		getLength:_length
+	};
+})();

+ 489 - 0
course-design/libs/json2.js

@@ -0,0 +1,489 @@
+/*
+    json2.js
+    2014-02-04
+
+    Public Domain.
+
+    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+    See http://www.JSON.org/js.html
+
+
+    This code should be minified before deployment.
+    See http://javascript.crockford.com/jsmin.html
+
+    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+    NOT CONTROL.
+
+
+    This file creates a global JSON object containing two methods: stringify
+    and parse.
+
+        JSON.stringify(value, replacer, space)
+            value       any JavaScript value, usually an object or array.
+
+            replacer    an optional parameter that determines how object
+                        values are stringified for objects. It can be a
+                        function or an array of strings.
+
+            space       an optional parameter that specifies the indentation
+                        of nested structures. If it is omitted, the text will
+                        be packed without extra whitespace. If it is a number,
+                        it will specify the number of spaces to indent at each
+                        level. If it is a string (such as '\t' or '&nbsp;'),
+                        it contains the characters used to indent at each level.
+
+            This method produces a JSON text from a JavaScript value.
+
+            When an object value is found, if the object contains a toJSON
+            method, its toJSON method will be called and the result will be
+            stringified. A toJSON method does not serialize: it returns the
+            value represented by the name/value pair that should be serialized,
+            or undefined if nothing should be serialized. The toJSON method
+            will be passed the key associated with the value, and this will be
+            bound to the value
+
+            For example, this would serialize Dates as ISO strings.
+
+                Date.prototype.toJSON = function (key) {
+                    function f(n) {
+                        // Format integers to have at least two digits.
+                        return n < 10 ? '0' + n : n;
+                    }
+
+                    return this.getUTCFullYear()   + '-' +
+                         f(this.getUTCMonth() + 1) + '-' +
+                         f(this.getUTCDate())      + 'T' +
+                         f(this.getUTCHours())     + ':' +
+                         f(this.getUTCMinutes())   + ':' +
+                         f(this.getUTCSeconds())   + 'Z';
+                };
+
+            You can provide an optional replacer method. It will be passed the
+            key and value of each member, with this bound to the containing
+            object. The value that is returned from your method will be
+            serialized. If your method returns undefined, then the member will
+            be excluded from the serialization.
+
+            If the replacer parameter is an array of strings, then it will be
+            used to select the members to be serialized. It filters the results
+            such that only members with keys listed in the replacer array are
+            stringified.
+
+            Values that do not have JSON representations, such as undefined or
+            functions, will not be serialized. Such values in objects will be
+            dropped; in arrays they will be replaced with null. You can use
+            a replacer function to replace those with JSON values.
+            JSON.stringify(undefined) returns undefined.
+
+            The optional space parameter produces a stringification of the
+            value that is filled with line breaks and indentation to make it
+            easier to read.
+
+            If the space parameter is a non-empty string, then that string will
+            be used for indentation. If the space parameter is a number, then
+            the indentation will be that many spaces.
+
+            Example:
+
+            text = JSON.stringify(['e', {pluribus: 'unum'}]);
+            // text is '["e",{"pluribus":"unum"}]'
+
+
+            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+            text = JSON.stringify([new Date()], function (key, value) {
+                return this[key] instanceof Date ?
+                    'Date(' + this[key] + ')' : value;
+            });
+            // text is '["Date(---current time---)"]'
+
+
+        JSON.parse(text, reviver)
+            This method parses a JSON text to produce an object or array.
+            It can throw a SyntaxError exception.
+
+            The optional reviver parameter is a function that can filter and
+            transform the results. It receives each of the keys and values,
+            and its return value is used instead of the original value.
+            If it returns what it received, then the structure is not modified.
+            If it returns undefined then the member is deleted.
+
+            Example:
+
+            // Parse the text. Values that look like ISO date strings will
+            // be converted to Date objects.
+
+            myData = JSON.parse(text, function (key, value) {
+                var a;
+                if (typeof value === 'string') {
+                    a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+                    if (a) {
+                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+                            +a[5], +a[6]));
+                    }
+                }
+                return value;
+            });
+
+            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+                var d;
+                if (typeof value === 'string' &&
+                        value.slice(0, 5) === 'Date(' &&
+                        value.slice(-1) === ')') {
+                    d = new Date(value.slice(5, -1));
+                    if (d) {
+                        return d;
+                    }
+                }
+                return value;
+            });
+
+
+    This is a reference implementation. You are free to copy, modify, or
+    redistribute.
+*/
+
+/*jslint evil: true, regexp: true */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+    lastIndex, length, parse, prototype, push, replace, slice, stringify,
+    test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+if (typeof JSON !== 'object') {
+    JSON = {};
+}
+
+(function () {
+    'use strict';
+
+    function f(n) {
+        // Format integers to have at least two digits.
+        return n < 10 ? '0' + n : n;
+    }
+
+    if (typeof Date.prototype.toJSON !== 'function') {
+
+        Date.prototype.toJSON = function () {
+
+            return isFinite(this.valueOf())
+                ? this.getUTCFullYear()     + '-' +
+                    f(this.getUTCMonth() + 1) + '-' +
+                    f(this.getUTCDate())      + 'T' +
+                    f(this.getUTCHours())     + ':' +
+                    f(this.getUTCMinutes())   + ':' +
+                    f(this.getUTCSeconds())   + 'Z'
+                : null;
+        };
+
+        String.prototype.toJSON      =
+            Number.prototype.toJSON  =
+            Boolean.prototype.toJSON = function () {
+                return this.valueOf();
+            };
+    }
+
+    var cx,
+        escapable,
+        gap,
+        indent,
+        meta,
+        rep;
+
+
+    function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+        escapable.lastIndex = 0;
+        return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+            var c = meta[a];
+            return typeof c === 'string'
+                ? c
+                : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+        }) + '"' : '"' + string + '"';
+    }
+
+
+    function str(key, holder) {
+
+// Produce a string from holder[key].
+
+        var i,          // The loop counter.
+            k,          // The member key.
+            v,          // The member value.
+            length,
+            mind = gap,
+            partial,
+            value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+        if (value && typeof value === 'object' &&
+                typeof value.toJSON === 'function') {
+            value = value.toJSON(key);
+        }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+        if (typeof rep === 'function') {
+            value = rep.call(holder, key, value);
+        }
+
+// What happens next depends on the value's type.
+
+        switch (typeof value) {
+        case 'string':
+            return quote(value);
+
+        case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+            return isFinite(value) ? String(value) : 'null';
+
+        case 'boolean':
+        case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+            return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+        case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+            if (!value) {
+                return 'null';
+            }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+            gap += indent;
+            partial = [];
+
+// Is the value an array?
+
+            if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+                length = value.length;
+                for (i = 0; i < length; i += 1) {
+                    partial[i] = str(i, value) || 'null';
+                }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+                v = partial.length === 0
+                    ? '[]'
+                    : gap
+                    ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
+                    : '[' + partial.join(',') + ']';
+                gap = mind;
+                return v;
+            }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+            if (rep && typeof rep === 'object') {
+                length = rep.length;
+                for (i = 0; i < length; i += 1) {
+                    if (typeof rep[i] === 'string') {
+                        k = rep[i];
+                        v = str(k, value);
+                        if (v) {
+                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
+                        }
+                    }
+                }
+            } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+                for (k in value) {
+                    if (Object.prototype.hasOwnProperty.call(value, k)) {
+                        v = str(k, value);
+                        if (v) {
+                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
+                        }
+                    }
+                }
+            }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+            v = partial.length === 0
+                ? '{}'
+                : gap
+                ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
+                : '{' + partial.join(',') + '}';
+            gap = mind;
+            return v;
+        }
+    }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+    if (typeof JSON.stringify !== 'function') {
+        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
+        meta = {    // table of character substitutions
+            '\b': '\\b',
+            '\t': '\\t',
+            '\n': '\\n',
+            '\f': '\\f',
+            '\r': '\\r',
+            '"' : '\\"',
+            '\\': '\\\\'
+        };
+        JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+            var i;
+            gap = '';
+            indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+            if (typeof space === 'number') {
+                for (i = 0; i < space; i += 1) {
+                    indent += ' ';
+                }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+            } else if (typeof space === 'string') {
+                indent = space;
+            }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+            rep = replacer;
+            if (replacer && typeof replacer !== 'function' &&
+                    (typeof replacer !== 'object' ||
+                    typeof replacer.length !== 'number')) {
+                throw new Error('JSON.stringify');
+            }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+            return str('', {'': value});
+        };
+    }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+    if (typeof JSON.parse !== 'function') {
+        cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
+        JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+            var j;
+
+            function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+                var k, v, value = holder[key];
+                if (value && typeof value === 'object') {
+                    for (k in value) {
+                        if (Object.prototype.hasOwnProperty.call(value, k)) {
+                            v = walk(value, k);
+                            if (v !== undefined) {
+                                value[k] = v;
+                            } else {
+                                delete value[k];
+                            }
+                        }
+                    }
+                }
+                return reviver.call(holder, key, value);
+            }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+            text = String(text);
+            cx.lastIndex = 0;
+            if (cx.test(text)) {
+                text = text.replace(cx, function (a) {
+                    return '\\u' +
+                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+                });
+            }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+            if (/^[\],:{}\s]*$/
+                    .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
+                        .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+                        .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+                j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+                return typeof reviver === 'function'
+                    ? walk({'': j}, '')
+                    : j;
+            }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+            throw new SyntaxError('JSON.parse');
+        };
+    }
+}());

+ 659 - 0
course-design/libs/katavorio-0.4.js

@@ -0,0 +1,659 @@
+/**
+ drag/drop functionality for use with jsPlumb but with
+ no knowledge of jsPlumb. supports multiple scopes (separated by whitespace), dragging
+ multiple elements, constrain to parent, drop filters, drag start filters, custom
+ css classes.
+
+ a lot of the functionality of this script is expected to be plugged in:
+
+ addClass
+ removeClass
+
+ addEvent
+ removeEvent
+
+ getPosition
+ setPosition
+ getSize
+
+ indexOf
+ intersects
+
+ the name came from here:
+
+ http://mrsharpoblunto.github.io/foswig.js/
+
+ copyright 2014 jsPlumb
+ */
+
+;(function() {
+
+    "use strict";
+
+    var getOffsetRect = function (elem) {
+        // (1)
+        var box = elem.getBoundingClientRect();
+
+        var body = document.body;
+        var docElem = document.documentElement;
+
+        // (2)
+        var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop;
+        var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;
+
+        // (3)
+        var clientTop = docElem.clientTop || body.clientTop || 0;
+        var clientLeft = docElem.clientLeft || body.clientLeft || 0;
+
+        // (4)
+        var top  = box.top +  scrollTop - clientTop;
+        var left = box.left + scrollLeft - clientLeft;
+
+        return { top: Math.round(top), left: Math.round(left) };
+    };
+
+    var matchesSelector = function(el, selector, ctx) {
+        ctx = ctx || el.parentNode;
+        var possibles = ctx.querySelectorAll(selector);
+        for (var i = 0; i < possibles.length; i++) {
+            if (possibles[i] === el)
+                return true;
+        }
+        return false;
+    };
+
+    var iev = (function() {
+            var rv = -1;
+            if (navigator.appName == 'Microsoft Internet Explorer') {
+                var ua = navigator.userAgent,
+                    re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+                if (re.exec(ua) != null)
+                    rv = parseFloat(RegExp.$1);
+            }
+            return rv;
+        })(),
+        isIELT9 = iev > -1 && iev < 9,
+        _pl = function(e) {
+            if (isIELT9) {
+                return [ e.clientX + document.documentElement.scrollLeft, e.clientY + document.documentElement.scrollTop ];
+            }
+            else {
+                var ts = _touches(e), t = _getTouch(ts, 0);
+                // this is for iPad. may not fly for Android.
+                return [t.pageX, t.pageY];
+            }
+        },
+        _getTouch = function(touches, idx) { return touches.item ? touches.item(idx) : touches[idx]; },
+        _touches = function(e) {
+            return e.touches && e.touches.length > 0 ? e.touches :
+                    e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches :
+                    e.targetTouches && e.targetTouches.length > 0 ? e.targetTouches :
+                [ e ];
+        },
+        _classes = {
+            draggable:"katavorio-draggable",    // draggable elements
+            droppable:"katavorio-droppable",    // droppable elements
+            drag : "katavorio-drag",            // elements currently being dragged            
+            selected:"katavorio-drag-selected", // elements in current drag selection
+            active : "katavorio-drag-active",   // droppables that are targets of a currently dragged element
+            hover : "katavorio-drag-hover",     // droppables over which a matching drag element is hovering
+            noSelect : "katavorio-drag-no-select" // added to the body to provide a hook to suppress text selection
+        },
+        _defaultScope = "katavorio-drag-scope",
+        _events = [ "stop", "start", "drag", "drop", "over", "out" ],
+        _devNull = function() {},
+        _true = function() { return true; },
+        _foreach = function(l, fn, from) {
+            for (var i = 0; i < l.length; i++) {
+                if (l[i] != from)
+                    fn(l[i]);
+            }
+        },
+        _setDroppablesActive = function(dd, val, andHover, drag) {
+            _foreach(dd, function(e) {
+                e.setActive(val);
+                if (val) e.updatePosition();
+                if (andHover) e.setHover(drag, val);
+            });
+        },
+        _each = function(obj, fn) {
+            if (obj == null) return;
+            obj = (typeof obj !== "string") && (obj.tagName == null && obj.length != null) ? obj : [ obj ];
+            for (var i = 0; i < obj.length; i++)
+                fn.apply(obj[i], [ obj[i] ]);
+        },
+        _consume = function(e) {
+            if (e.stopPropagation) {
+                e.stopPropagation();
+                e.preventDefault();
+            }
+            else {
+                e.returnValue = false;
+            }
+        },
+        _defaultInputFilterSelector = "input,textarea,select,button",
+    //
+    // filters out events on all input elements, like textarea, checkbox, input, select.
+        _inputFilter = function(e, el, _katavorio) {
+            var t = e.srcElement || e.target;
+            return !matchesSelector(t, _katavorio.getInputFilterSelector(), el);
+        };
+
+    var Super = function(el, params, css, scope) {
+        this.params = params || {};
+        this.el = el;
+        this.params.addClass(this.el, this._class);
+        var enabled = true;
+        this.setEnabled = function(e) { enabled = e; };
+        this.isEnabled = function() { return enabled; };
+        this.toggleEnabled = function() { enabled = !enabled; };
+        this.setScope = function(scopes) {
+            this.scopes = scopes ? scopes.split(/\s+/) : [ scope ];
+        };
+        this.addScope = function(scopes) {
+            var m = {};
+            _each(this.scopes, function(s) { m[s] = true;});
+            _each(scopes ? scopes.split(/\s+/) : [], function(s) { m[s] = true;});
+            this.scopes = [];
+            for (var i in m) this.scopes.push(i);
+        };
+        this.removeScope = function(scopes) {
+            var m = {};
+            _each(this.scopes, function(s) { m[s] = true;});
+            _each(scopes ? scopes.split(/\s+/) : [], function(s) { delete m[s];});
+            this.scopes = [];
+            for (var i in m) this.scopes.push(i);
+        };
+        this.toggleScope = function(scopes) {
+            var m = {};
+            _each(this.scopes, function(s) { m[s] = true;});
+            _each(scopes ? scopes.split(/\s+/) : [], function(s) {
+                if (m[s]) delete m[s];
+                else m[s] = true;
+            });
+            this.scopes = [];
+            for (var i in m) this.scopes.push(i);
+        };
+        this.setScope(params.scope);
+        this.k = params.katavorio;
+        return params.katavorio;
+    };
+
+    var Drag = function(el, params, css, scope) {
+        this._class = css.draggable;
+        var k = Super.apply(this, arguments);
+        this.rightButtonCanDrag = this.params.rightButtonCanDrag;
+        var downAt = [0,0], posAtDown = null, moving = false,
+            consumeStartEvent = this.params.consumeStartEvent !== false,
+            dragEl = this.el,
+            clone = this.params.clone;
+        this.toGrid = function(pos) {
+            return this.params.grid == null ? pos :
+                [
+                        this.params.grid[0] * Math.floor(pos[0] / this.params.grid[0]),
+                        this.params.grid[1] * Math.floor(pos[1] / this.params.grid[1])
+                ];
+        };
+
+        this.constrain = typeof this.params.constrain === "function" ? this.params.constrain  : (this.params.constrain || this.params.containment) ? function(pos) {
+            return [
+                Math.max(0, Math.min(constrainRect.w - this.size[0], pos[0])),
+                Math.max(0, Math.min(constrainRect.h - this.size[1], pos[1]))
+            ];
+        } : function(pos) { return pos; };
+
+        var filter = _true,
+            filterSpec = "",
+            filterExclude = this.params.filterExclude !== false,
+            _setFilter = this.setFilter = function(f, _exclude) {
+                if (f) {
+                    filterSpec = f;
+                    filterExclude = _exclude !== false;
+                    filter = function(e) {
+                        var t = e.srcElement || e.target, ms = matchesSelector(t, f, el);
+                        return filterExclude ? !ms : ms;
+                    };
+                }
+            };
+        this.canDrag = this.params.canDrag || _true;
+
+        var constrainRect,
+            matchingDroppables = [], intersectingDroppables = [];
+
+        this.downListener = function(e) {
+            var isNotRightClick = this.rightButtonCanDrag || (e.which !== 3 && e.button !== 2);
+            if (isNotRightClick && this.isEnabled() && this.canDrag()) {
+                var _f =  filter(e) && _inputFilter(e, this.el, this.k);
+                if (_f) {
+                    if (!clone)
+                        dragEl = this.el;
+                    else {
+                        dragEl = this.el.cloneNode(true);
+                        dragEl.setAttribute("id", null);
+                        dragEl.style.position = "absolute";
+                        // the clone node is added to the body; getOffsetRect gives us a value
+                        // relative to the body.
+                        var b = getOffsetRect(this.el);
+                        dragEl.style.left = b.left + "px";
+                        dragEl.style.top = b.top + "px";
+                        document.body.appendChild(dragEl);
+                    }
+                    consumeStartEvent && _consume(e);
+                    downAt = _pl(e);
+                    //
+                    this.params.bind(document, "mousemove", this.moveListener);
+                    this.params.bind(document, "mouseup", this.upListener);
+                    k.markSelection(this);
+                    this.params.addClass(document.body, css.noSelect);
+                }
+                else if (this.params.consumeFilteredEvents) {
+                    _consume(e);
+                }
+            }
+        }.bind(this);
+
+        this.moveListener = function(e) {
+            if (downAt) {
+                if (!moving) {
+                    this.params.events["start"]({el:this.el, pos:posAtDown, e:e, drag:this});
+                    this.mark();
+                    moving = true;
+                }
+
+                intersectingDroppables.length = 0;
+                var pos = _pl(e), dx = pos[0] - downAt[0], dy = pos[1] - downAt[1],
+                    z = this.params.ignoreZoom ? 1 : k.getZoom();
+                dx /= z;
+                dy /= z;
+                this.moveBy(dx, dy, e);
+                k.updateSelection(dx, dy, this);
+            }
+        }.bind(this);
+
+        this.upListener = function(e) {
+            downAt = null;
+            moving = false;
+            this.params.unbind(document, "mousemove", this.moveListener);
+            this.params.unbind(document, "mouseup", this.upListener);
+            this.params.removeClass(document.body, css.noSelect);
+            this.unmark(e);
+            k.unmarkSelection(this, e);
+            this.stop(e);
+            k.notifySelectionDragStop(this, e);
+            if (clone) {
+                dragEl && dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
+                dragEl = null;
+            }
+        }.bind(this);
+
+        this.getFilter = function() { return filterSpec; };
+        this.isFilterExclude = function() { return filterExclude; };
+
+        this.abort = function() {
+            if (downAt != null)
+                this.upListener();
+        };
+
+        this.getDragElement = function() {
+            return dragEl || this.el;
+        };
+
+        this.stop = function(e) {
+            this.params.events["stop"]({el:dragEl, pos:this.params.getPosition(dragEl), e:e, drag:this});
+        };
+
+        this.mark = function() {
+            posAtDown = this.params.getPosition(dragEl);
+            this.size = this.params.getSize(dragEl);
+            matchingDroppables = k.getMatchingDroppables(this);
+            _setDroppablesActive(matchingDroppables, true, false, this);
+            this.params.addClass(dragEl, this.params.dragClass || css.drag);
+            if (this.params.constrain || this.params.containment) {
+                var cs = this.params.getSize(dragEl.parentNode);
+                constrainRect = { w:cs[0], h:cs[1] };
+            }
+        };
+        this.unmark = function(e) {
+            _setDroppablesActive(matchingDroppables, false, true, this);
+            matchingDroppables.length = 0;
+            for (var i = 0; i < intersectingDroppables.length; i++)
+                intersectingDroppables[i].drop(this, e);
+        };
+        this.moveBy = function(dx, dy, e) {
+            intersectingDroppables.length = 0;
+            var cPos = this.constrain(this.toGrid(([posAtDown[0] + dx, posAtDown[1] + dy])), dragEl),
+                rect = { x:cPos[0], y:cPos[1], w:this.size[0], h:this.size[1]};
+            this.params.setPosition(dragEl, cPos);
+            for (var i = 0; i < matchingDroppables.length; i++) {
+                var r2 = { x:matchingDroppables[i].position[0], y:matchingDroppables[i].position[1], w:matchingDroppables[i].size[0], h:matchingDroppables[i].size[1]};
+                if (this.params.intersects(rect, r2) && matchingDroppables[i].canDrop(this)) {
+                    intersectingDroppables.push(matchingDroppables[i]);
+                    matchingDroppables[i].setHover(this, true, e);
+                }
+                else if (matchingDroppables[i].el._katavorioDragHover) {
+                    matchingDroppables[i].setHover(this, false, e);
+                }
+            }
+            this.params.events["drag"]({el:this.el, pos:cPos, e:e, drag:this});
+        };
+        this.destroy = function() {
+            this.params.unbind(this.el, "mousedown", this.downListener);
+            this.params.unbind(document, "mousemove", this.moveListener);
+            this.params.unbind(document, "mouseup", this.upListener);
+            this.downListener = null;
+            this.upListener = null;
+            this.moveListener = null;
+            //this.params = null;
+            //this.el = null;
+            //dragEl = null;
+        };
+
+        // init:register mousedown, and perhaps set a filter
+        this.params.bind(this.el, "mousedown", this.downListener);
+
+        // if handle provded, use that.  otherwise, try to set a filter.
+        // note that a `handle` selector always results in filterExclude being set to false, ie.
+        // the selector defines the handle element(s).
+        if (this.params.handle)
+            _setFilter(this.params.handle, false);
+        else
+            _setFilter(this.params.filter, this.params.filterExclude);
+    };
+
+    var Drop = function(el, params, css, scope) {
+        this._class = css.droppable;
+        this.params = params || {};
+        this._activeClass = params.activeClass || css.active;
+        this._hoverClass = params.hoverClass || css.hover;
+        Super.apply(this, arguments)
+        var hover = false;
+
+        this.setActive = function(val) {
+            this.params[val ? "addClass" : "removeClass"](this.el, this._activeClass);
+        };
+
+        this.updatePosition = function() {
+            this.position = this.params.getPosition(this.el);
+            this.size = this.params.getSize(this.el);
+        };
+
+        this.canDrop = this.params.canDrop || function(drag) {
+            return true;
+        };
+
+        this.setHover = function(drag, val, e) {
+            // if turning off hover but this was not the drag that caused the hover, ignore.
+            if (val || this.el._katavorioDragHover == null || this.el._katavorioDragHover == drag.el._katavorio) {
+                this.params[val ? "addClass" : "removeClass"](this.el, this._hoverClass);
+                this.el._katavorioDragHover = val ? drag.el._katavorio : null;
+                if (hover !== val)
+                    this.params.events[val ? "over" : "out"]({el:this.el, e:e, drag:drag, drop:this});
+                hover = val;
+            }
+        };
+
+        this.drop = function(drag, event) {
+            this.params.events["drop"]({ drag:drag, e:event, drop:this });
+        };
+
+        this.destroy = function() {
+            this._class = null;
+            this._activeClass = null;
+            this._hoverClass = null;
+            //this.params = null;
+            hover = null;
+            //this.el = null;
+        };
+    };
+
+    var _uuid = function() {
+        return ('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+            var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
+            return v.toString(16);
+        }));
+    };
+
+    var _gel = function(el) {
+        if (el == null) return null;
+        el = typeof el === "string" ? document.getElementById(el) : el;
+        if (el == null) return null;
+        el._katavorio = el._katavorio || _uuid();
+        return el;
+    };
+
+    this.Katavorio = function(katavorioParams) {
+
+        var _selection = [],
+            _selectionMap = {};
+        this._dragsByScope = {};
+        this._dropsByScope = {};
+        var _zoom = 1,
+            _reg = function(obj, map) {
+                for(var i = 0; i < obj.scopes.length; i++) {
+                    map[obj.scopes[i]] = map[obj.scopes[i]] || [];
+                    map[obj.scopes[i]].push(obj);
+                }
+            },
+            _unreg = function(obj, map) {
+                var c = 0;
+                for(var i = 0; i < obj.scopes.length; i++) {
+                    if (map[obj.scopes[i]]) {
+                        var idx = katavorioParams.indexOf(map[obj.scopes[i]], obj);
+                        if (idx != -1) {
+                            map[obj.scopes[i]].splice(idx, 1);
+                            c++;
+                        }
+                    }
+                }
+                return c > 0 ;
+            },
+            _getMatchingDroppables = this.getMatchingDroppables = function(drag) {
+                var dd = [], _m = {};
+                for (var i = 0; i < drag.scopes.length; i++) {
+                    var _dd = this._dropsByScope[drag.scopes[i]];
+                    if (_dd) {
+                        for (var j = 0; j < _dd.length; j++) {
+                            if (_dd[j].canDrop(drag) &&  !_m[_dd[j].el._katavorio] && _dd[j].el !== drag.el) {
+                                _m[_dd[j].el._katavorio] = true;
+                                dd.push(_dd[j]);
+                            }
+                        }
+                    }
+                }
+                return dd;
+            },
+            _prepareParams = function(p) {
+                p = p || {};
+                var _p = {
+                    events:{}
+                };
+                for (var i in katavorioParams) _p[i] = katavorioParams[i];
+                for (var i in p) _p[i] = p[i];
+                // events
+
+                for (var i = 0; i < _events.length; i++) {
+                    _p.events[_events[i]] = p[_events[i]] || _devNull;
+                }
+                _p.katavorio = this;
+                return _p;
+            }.bind(this),
+            _css = {},
+            overrideCss = katavorioParams.css || {},
+            _scope = katavorioParams.scope || _defaultScope;
+
+        // prepare map of css classes based on defaults frst, then optional overrides
+        for (var i in _classes) _css[i] = _classes[i];
+        for (var i in overrideCss) _css[i] = overrideCss[i];
+
+        var inputFilterSelector = katavorioParams.inputFilterSelector || _defaultInputFilterSelector;
+        /**
+         * Gets the selector identifying which input elements to filter from drag events.
+         * @method getInputFilterSelector
+         * @return {String} Current input filter selector.
+         */
+        this.getInputFilterSelector = function() { return inputFilterSelector; };
+
+        /**
+         * Sets the selector identifying which input elements to filter from drag events.
+         * @method setInputFilterSelector
+         * @param {String} selector Input filter selector to set.
+         * @return {Katavorio} Current instance; method may be chained.
+         */
+        this.setInputFilterSelector = function(selector) {
+            inputFilterSelector = selector;
+            return this;
+        };
+
+        this.draggable = function(el, params) {
+            var o = [];
+            _each(el, function(_el) {
+                _el = _gel(_el);
+                if (_el != null) {
+                    var p = _prepareParams(params);
+                    _el._katavorioDrag = new Drag(_el, p, _css, _scope);
+                    _reg(_el._katavorioDrag, this._dragsByScope);
+                    o.push(_el._katavorioDrag);
+                    katavorioParams.addClass(_el, _css.draggable);
+                }
+            }.bind(this));
+            return o;
+
+        };
+
+        this.droppable = function(el, params) {
+            var o = [];
+            _each(el, function(_el) {
+                _el = _gel(_el);
+                if (_el != null) {
+                    _el._katavorioDrop = new Drop(_el, _prepareParams(params), _css, _scope);
+                    _reg(_el._katavorioDrop, this._dropsByScope);
+                    o.push(_el._katavorioDrop);
+                    katavorioParams.addClass(_el, _css.droppable);
+                }
+            }.bind(this));
+            return o;
+        };
+
+        /**
+         * @name Katavorio#select
+         * @function
+         * @desc Adds an element to the current selection (for multiple node drag)
+         * @param {Element|String} DOM element - or id of the element - to add.
+         */
+        this.select = function(el) {
+            _each(el, function() {
+                var _el = _gel(this);
+                if (_el && _el._katavorioDrag) {
+                    if (!_selectionMap[_el._katavorio]) {
+                        _selection.push(_el._katavorioDrag);
+                        _selectionMap[_el._katavorio] = [ _el, _selection.length - 1 ];
+                        katavorioParams.addClass(_el, _css.selected);
+                    }
+                }
+            });
+            return this;
+        };
+
+        /**
+         * @name Katavorio#deselect
+         * @function
+         * @desc Removes an element from the current selection (for multiple node drag)
+         * @param {Element|String} DOM element - or id of the element - to remove.
+         */
+        this.deselect = function(el) {
+            _each(el, function() {
+                var _el = _gel(this);
+                if (_el && _el._katavorio) {
+                    var e = _selectionMap[_el._katavorio];
+                    if (e) {
+                        var _s = [];
+                        for (var i = 0; i < _selection.length; i++)
+                            if (_selection[i].el !== _el) _s.push(_selection[i]);
+                        _selection = _s;
+                        delete _selectionMap[_el._katavorio];
+                        katavorioParams.removeClass(_el, _css.selected);
+                    }
+                }
+            });
+            return this;
+        };
+
+        this.deselectAll = function() {
+            for (var i in _selectionMap) {
+                var d = _selectionMap[i];
+                katavorioParams.removeClass(d[0], _css.selected);
+            }
+
+            _selection.length = 0;
+            _selectionMap = {};
+        };
+
+        this.markSelection = function(drag) {
+            _foreach(_selection, function(e) { e.mark(); }, drag);
+        };
+
+        this.unmarkSelection = function(drag, event) {
+            _foreach(_selection, function(e) { e.unmark(event); }, drag);
+        };
+
+        this.getSelection = function() { return _selection.slice(0); };
+
+        this.updateSelection = function(dx, dy, drag) {
+            _foreach(_selection, function(e) { e.moveBy(dx, dy); }, drag);
+        };
+
+        this.notifySelectionDragStop = function(drag, evt) {
+            _foreach(_selection, function(e) { e.stop(evt); }, drag);
+        };
+
+        this.setZoom = function(z) { _zoom = z; };
+        this.getZoom = function() { return _zoom; };
+
+        // does the work of changing scopes
+        var _scopeManip = function(kObj, scopes, map, fn) {
+            if (kObj != null) {
+                _unreg(kObj, map);  // deregister existing scopes
+                kObj[fn](scopes); // set scopes
+                _reg(kObj, map); // register new ones
+            }
+        };
+
+        _each([ "set", "add", "remove", "toggle"], function(v) {
+            this[v + "Scope"] = function(el, scopes) {
+                _scopeManip(el._katavorioDrag, scopes, this._dragsByScope, v + "Scope");
+                _scopeManip(el._katavorioDrop, scopes, this._dropsByScope, v + "Scope");
+            }.bind(this);
+            this[v + "DragScope"] = function(el, scopes) {
+                _scopeManip(el._katavorioDrag, scopes, this._dragsByScope, v + "Scope");
+            }.bind(this);
+            this[v + "DropScope"] = function(el, scopes) {
+                _scopeManip(el._katavorioDrop, scopes, this._dropsByScope, v + "Scope");
+            }.bind(this);
+        }.bind(this));
+
+        this.getDragsForScope = function(s) { return this._dragsByScope[s]; };
+        this.getDropsForScope = function(s) { return this._dropsByScope[s]; };
+
+        var _destroy = function(el, type, map) {
+            el = _gel(el);
+            if (el[type]) {
+                if (_unreg(el[type], map))
+                    el[type].destroy();
+                el[type] = null;
+            }
+        };
+
+        this.elementRemoved = function(el) {
+            this.destroyDraggable(el);
+            this.destroyDroppable(el);
+        };
+
+        this.destroyDraggable = function(el) {
+            _destroy(el, "_katavorioDrag", this._dragsByScope);
+        };
+
+        this.destroyDroppable = function(el) {
+            _destroy(el, "_katavorioDrop", this._dropsByScope);
+        };
+    };
+}).call(this);

+ 524 - 0
course-design/libs/mottle-0.4.js

@@ -0,0 +1,524 @@
+;(function() {
+
+	"use strict";
+
+	var Sniff = {
+		android:navigator.userAgent.toLowerCase().indexOf("android") > -1
+	};
+
+	var matchesSelector = function(el, selector, ctx) {
+			ctx = ctx || el.parentNode;
+			var possibles = ctx.querySelectorAll(selector);
+			for (var i = 0; i < possibles.length; i++) {
+				if (possibles[i] === el) {
+					return true;
+				}
+			}
+			return false;
+		},
+		_gel = function(el) { return typeof el == "string" ? document.getElementById(el) : el; },
+		_t = function(e) { return e.srcElement || e.target; },
+		_d = function(l, fn) {
+			for (var i = 0, j = l.length; i < j; i++) {
+				if (l[i] == fn) break;
+			}
+			if (i < l.length) l.splice(i, 1);
+		},
+		guid = 1,
+		//
+		// this function generates a guid for every handler, sets it on the handler, then adds
+		// it to the associated object's map of handlers for the given event. this is what enables us 
+		// to unbind all events of some type, or all events (the second of which can be requested by the user, 
+		// but it also used by Mottle when an element is removed.)
+		_store = function(obj, event, fn) {
+			var g = guid++;
+			obj.__ta = obj.__ta || {};
+			obj.__ta[event] = obj.__ta[event] || {};
+			// store each handler with a unique guid.
+			obj.__ta[event][g] = fn;
+			// set the guid on the handler.
+			fn.__tauid = g;
+			return g;
+		},
+		_unstore = function(obj, event, fn) {
+			obj.__ta && obj.__ta[event] && delete obj.__ta[event][fn.__tauid];
+			// a handler might have attached extra functions, so we unbind those too.
+			if (fn.__taExtra) {
+				for (var i = 0; i < fn.__taExtra.length; i++) {
+					_unbind(obj, fn.__taExtra[i][0], fn.__taExtra[i][1]);
+				}
+				fn.__taExtra.length = 0;
+			}
+			// a handler might have attached an unstore callback
+			fn.__taUnstore && fn.__taUnstore();
+		},
+		_curryChildFilter = function(children, obj, fn, evt) {
+			if (children == null) return fn;
+			else {
+				var c = children.split(","),
+					_fn = function(e) {
+						_fn.__tauid = fn.__tauid;
+						var t = _t(e);
+						for (var i = 0; i < c.length; i++) {
+							if (matchesSelector(t, c[i], obj)) {
+								fn.apply(t, arguments);
+							}
+						}
+					};
+				registerExtraFunction(fn, evt, _fn);
+				return _fn;
+			}
+		},
+		//
+		// registers an 'extra' function on some event listener function we were given - a function that we
+		// created and bound to the element as part of our housekeeping, and which we want to unbind and remove
+		// whenever the given function is unbound.
+		registerExtraFunction = function(fn, evt, newFn) {
+			fn.__taExtra = fn.__taExtra || [];
+			fn.__taExtra.push([evt, newFn]);
+		},
+		DefaultHandler = function(obj, evt, fn, children) {
+			// TODO: this was here originally because i wanted to handle devices that are both touch AND mouse. however this can cause certain of the helper
+			// functions to be bound twice, as - for example - on a nexus 4, both a mouse event and a touch event are fired.  the use case i had in mind
+			// was a device such as an Asus touch pad thing, which has a touch pad but can also be controlled with a mouse.
+			//if (isMouseDevice)
+			//	_bind(obj, evt, _curryChildFilter(children, obj, fn, evt), fn);
+			
+			if (isTouchDevice && touchMap[evt]) {
+				_bind(obj, touchMap[evt], _curryChildFilter(children, obj, fn, touchMap[evt]), fn);
+			}
+			else
+				_bind(obj, evt, _curryChildFilter(children, obj, fn, evt), fn);
+		},
+		SmartClickHandler = function(obj, evt, fn, children) {
+			if (obj.__taSmartClicks == null) {
+				var down = function(e) { obj.__tad = _pageLocation(e); },
+					up = function(e) { obj.__tau = _pageLocation(e); },
+					click = function(e) {
+						if (obj.__tad && obj.__tau && obj.__tad[0] === obj.__tau[0] && obj.__tad[1] === obj.__tau[1]) {
+							for (var i = 0; i < obj.__taSmartClicks.length; i++)
+								obj.__taSmartClicks[i].apply(_t(e), [ e ]);
+						}
+					};
+				DefaultHandler(obj, "mousedown", down, children);
+				DefaultHandler(obj, "mouseup", up, children);
+				DefaultHandler(obj, "click", click, children);
+				obj.__taSmartClicks = [];
+			}
+			
+			// store in the list of callbacks
+			obj.__taSmartClicks.push(fn);
+			// the unstore function removes this function from the object's listener list for this type.
+			fn.__taUnstore = function() {
+				_d(obj.__taSmartClicks, fn);
+			};
+		},
+		_tapProfiles = {
+			"tap":{touches:1, taps:1},
+			"dbltap":{touches:1, taps:2},
+			"contextmenu":{touches:2, taps:1}
+		},
+		TapHandler = function(clickThreshold, dblClickThreshold) {
+			return function(obj, evt, fn, children) {
+				// if event is contextmenu, for devices which are mouse only, we want to
+				// use the default bind. 
+				if (evt == "contextmenu" && isMouseDevice)
+					DefaultHandler(obj, evt, fn, children);
+				else {
+                    // the issue here is that this down handler gets registered only for the
+                    // child nodes in the first registration. in fact it should be registered with
+                    // no child selector and then on down we should cycle through the regustered
+                    // functions to see if one of them matches. on mouseup we should execute ALL of
+                    // the functions whose children are either null or match the element.
+					if (obj.__taTapHandler == null) {
+						var tt = obj.__taTapHandler = {
+							tap:[],
+							dbltap:[],
+							contextmenu:[],
+							down:false,
+							taps:0,
+                            downSelectors:[]
+						};
+						var down = function(e) {
+                                var target = e.srcElement || e.target;
+                                for (var i = 0; i < tt.downSelectors.length; i++) {
+                                    if (tt.downSelectors[i] == null || matchesSelector(target, tt.downSelectors[i], obj)) {
+                                        tt.down = true;
+                                        setTimeout(clearSingle, clickThreshold);
+                                        setTimeout(clearDouble, dblClickThreshold);
+                                        break; // we only need one match on mousedown
+                                    }
+                                }
+							},
+							up = function(e) {
+								if (tt.down) {
+                                    var target = e.srcElement || e.target;
+									tt.taps++;
+									var tc = _touchCount(e);
+									for (var eventId in _tapProfiles) {
+										var p = _tapProfiles[eventId];
+										if (p.touches === tc && (p.taps === 1 || p.taps === tt.taps)) {
+											for (var i = 0; i < tt[eventId].length; i++) {
+                                                if (tt[eventId][i][1] == null || matchesSelector(target, tt[eventId][i][1], obj))
+												    tt[eventId][i][0].apply(_t(e), [ e ]);
+											}
+										}
+									}
+								}
+							},
+							clearSingle = function() {
+								tt.down = false;
+							},
+							clearDouble = function() {
+								tt.taps = 0;
+							};
+						
+						DefaultHandler(obj, "mousedown", down/*, children*/);
+						DefaultHandler(obj, "mouseup", up/*, children*/);
+					}
+                    // add this child selector (it can be null, that's fine).
+                    obj.__taTapHandler.downSelectors.push(children);
+
+					obj.__taTapHandler[evt].push([fn, children]);
+					// the unstore function removes this function from the object's listener list for this type.
+					fn.__taUnstore = function() {
+						_d(obj.__taTapHandler[evt], fn);
+					};
+				}
+			};
+		},
+		meeHelper = function(type, evt, obj, target) {
+			for (var i in obj.__tamee[type]) {
+				obj.__tamee[type][i].apply(target, [ evt ]);
+			}
+		},
+		MouseEnterExitHandler = function() {
+			var activeElements = [];
+			return function(obj, evt, fn, children) {
+				if (!obj.__tamee) {
+					// __tamee holds a flag saying whether the mouse is currently "in" the element, and a list of
+					// both mouseenter and mouseexit functions.
+					obj.__tamee = { over:false, mouseenter:[], mouseexit:[] };
+					// register over and out functions
+					var over = function(e) {
+							var t = _t(e);
+							if ( (children== null && (t == obj && !obj.__tamee.over)) || (matchesSelector(t, children, obj) && (t.__tamee == null || !t.__tamee.over)) ) {
+								meeHelper("mouseenter", e, obj, t);
+								t.__tamee = t.__tamee || {};
+								t.__tamee.over = true;
+								activeElements.push(t);
+							}
+						},
+						out = function(e) {
+							var t = _t(e);
+							// is the current target one of the activeElements? and is the 
+							// related target NOT a descendant of it?
+							for (var i = 0; i < activeElements.length; i++) {
+								if (t == activeElements[i] && !matchesSelector((e.relatedTarget || e.toElement), "*", t)) {
+									t.__tamee.over = false;
+									activeElements.splice(i, 1);
+									meeHelper("mouseexit", e, obj, t);
+								}
+							}
+						};
+						
+					_bind(obj, "mouseover", _curryChildFilter(children, obj, over, "mouseover"), over);
+					_bind(obj, "mouseout", _curryChildFilter(children, obj, out, "mouseout"), out);
+				}
+
+				fn.__taUnstore = function() {
+					delete obj.__tamee[evt][fn.__tauid];
+				};
+
+				_store(obj, evt, fn);
+				obj.__tamee[evt][fn.__tauid] = fn;
+			};
+		},
+		isTouchDevice = "ontouchstart" in document.documentElement,
+		isMouseDevice = "onmousedown" in document.documentElement,
+		touchMap = { "mousedown":"touchstart", "mouseup":"touchend", "mousemove":"touchmove" },
+		touchstart="touchstart",touchend="touchend",touchmove="touchmove",
+		ta_down = "__MottleDown", ta_up = "__MottleUp", 
+		ta_context_down = "__MottleContextDown", ta_context_up = "__MottleContextUp",
+		iev = (function() {
+			var rv = -1; 
+			if (navigator.appName == 'Microsoft Internet Explorer') {
+				var ua = navigator.userAgent,
+					re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+				if (re.exec(ua) != null)
+					rv = parseFloat(RegExp.$1);
+			}
+			return rv;
+		})(),
+		isIELT9 = iev > -1 && iev < 9, 
+		_genLoc = function(e, prefix) {
+			if (e == null) return [ 0, 0 ];
+			var ts = _touches(e), t = _getTouch(ts, 0);
+			return [t[prefix + "X"], t[prefix + "Y"]];
+		},
+		_pageLocation = function(e) {
+			if (e == null) return [ 0, 0 ];
+			if (isIELT9) {
+				return [ e.clientX + document.documentElement.scrollLeft, e.clientY + document.documentElement.scrollTop ];
+			}
+			else {
+				return _genLoc(e, "page");
+			}
+		},
+		_screenLocation = function(e) {
+			return _genLoc(e, "screen");
+		},
+		_clientLocation = function(e) {
+			return _genLoc(e, "client");
+		},
+		_getTouch = function(touches, idx) { return touches.item ? touches.item(idx) : touches[idx]; },
+		_touches = function(e) {
+			return e.touches && e.touches.length > 0 ? e.touches : 
+				   e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches :
+				   e.targetTouches && e.targetTouches.length > 0 ? e.targetTouches :
+				   [ e ];
+		},
+		_touchCount = function(e) { return _touches(e).length; },
+		//http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
+		_bind = function( obj, type, fn, originalFn) {
+			_store(obj, type, fn);
+			originalFn.__tauid = fn.__tauid;
+			if (obj.addEventListener)
+				obj.addEventListener( type, fn, false );
+			else if (obj.attachEvent) {
+				var key = type + fn.__tauid;
+				obj["e" + key] = fn;
+				// TODO look at replacing with .call(..)
+				obj[key] = function() { 
+					obj["e"+key] && obj["e"+key]( window.event ); 
+				};
+				obj.attachEvent( "on"+type, obj[key] );
+			}
+		},
+		_unbind = function( obj, type, fn) {
+			if (fn == null) return;
+			_each(obj, function() {
+				var _el = _gel(this);
+				_unstore(_el, type, fn);
+				// it has been bound if there is a tauid. otherwise it was not bound and we can ignore it.
+				if (fn.__tauid != null) {
+					if (_el.removeEventListener)
+						_el.removeEventListener( type, fn, false );
+					else if (this.detachEvent) {
+						var key = type + fn.__tauid;
+						_el[key] && _el.detachEvent( "on"+type, _el[key] );
+						_el[key] = null;
+						_el["e"+key] = null;
+					}
+				}
+			});
+		},
+		_devNull = function() {},
+		_each = function(obj, fn) {
+			if (obj == null) return;
+			// if a list (or list-like), use it. if a string, get a list 
+			// by running the string through querySelectorAll. else, assume 
+			// it's an Element.
+			obj = (typeof obj !== "string") && (obj.tagName == null && obj.length != null) ? obj : typeof obj === "string" ? document.querySelectorAll(obj) : [ obj ];
+			for (var i = 0; i < obj.length; i++)
+				fn.apply(obj[i]);
+		};
+
+	/**
+	* Event handler.  Offers support for abstracting out the differences
+	* between touch and mouse devices, plus "smart click" functionality
+	* (don't fire click if the mouse has moved betweeb mousedown and mouseup),
+	* and synthesized click/tap events.
+	* @class Mottle
+	* @constructor
+	* @param {Object} params Constructor params
+	* @param {Integer} [params.clickThreshold=150] Threshold, in milliseconds beyond which a touchstart followed by a touchend is not considered to be a click.
+	* @param {Integer} [params.dblClickThreshold=350] Threshold, in milliseconds beyond which two successive tap events are not considered to be a click.
+	* @param {Boolean} [params.smartClicks=false] If true, won't fire click events if the mouse has moved between mousedown and mouseup. Note that this functionality
+	* requires that Mottle consume the mousedown event, and so may not be viable in all use cases.
+	*/
+	this.Mottle = function(params) {
+		params = params || {};
+		var self = this, 
+			clickThreshold = params.clickThreshold || 150,
+			dblClickThreshold = params.dblClickThreshold || 350,
+			mouseEnterExitHandler = new MouseEnterExitHandler(),
+			tapHandler = new TapHandler(clickThreshold, dblClickThreshold),
+			_smartClicks = params.smartClicks,
+			_doBind = function(obj, evt, fn, children) {
+				if (fn == null) return;
+				_each(obj, function() {
+					var _el = _gel(this);
+					if (_smartClicks && evt === "click")
+						SmartClickHandler(_el, evt, fn, children);
+					else if (evt === "tap" || evt === "dbltap" || evt === "contextmenu") {
+						tapHandler(_el, evt, fn, children);
+					}
+					else if (evt === "mouseenter" || evt == "mouseexit")
+						mouseEnterExitHandler(_el, evt, fn, children);
+					else 
+						DefaultHandler(_el, evt, fn, children);
+				});
+			};
+
+		/**
+		* Removes an element from the DOM, and unregisters all event handlers for it. You should use this
+		* to ensure you don't leak memory.
+		* @method remove
+		* @param {String|Element} el Element, or id of the element, to remove.
+		* @return {Mottle} The current Mottle instance; you can chain this method.
+		*/
+		this.remove = function(el) {
+			_each(el, function() {
+				var _el = _gel(this);
+				if (_el.__ta) {
+					for (var evt in _el.__ta) {
+						for (var h in _el.__ta[evt]) {
+							_unbind(_el, evt, _el.__ta[evt][h]);
+						}
+					}
+				}
+				_el.parentNode && _el.parentNode.removeChild(_el);
+			});
+			return this;
+		};
+
+		/**
+		* Register an event handler, optionally as a delegate for some set of descendant elements. Note
+		* that this method takes either 3 or 4 arguments - if you supply 3 arguments it is assumed you have 
+		* omitted the `children` parameter, and that the event handler should be bound directly to the given element.
+		* @method on
+		* @param {Element[]|Element|String} el Either an Element, or a CSS spec for a list of elements, or an array of Elements.
+		* @param {String} [children] Comma-delimited list of selectors identifying allowed children.
+		* @param {String} event Event ID.
+		* @param {Function} fn Event handler function.
+		* @return {Mottle} The current Mottle instance; you can chain this method.
+		*/
+		this.on = function(el, event, children, fn) {
+			var _el = arguments[0],
+				_c = arguments.length == 4 ? arguments[2] : null,
+				_e = arguments[1],
+				_f = arguments[arguments.length - 1];
+
+			_doBind(_el, _e, _f, _c);
+			return this;
+		};	
+
+		/**
+		* Cancel delegate event handling for the given function. Note that unlike with 'on' you do not supply
+		* a list of child selectors here: it removes event delegation from all of the child selectors for which the
+		* given function was registered (if any).
+		* @method off
+		* @param {Element[]|Element|String} el Element - or ID of element - from which to remove event listener.
+		* @param {String} event Event ID.
+		* @param {Function} fn Event handler function.
+		* @return {Mottle} The current Mottle instance; you can chain this method.
+		*/
+		this.off = function(el, evt, fn) {
+			_unbind(el, evt, fn);
+			return this;
+		};
+
+		/**
+		* Triggers some event for a given element.
+		* @method trigger
+		* @param {Element} el Element for which to trigger the event.
+		* @param {String} event Event ID.
+		* @param {Event} originalEvent The original event. Should be optional of course, but currently is not, due
+		* to the jsPlumb use case that caused this method to be added.
+		* @param {Object} [payload] Optional object to set as `payload` on the generated event; useful for message passing.
+		* @return {Mottle} The current Mottle instance; you can chain this method.
+		*/
+		this.trigger = function(el, event, originalEvent, payload) {
+			var eventToBind = (isTouchDevice && touchMap[event]) ? touchMap[event] : event;
+			var pl = _pageLocation(originalEvent), sl = _screenLocation(originalEvent), cl = _clientLocation(originalEvent);
+			_each(el, function() {
+				var _el = _gel(this), evt;
+				originalEvent = originalEvent || {
+					screenX:sl[0],
+					screenY:sl[1],
+					clientX:cl[0],
+					clientY:cl[1]
+				};
+
+				var _decorate = function(_evt) {
+					if (payload) _evt.payload = payload;
+				};
+
+				var eventGenerators = {
+					"TouchEvent":function(evt) {
+						var t = document.createTouch(window, _el, 0, pl[0], pl[1], 
+									sl[0], sl[1],
+									cl[0], cl[1],
+									0,0,0,0);
+
+						evt.initTouchEvent(eventToBind, true, true, window, 0, 
+							sl[0], sl[1],
+							cl[0], cl[1],
+							false, false, false, false, document.createTouchList(t));
+					},
+					"MouseEvents":function(evt) {
+						evt.initMouseEvent(eventToBind, true, true, window, 0,
+							sl[0], sl[1],
+							cl[0], cl[1],
+							false, false, false, false, 1, _el);
+						
+						if (Sniff.android) {
+							// Android's touch events are not standard.
+							var t = document.createTouch(window, _el, 0, pl[0], pl[1], 
+										sl[0], sl[1],
+										cl[0], cl[1],
+										0,0,0,0);
+
+							evt.touches = evt.targetTouches = evt.changedTouches = document.createTouchList(t);
+						}
+					}
+				};
+
+				if (document.createEvent) {
+					var ite = (isTouchDevice && touchMap[event] && !Sniff.android), evtName = ite ? "TouchEvent" : "MouseEvents";
+					evt = document.createEvent(evtName);
+					eventGenerators[evtName](evt);
+					_decorate(evt);
+					_el.dispatchEvent(evt);
+				}
+				else if (document.createEventObject) {
+					evt = document.createEventObject();
+					evt.eventType = evt.eventName = eventToBind;
+					evt.screenX = sl[0];
+					evt.screenY = sl[1];
+					evt.clientX = cl[0];
+					evt.clientY = cl[1];
+					_decorate(evt);
+					_el.fireEvent('on' + eventToBind, evt);
+				}
+			});
+			return this;
+		}
+	};
+
+	/**
+	* Static method to assist in 'consuming' an element: uses `stopPropagation` where available, or sets `e.returnValue=false` where it is not.
+	* @method Mottle.consume
+	* @param {Event} e Event to consume
+	* @param {Boolean} [doNotPreventDefault=false] If true, does not call `preventDefault()` on the event.
+	*/
+	Mottle.consume = function(e, doNotPreventDefault) {
+		if (e.stopPropagation)
+			e.stopPropagation();
+		else 
+			e.returnValue = false;
+
+		if (!doNotPreventDefault && e.preventDefault)
+			 e.preventDefault();
+	};
+
+	/**
+	* Gets the page location corresponding to the given event. For touch events this means get the page location of the first touch.
+	* @method Mottle.pageLocation
+	* @param {Event} e Event to get page location for.
+	* @return {Integer[]} [left, top] for the given event.
+	*/
+	Mottle.pageLocation = _pageLocation;
+
+}).call(this);

File diff suppressed because it is too large
+ 4 - 0
course-design/libs/underscore-min.js


+ 1415 - 0
course-design/libs/underscore.js

@@ -0,0 +1,1415 @@
+//     Underscore.js 1.7.0
+//     http://underscorejs.org
+//     (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+//     Underscore may be freely distributed under the MIT license.
+
+(function() {
+
+  // Baseline setup
+  // --------------
+
+  // Establish the root object, `window` in the browser, or `exports` on the server.
+  var root = this;
+
+  // Save the previous value of the `_` variable.
+  var previousUnderscore = root._;
+
+  // Save bytes in the minified (but not gzipped) version:
+  var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
+
+  // Create quick reference variables for speed access to core prototypes.
+  var
+    push             = ArrayProto.push,
+    slice            = ArrayProto.slice,
+    concat           = ArrayProto.concat,
+    toString         = ObjProto.toString,
+    hasOwnProperty   = ObjProto.hasOwnProperty;
+
+  // All **ECMAScript 5** native function implementations that we hope to use
+  // are declared here.
+  var
+    nativeIsArray      = Array.isArray,
+    nativeKeys         = Object.keys,
+    nativeBind         = FuncProto.bind;
+
+  // Create a safe reference to the Underscore object for use below.
+  var _ = function(obj) {
+    if (obj instanceof _) return obj;
+    if (!(this instanceof _)) return new _(obj);
+    this._wrapped = obj;
+  };
+
+  // Export the Underscore object for **Node.js**, with
+  // backwards-compatibility for the old `require()` API. If we're in
+  // the browser, add `_` as a global object.
+  if (typeof exports !== 'undefined') {
+    if (typeof module !== 'undefined' && module.exports) {
+      exports = module.exports = _;
+    }
+    exports._ = _;
+  } else {
+    root._ = _;
+  }
+
+  // Current version.
+  _.VERSION = '1.7.0';
+
+  // Internal function that returns an efficient (for current engines) version
+  // of the passed-in callback, to be repeatedly applied in other Underscore
+  // functions.
+  var createCallback = function(func, context, argCount) {
+    if (context === void 0) return func;
+    switch (argCount == null ? 3 : argCount) {
+      case 1: return function(value) {
+        return func.call(context, value);
+      };
+      case 2: return function(value, other) {
+        return func.call(context, value, other);
+      };
+      case 3: return function(value, index, collection) {
+        return func.call(context, value, index, collection);
+      };
+      case 4: return function(accumulator, value, index, collection) {
+        return func.call(context, accumulator, value, index, collection);
+      };
+    }
+    return function() {
+      return func.apply(context, arguments);
+    };
+  };
+
+  // A mostly-internal function to generate callbacks that can be applied
+  // to each element in a collection, returning the desired result — either
+  // identity, an arbitrary callback, a property matcher, or a property accessor.
+  _.iteratee = function(value, context, argCount) {
+    if (value == null) return _.identity;
+    if (_.isFunction(value)) return createCallback(value, context, argCount);
+    if (_.isObject(value)) return _.matches(value);
+    return _.property(value);
+  };
+
+  // Collection Functions
+  // --------------------
+
+  // The cornerstone, an `each` implementation, aka `forEach`.
+  // Handles raw objects in addition to array-likes. Treats all
+  // sparse array-likes as if they were dense.
+  _.each = _.forEach = function(obj, iteratee, context) {
+    if (obj == null) return obj;
+    iteratee = createCallback(iteratee, context);
+    var i, length = obj.length;
+    if (length === +length) {
+      for (i = 0; i < length; i++) {
+        iteratee(obj[i], i, obj);
+      }
+    } else {
+      var keys = _.keys(obj);
+      for (i = 0, length = keys.length; i < length; i++) {
+        iteratee(obj[keys[i]], keys[i], obj);
+      }
+    }
+    return obj;
+  };
+
+  // Return the results of applying the iteratee to each element.
+  _.map = _.collect = function(obj, iteratee, context) {
+    if (obj == null) return [];
+    iteratee = _.iteratee(iteratee, context);
+    var keys = obj.length !== +obj.length && _.keys(obj),
+        length = (keys || obj).length,
+        results = Array(length),
+        currentKey;
+    for (var index = 0; index < length; index++) {
+      currentKey = keys ? keys[index] : index;
+      results[index] = iteratee(obj[currentKey], currentKey, obj);
+    }
+    return results;
+  };
+
+  var reduceError = 'Reduce of empty array with no initial value';
+
+  // **Reduce** builds up a single result from a list of values, aka `inject`,
+  // or `foldl`.
+  _.reduce = _.foldl = _.inject = function(obj, iteratee, memo, context) {
+    if (obj == null) obj = [];
+    iteratee = createCallback(iteratee, context, 4);
+    var keys = obj.length !== +obj.length && _.keys(obj),
+        length = (keys || obj).length,
+        index = 0, currentKey;
+    if (arguments.length < 3) {
+      if (!length) throw new TypeError(reduceError);
+      memo = obj[keys ? keys[index++] : index++];
+    }
+    for (; index < length; index++) {
+      currentKey = keys ? keys[index] : index;
+      memo = iteratee(memo, obj[currentKey], currentKey, obj);
+    }
+    return memo;
+  };
+
+  // The right-associative version of reduce, also known as `foldr`.
+  _.reduceRight = _.foldr = function(obj, iteratee, memo, context) {
+    if (obj == null) obj = [];
+    iteratee = createCallback(iteratee, context, 4);
+    var keys = obj.length !== + obj.length && _.keys(obj),
+        index = (keys || obj).length,
+        currentKey;
+    if (arguments.length < 3) {
+      if (!index) throw new TypeError(reduceError);
+      memo = obj[keys ? keys[--index] : --index];
+    }
+    while (index--) {
+      currentKey = keys ? keys[index] : index;
+      memo = iteratee(memo, obj[currentKey], currentKey, obj);
+    }
+    return memo;
+  };
+
+  // Return the first value which passes a truth test. Aliased as `detect`.
+  _.find = _.detect = function(obj, predicate, context) {
+    var result;
+    predicate = _.iteratee(predicate, context);
+    _.some(obj, function(value, index, list) {
+      if (predicate(value, index, list)) {
+        result = value;
+        return true;
+      }
+    });
+    return result;
+  };
+
+  // Return all the elements that pass a truth test.
+  // Aliased as `select`.
+  _.filter = _.select = function(obj, predicate, context) {
+    var results = [];
+    if (obj == null) return results;
+    predicate = _.iteratee(predicate, context);
+    _.each(obj, function(value, index, list) {
+      if (predicate(value, index, list)) results.push(value);
+    });
+    return results;
+  };
+
+  // Return all the elements for which a truth test fails.
+  _.reject = function(obj, predicate, context) {
+    return _.filter(obj, _.negate(_.iteratee(predicate)), context);
+  };
+
+  // Determine whether all of the elements match a truth test.
+  // Aliased as `all`.
+  _.every = _.all = function(obj, predicate, context) {
+    if (obj == null) return true;
+    predicate = _.iteratee(predicate, context);
+    var keys = obj.length !== +obj.length && _.keys(obj),
+        length = (keys || obj).length,
+        index, currentKey;
+    for (index = 0; index < length; index++) {
+      currentKey = keys ? keys[index] : index;
+      if (!predicate(obj[currentKey], currentKey, obj)) return false;
+    }
+    return true;
+  };
+
+  // Determine if at least one element in the object matches a truth test.
+  // Aliased as `any`.
+  _.some = _.any = function(obj, predicate, context) {
+    if (obj == null) return false;
+    predicate = _.iteratee(predicate, context);
+    var keys = obj.length !== +obj.length && _.keys(obj),
+        length = (keys || obj).length,
+        index, currentKey;
+    for (index = 0; index < length; index++) {
+      currentKey = keys ? keys[index] : index;
+      if (predicate(obj[currentKey], currentKey, obj)) return true;
+    }
+    return false;
+  };
+
+  // Determine if the array or object contains a given value (using `===`).
+  // Aliased as `include`.
+  _.contains = _.include = function(obj, target) {
+    if (obj == null) return false;
+    if (obj.length !== +obj.length) obj = _.values(obj);
+    return _.indexOf(obj, target) >= 0;
+  };
+
+  // Invoke a method (with arguments) on every item in a collection.
+  _.invoke = function(obj, method) {
+    var args = slice.call(arguments, 2);
+    var isFunc = _.isFunction(method);
+    return _.map(obj, function(value) {
+      return (isFunc ? method : value[method]).apply(value, args);
+    });
+  };
+
+  // Convenience version of a common use case of `map`: fetching a property.
+  _.pluck = function(obj, key) {
+    return _.map(obj, _.property(key));
+  };
+
+  // Convenience version of a common use case of `filter`: selecting only objects
+  // containing specific `key:value` pairs.
+  _.where = function(obj, attrs) {
+    return _.filter(obj, _.matches(attrs));
+  };
+
+  // Convenience version of a common use case of `find`: getting the first object
+  // containing specific `key:value` pairs.
+  _.findWhere = function(obj, attrs) {
+    return _.find(obj, _.matches(attrs));
+  };
+
+  // Return the maximum element (or element-based computation).
+  _.max = function(obj, iteratee, context) {
+    var result = -Infinity, lastComputed = -Infinity,
+        value, computed;
+    if (iteratee == null && obj != null) {
+      obj = obj.length === +obj.length ? obj : _.values(obj);
+      for (var i = 0, length = obj.length; i < length; i++) {
+        value = obj[i];
+        if (value > result) {
+          result = value;
+        }
+      }
+    } else {
+      iteratee = _.iteratee(iteratee, context);
+      _.each(obj, function(value, index, list) {
+        computed = iteratee(value, index, list);
+        if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
+          result = value;
+          lastComputed = computed;
+        }
+      });
+    }
+    return result;
+  };
+
+  // Return the minimum element (or element-based computation).
+  _.min = function(obj, iteratee, context) {
+    var result = Infinity, lastComputed = Infinity,
+        value, computed;
+    if (iteratee == null && obj != null) {
+      obj = obj.length === +obj.length ? obj : _.values(obj);
+      for (var i = 0, length = obj.length; i < length; i++) {
+        value = obj[i];
+        if (value < result) {
+          result = value;
+        }
+      }
+    } else {
+      iteratee = _.iteratee(iteratee, context);
+      _.each(obj, function(value, index, list) {
+        computed = iteratee(value, index, list);
+        if (computed < lastComputed || computed === Infinity && result === Infinity) {
+          result = value;
+          lastComputed = computed;
+        }
+      });
+    }
+    return result;
+  };
+
+  // Shuffle a collection, using the modern version of the
+  // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
+  _.shuffle = function(obj) {
+    var set = obj && obj.length === +obj.length ? obj : _.values(obj);
+    var length = set.length;
+    var shuffled = Array(length);
+    for (var index = 0, rand; index < length; index++) {
+      rand = _.random(0, index);
+      if (rand !== index) shuffled[index] = shuffled[rand];
+      shuffled[rand] = set[index];
+    }
+    return shuffled;
+  };
+
+  // Sample **n** random values from a collection.
+  // If **n** is not specified, returns a single random element.
+  // The internal `guard` argument allows it to work with `map`.
+  _.sample = function(obj, n, guard) {
+    if (n == null || guard) {
+      if (obj.length !== +obj.length) obj = _.values(obj);
+      return obj[_.random(obj.length - 1)];
+    }
+    return _.shuffle(obj).slice(0, Math.max(0, n));
+  };
+
+  // Sort the object's values by a criterion produced by an iteratee.
+  _.sortBy = function(obj, iteratee, context) {
+    iteratee = _.iteratee(iteratee, context);
+    return _.pluck(_.map(obj, function(value, index, list) {
+      return {
+        value: value,
+        index: index,
+        criteria: iteratee(value, index, list)
+      };
+    }).sort(function(left, right) {
+      var a = left.criteria;
+      var b = right.criteria;
+      if (a !== b) {
+        if (a > b || a === void 0) return 1;
+        if (a < b || b === void 0) return -1;
+      }
+      return left.index - right.index;
+    }), 'value');
+  };
+
+  // An internal function used for aggregate "group by" operations.
+  var group = function(behavior) {
+    return function(obj, iteratee, context) {
+      var result = {};
+      iteratee = _.iteratee(iteratee, context);
+      _.each(obj, function(value, index) {
+        var key = iteratee(value, index, obj);
+        behavior(result, value, key);
+      });
+      return result;
+    };
+  };
+
+  // Groups the object's values by a criterion. Pass either a string attribute
+  // to group by, or a function that returns the criterion.
+  _.groupBy = group(function(result, value, key) {
+    if (_.has(result, key)) result[key].push(value); else result[key] = [value];
+  });
+
+  // Indexes the object's values by a criterion, similar to `groupBy`, but for
+  // when you know that your index values will be unique.
+  _.indexBy = group(function(result, value, key) {
+    result[key] = value;
+  });
+
+  // Counts instances of an object that group by a certain criterion. Pass
+  // either a string attribute to count by, or a function that returns the
+  // criterion.
+  _.countBy = group(function(result, value, key) {
+    if (_.has(result, key)) result[key]++; else result[key] = 1;
+  });
+
+  // Use a comparator function to figure out the smallest index at which
+  // an object should be inserted so as to maintain order. Uses binary search.
+  _.sortedIndex = function(array, obj, iteratee, context) {
+    iteratee = _.iteratee(iteratee, context, 1);
+    var value = iteratee(obj);
+    var low = 0, high = array.length;
+    while (low < high) {
+      var mid = low + high >>> 1;
+      if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
+    }
+    return low;
+  };
+
+  // Safely create a real, live array from anything iterable.
+  _.toArray = function(obj) {
+    if (!obj) return [];
+    if (_.isArray(obj)) return slice.call(obj);
+    if (obj.length === +obj.length) return _.map(obj, _.identity);
+    return _.values(obj);
+  };
+
+  // Return the number of elements in an object.
+  _.size = function(obj) {
+    if (obj == null) return 0;
+    return obj.length === +obj.length ? obj.length : _.keys(obj).length;
+  };
+
+  // Split a collection into two arrays: one whose elements all satisfy the given
+  // predicate, and one whose elements all do not satisfy the predicate.
+  _.partition = function(obj, predicate, context) {
+    predicate = _.iteratee(predicate, context);
+    var pass = [], fail = [];
+    _.each(obj, function(value, key, obj) {
+      (predicate(value, key, obj) ? pass : fail).push(value);
+    });
+    return [pass, fail];
+  };
+
+  // Array Functions
+  // ---------------
+
+  // Get the first element of an array. Passing **n** will return the first N
+  // values in the array. Aliased as `head` and `take`. The **guard** check
+  // allows it to work with `_.map`.
+  _.first = _.head = _.take = function(array, n, guard) {
+    if (array == null) return void 0;
+    if (n == null || guard) return array[0];
+    if (n < 0) return [];
+    return slice.call(array, 0, n);
+  };
+
+  // Returns everything but the last entry of the array. Especially useful on
+  // the arguments object. Passing **n** will return all the values in
+  // the array, excluding the last N. The **guard** check allows it to work with
+  // `_.map`.
+  _.initial = function(array, n, guard) {
+    return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
+  };
+
+  // Get the last element of an array. Passing **n** will return the last N
+  // values in the array. The **guard** check allows it to work with `_.map`.
+  _.last = function(array, n, guard) {
+    if (array == null) return void 0;
+    if (n == null || guard) return array[array.length - 1];
+    return slice.call(array, Math.max(array.length - n, 0));
+  };
+
+  // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
+  // Especially useful on the arguments object. Passing an **n** will return
+  // the rest N values in the array. The **guard**
+  // check allows it to work with `_.map`.
+  _.rest = _.tail = _.drop = function(array, n, guard) {
+    return slice.call(array, n == null || guard ? 1 : n);
+  };
+
+  // Trim out all falsy values from an array.
+  _.compact = function(array) {
+    return _.filter(array, _.identity);
+  };
+
+  // Internal implementation of a recursive `flatten` function.
+  var flatten = function(input, shallow, strict, output) {
+    if (shallow && _.every(input, _.isArray)) {
+      return concat.apply(output, input);
+    }
+    for (var i = 0, length = input.length; i < length; i++) {
+      var value = input[i];
+      if (!_.isArray(value) && !_.isArguments(value)) {
+        if (!strict) output.push(value);
+      } else if (shallow) {
+        push.apply(output, value);
+      } else {
+        flatten(value, shallow, strict, output);
+      }
+    }
+    return output;
+  };
+
+  // Flatten out an array, either recursively (by default), or just one level.
+  _.flatten = function(array, shallow) {
+    return flatten(array, shallow, false, []);
+  };
+
+  // Return a version of the array that does not contain the specified value(s).
+  _.without = function(array) {
+    return _.difference(array, slice.call(arguments, 1));
+  };
+
+  // Produce a duplicate-free version of the array. If the array has already
+  // been sorted, you have the option of using a faster algorithm.
+  // Aliased as `unique`.
+  _.uniq = _.unique = function(array, isSorted, iteratee, context) {
+    if (array == null) return [];
+    if (!_.isBoolean(isSorted)) {
+      context = iteratee;
+      iteratee = isSorted;
+      isSorted = false;
+    }
+    if (iteratee != null) iteratee = _.iteratee(iteratee, context);
+    var result = [];
+    var seen = [];
+    for (var i = 0, length = array.length; i < length; i++) {
+      var value = array[i];
+      if (isSorted) {
+        if (!i || seen !== value) result.push(value);
+        seen = value;
+      } else if (iteratee) {
+        var computed = iteratee(value, i, array);
+        if (_.indexOf(seen, computed) < 0) {
+          seen.push(computed);
+          result.push(value);
+        }
+      } else if (_.indexOf(result, value) < 0) {
+        result.push(value);
+      }
+    }
+    return result;
+  };
+
+  // Produce an array that contains the union: each distinct element from all of
+  // the passed-in arrays.
+  _.union = function() {
+    return _.uniq(flatten(arguments, true, true, []));
+  };
+
+  // Produce an array that contains every item shared between all the
+  // passed-in arrays.
+  _.intersection = function(array) {
+    if (array == null) return [];
+    var result = [];
+    var argsLength = arguments.length;
+    for (var i = 0, length = array.length; i < length; i++) {
+      var item = array[i];
+      if (_.contains(result, item)) continue;
+      for (var j = 1; j < argsLength; j++) {
+        if (!_.contains(arguments[j], item)) break;
+      }
+      if (j === argsLength) result.push(item);
+    }
+    return result;
+  };
+
+  // Take the difference between one array and a number of other arrays.
+  // Only the elements present in just the first array will remain.
+  _.difference = function(array) {
+    var rest = flatten(slice.call(arguments, 1), true, true, []);
+    return _.filter(array, function(value){
+      return !_.contains(rest, value);
+    });
+  };
+
+  // Zip together multiple lists into a single array -- elements that share
+  // an index go together.
+  _.zip = function(array) {
+    if (array == null) return [];
+    var length = _.max(arguments, 'length').length;
+    var results = Array(length);
+    for (var i = 0; i < length; i++) {
+      results[i] = _.pluck(arguments, i);
+    }
+    return results;
+  };
+
+  // Converts lists into objects. Pass either a single array of `[key, value]`
+  // pairs, or two parallel arrays of the same length -- one of keys, and one of
+  // the corresponding values.
+  _.object = function(list, values) {
+    if (list == null) return {};
+    var result = {};
+    for (var i = 0, length = list.length; i < length; i++) {
+      if (values) {
+        result[list[i]] = values[i];
+      } else {
+        result[list[i][0]] = list[i][1];
+      }
+    }
+    return result;
+  };
+
+  // Return the position of the first occurrence of an item in an array,
+  // or -1 if the item is not included in the array.
+  // If the array is large and already in sort order, pass `true`
+  // for **isSorted** to use binary search.
+  _.indexOf = function(array, item, isSorted) {
+    if (array == null) return -1;
+    var i = 0, length = array.length;
+    if (isSorted) {
+      if (typeof isSorted == 'number') {
+        i = isSorted < 0 ? Math.max(0, length + isSorted) : isSorted;
+      } else {
+        i = _.sortedIndex(array, item);
+        return array[i] === item ? i : -1;
+      }
+    }
+    for (; i < length; i++) if (array[i] === item) return i;
+    return -1;
+  };
+
+  _.lastIndexOf = function(array, item, from) {
+    if (array == null) return -1;
+    var idx = array.length;
+    if (typeof from == 'number') {
+      idx = from < 0 ? idx + from + 1 : Math.min(idx, from + 1);
+    }
+    while (--idx >= 0) if (array[idx] === item) return idx;
+    return -1;
+  };
+
+  // Generate an integer Array containing an arithmetic progression. A port of
+  // the native Python `range()` function. See
+  // [the Python documentation](http://docs.python.org/library/functions.html#range).
+  _.range = function(start, stop, step) {
+    if (arguments.length <= 1) {
+      stop = start || 0;
+      start = 0;
+    }
+    step = step || 1;
+
+    var length = Math.max(Math.ceil((stop - start) / step), 0);
+    var range = Array(length);
+
+    for (var idx = 0; idx < length; idx++, start += step) {
+      range[idx] = start;
+    }
+
+    return range;
+  };
+
+  // Function (ahem) Functions
+  // ------------------
+
+  // Reusable constructor function for prototype setting.
+  var Ctor = function(){};
+
+  // Create a function bound to a given object (assigning `this`, and arguments,
+  // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
+  // available.
+  _.bind = function(func, context) {
+    var args, bound;
+    if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
+    if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
+    args = slice.call(arguments, 2);
+    bound = function() {
+      if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
+      Ctor.prototype = func.prototype;
+      var self = new Ctor;
+      Ctor.prototype = null;
+      var result = func.apply(self, args.concat(slice.call(arguments)));
+      if (_.isObject(result)) return result;
+      return self;
+    };
+    return bound;
+  };
+
+  // Partially apply a function by creating a version that has had some of its
+  // arguments pre-filled, without changing its dynamic `this` context. _ acts
+  // as a placeholder, allowing any combination of arguments to be pre-filled.
+  _.partial = function(func) {
+    var boundArgs = slice.call(arguments, 1);
+    return function() {
+      var position = 0;
+      var args = boundArgs.slice();
+      for (var i = 0, length = args.length; i < length; i++) {
+        if (args[i] === _) args[i] = arguments[position++];
+      }
+      while (position < arguments.length) args.push(arguments[position++]);
+      return func.apply(this, args);
+    };
+  };
+
+  // Bind a number of an object's methods to that object. Remaining arguments
+  // are the method names to be bound. Useful for ensuring that all callbacks
+  // defined on an object belong to it.
+  _.bindAll = function(obj) {
+    var i, length = arguments.length, key;
+    if (length <= 1) throw new Error('bindAll must be passed function names');
+    for (i = 1; i < length; i++) {
+      key = arguments[i];
+      obj[key] = _.bind(obj[key], obj);
+    }
+    return obj;
+  };
+
+  // Memoize an expensive function by storing its results.
+  _.memoize = function(func, hasher) {
+    var memoize = function(key) {
+      var cache = memoize.cache;
+      var address = hasher ? hasher.apply(this, arguments) : key;
+      if (!_.has(cache, address)) cache[address] = func.apply(this, arguments);
+      return cache[address];
+    };
+    memoize.cache = {};
+    return memoize;
+  };
+
+  // Delays a function for the given number of milliseconds, and then calls
+  // it with the arguments supplied.
+  _.delay = function(func, wait) {
+    var args = slice.call(arguments, 2);
+    return setTimeout(function(){
+      return func.apply(null, args);
+    }, wait);
+  };
+
+  // Defers a function, scheduling it to run after the current call stack has
+  // cleared.
+  _.defer = function(func) {
+    return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
+  };
+
+  // Returns a function, that, when invoked, will only be triggered at most once
+  // during a given window of time. Normally, the throttled function will run
+  // as much as it can, without ever going more than once per `wait` duration;
+  // but if you'd like to disable the execution on the leading edge, pass
+  // `{leading: false}`. To disable execution on the trailing edge, ditto.
+  _.throttle = function(func, wait, options) {
+    var context, args, result;
+    var timeout = null;
+    var previous = 0;
+    if (!options) options = {};
+    var later = function() {
+      previous = options.leading === false ? 0 : _.now();
+      timeout = null;
+      result = func.apply(context, args);
+      if (!timeout) context = args = null;
+    };
+    return function() {
+      var now = _.now();
+      if (!previous && options.leading === false) previous = now;
+      var remaining = wait - (now - previous);
+      context = this;
+      args = arguments;
+      if (remaining <= 0 || remaining > wait) {
+        clearTimeout(timeout);
+        timeout = null;
+        previous = now;
+        result = func.apply(context, args);
+        if (!timeout) context = args = null;
+      } else if (!timeout && options.trailing !== false) {
+        timeout = setTimeout(later, remaining);
+      }
+      return result;
+    };
+  };
+
+  // Returns a function, that, as long as it continues to be invoked, will not
+  // be triggered. The function will be called after it stops being called for
+  // N milliseconds. If `immediate` is passed, trigger the function on the
+  // leading edge, instead of the trailing.
+  _.debounce = function(func, wait, immediate) {
+    var timeout, args, context, timestamp, result;
+
+    var later = function() {
+      var last = _.now() - timestamp;
+
+      if (last < wait && last > 0) {
+        timeout = setTimeout(later, wait - last);
+      } else {
+        timeout = null;
+        if (!immediate) {
+          result = func.apply(context, args);
+          if (!timeout) context = args = null;
+        }
+      }
+    };
+
+    return function() {
+      context = this;
+      args = arguments;
+      timestamp = _.now();
+      var callNow = immediate && !timeout;
+      if (!timeout) timeout = setTimeout(later, wait);
+      if (callNow) {
+        result = func.apply(context, args);
+        context = args = null;
+      }
+
+      return result;
+    };
+  };
+
+  // Returns the first function passed as an argument to the second,
+  // allowing you to adjust arguments, run code before and after, and
+  // conditionally execute the original function.
+  _.wrap = function(func, wrapper) {
+    return _.partial(wrapper, func);
+  };
+
+  // Returns a negated version of the passed-in predicate.
+  _.negate = function(predicate) {
+    return function() {
+      return !predicate.apply(this, arguments);
+    };
+  };
+
+  // Returns a function that is the composition of a list of functions, each
+  // consuming the return value of the function that follows.
+  _.compose = function() {
+    var args = arguments;
+    var start = args.length - 1;
+    return function() {
+      var i = start;
+      var result = args[start].apply(this, arguments);
+      while (i--) result = args[i].call(this, result);
+      return result;
+    };
+  };
+
+  // Returns a function that will only be executed after being called N times.
+  _.after = function(times, func) {
+    return function() {
+      if (--times < 1) {
+        return func.apply(this, arguments);
+      }
+    };
+  };
+
+  // Returns a function that will only be executed before being called N times.
+  _.before = function(times, func) {
+    var memo;
+    return function() {
+      if (--times > 0) {
+        memo = func.apply(this, arguments);
+      } else {
+        func = null;
+      }
+      return memo;
+    };
+  };
+
+  // Returns a function that will be executed at most one time, no matter how
+  // often you call it. Useful for lazy initialization.
+  _.once = _.partial(_.before, 2);
+
+  // Object Functions
+  // ----------------
+
+  // Retrieve the names of an object's properties.
+  // Delegates to **ECMAScript 5**'s native `Object.keys`
+  _.keys = function(obj) {
+    if (!_.isObject(obj)) return [];
+    if (nativeKeys) return nativeKeys(obj);
+    var keys = [];
+    for (var key in obj) if (_.has(obj, key)) keys.push(key);
+    return keys;
+  };
+
+  // Retrieve the values of an object's properties.
+  _.values = function(obj) {
+    var keys = _.keys(obj);
+    var length = keys.length;
+    var values = Array(length);
+    for (var i = 0; i < length; i++) {
+      values[i] = obj[keys[i]];
+    }
+    return values;
+  };
+
+  // Convert an object into a list of `[key, value]` pairs.
+  _.pairs = function(obj) {
+    var keys = _.keys(obj);
+    var length = keys.length;
+    var pairs = Array(length);
+    for (var i = 0; i < length; i++) {
+      pairs[i] = [keys[i], obj[keys[i]]];
+    }
+    return pairs;
+  };
+
+  // Invert the keys and values of an object. The values must be serializable.
+  _.invert = function(obj) {
+    var result = {};
+    var keys = _.keys(obj);
+    for (var i = 0, length = keys.length; i < length; i++) {
+      result[obj[keys[i]]] = keys[i];
+    }
+    return result;
+  };
+
+  // Return a sorted list of the function names available on the object.
+  // Aliased as `methods`
+  _.functions = _.methods = function(obj) {
+    var names = [];
+    for (var key in obj) {
+      if (_.isFunction(obj[key])) names.push(key);
+    }
+    return names.sort();
+  };
+
+  // Extend a given object with all the properties in passed-in object(s).
+  _.extend = function(obj) {
+    if (!_.isObject(obj)) return obj;
+    var source, prop;
+    for (var i = 1, length = arguments.length; i < length; i++) {
+      source = arguments[i];
+      for (prop in source) {
+        if (hasOwnProperty.call(source, prop)) {
+            obj[prop] = source[prop];
+        }
+      }
+    }
+    return obj;
+  };
+
+  // Return a copy of the object only containing the whitelisted properties.
+  _.pick = function(obj, iteratee, context) {
+    var result = {}, key;
+    if (obj == null) return result;
+    if (_.isFunction(iteratee)) {
+      iteratee = createCallback(iteratee, context);
+      for (key in obj) {
+        var value = obj[key];
+        if (iteratee(value, key, obj)) result[key] = value;
+      }
+    } else {
+      var keys = concat.apply([], slice.call(arguments, 1));
+      obj = new Object(obj);
+      for (var i = 0, length = keys.length; i < length; i++) {
+        key = keys[i];
+        if (key in obj) result[key] = obj[key];
+      }
+    }
+    return result;
+  };
+
+   // Return a copy of the object without the blacklisted properties.
+  _.omit = function(obj, iteratee, context) {
+    if (_.isFunction(iteratee)) {
+      iteratee = _.negate(iteratee);
+    } else {
+      var keys = _.map(concat.apply([], slice.call(arguments, 1)), String);
+      iteratee = function(value, key) {
+        return !_.contains(keys, key);
+      };
+    }
+    return _.pick(obj, iteratee, context);
+  };
+
+  // Fill in a given object with default properties.
+  _.defaults = function(obj) {
+    if (!_.isObject(obj)) return obj;
+    for (var i = 1, length = arguments.length; i < length; i++) {
+      var source = arguments[i];
+      for (var prop in source) {
+        if (obj[prop] === void 0) obj[prop] = source[prop];
+      }
+    }
+    return obj;
+  };
+
+  // Create a (shallow-cloned) duplicate of an object.
+  _.clone = function(obj) {
+    if (!_.isObject(obj)) return obj;
+    return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
+  };
+
+  // Invokes interceptor with the obj, and then returns obj.
+  // The primary purpose of this method is to "tap into" a method chain, in
+  // order to perform operations on intermediate results within the chain.
+  _.tap = function(obj, interceptor) {
+    interceptor(obj);
+    return obj;
+  };
+
+  // Internal recursive comparison function for `isEqual`.
+  var eq = function(a, b, aStack, bStack) {
+    // Identical objects are equal. `0 === -0`, but they aren't identical.
+    // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
+    if (a === b) return a !== 0 || 1 / a === 1 / b;
+    // A strict comparison is necessary because `null == undefined`.
+    if (a == null || b == null) return a === b;
+    // Unwrap any wrapped objects.
+    if (a instanceof _) a = a._wrapped;
+    if (b instanceof _) b = b._wrapped;
+    // Compare `[[Class]]` names.
+    var className = toString.call(a);
+    if (className !== toString.call(b)) return false;
+    switch (className) {
+      // Strings, numbers, regular expressions, dates, and booleans are compared by value.
+      case '[object RegExp]':
+      // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
+      case '[object String]':
+        // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
+        // equivalent to `new String("5")`.
+        return '' + a === '' + b;
+      case '[object Number]':
+        // `NaN`s are equivalent, but non-reflexive.
+        // Object(NaN) is equivalent to NaN
+        if (+a !== +a) return +b !== +b;
+        // An `egal` comparison is performed for other numeric values.
+        return +a === 0 ? 1 / +a === 1 / b : +a === +b;
+      case '[object Date]':
+      case '[object Boolean]':
+        // Coerce dates and booleans to numeric primitive values. Dates are compared by their
+        // millisecond representations. Note that invalid dates with millisecond representations
+        // of `NaN` are not equivalent.
+        return +a === +b;
+    }
+    if (typeof a != 'object' || typeof b != 'object') return false;
+    // Assume equality for cyclic structures. The algorithm for detecting cyclic
+    // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
+    var length = aStack.length;
+    while (length--) {
+      // Linear search. Performance is inversely proportional to the number of
+      // unique nested structures.
+      if (aStack[length] === a) return bStack[length] === b;
+    }
+    // Objects with different constructors are not equivalent, but `Object`s
+    // from different frames are.
+    var aCtor = a.constructor, bCtor = b.constructor;
+    if (
+      aCtor !== bCtor &&
+      // Handle Object.create(x) cases
+      'constructor' in a && 'constructor' in b &&
+      !(_.isFunction(aCtor) && aCtor instanceof aCtor &&
+        _.isFunction(bCtor) && bCtor instanceof bCtor)
+    ) {
+      return false;
+    }
+    // Add the first object to the stack of traversed objects.
+    aStack.push(a);
+    bStack.push(b);
+    var size, result;
+    // Recursively compare objects and arrays.
+    if (className === '[object Array]') {
+      // Compare array lengths to determine if a deep comparison is necessary.
+      size = a.length;
+      result = size === b.length;
+      if (result) {
+        // Deep compare the contents, ignoring non-numeric properties.
+        while (size--) {
+          if (!(result = eq(a[size], b[size], aStack, bStack))) break;
+        }
+      }
+    } else {
+      // Deep compare objects.
+      var keys = _.keys(a), key;
+      size = keys.length;
+      // Ensure that both objects contain the same number of properties before comparing deep equality.
+      result = _.keys(b).length === size;
+      if (result) {
+        while (size--) {
+          // Deep compare each member
+          key = keys[size];
+          if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break;
+        }
+      }
+    }
+    // Remove the first object from the stack of traversed objects.
+    aStack.pop();
+    bStack.pop();
+    return result;
+  };
+
+  // Perform a deep comparison to check if two objects are equal.
+  _.isEqual = function(a, b) {
+    return eq(a, b, [], []);
+  };
+
+  // Is a given array, string, or object empty?
+  // An "empty" object has no enumerable own-properties.
+  _.isEmpty = function(obj) {
+    if (obj == null) return true;
+    if (_.isArray(obj) || _.isString(obj) || _.isArguments(obj)) return obj.length === 0;
+    for (var key in obj) if (_.has(obj, key)) return false;
+    return true;
+  };
+
+  // Is a given value a DOM element?
+  _.isElement = function(obj) {
+    return !!(obj && obj.nodeType === 1);
+  };
+
+  // Is a given value an array?
+  // Delegates to ECMA5's native Array.isArray
+  _.isArray = nativeIsArray || function(obj) {
+    return toString.call(obj) === '[object Array]';
+  };
+
+  // Is a given variable an object?
+  _.isObject = function(obj) {
+    var type = typeof obj;
+    return type === 'function' || type === 'object' && !!obj;
+  };
+
+  // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
+  _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
+    _['is' + name] = function(obj) {
+      return toString.call(obj) === '[object ' + name + ']';
+    };
+  });
+
+  // Define a fallback version of the method in browsers (ahem, IE), where
+  // there isn't any inspectable "Arguments" type.
+  if (!_.isArguments(arguments)) {
+    _.isArguments = function(obj) {
+      return _.has(obj, 'callee');
+    };
+  }
+
+  // Optimize `isFunction` if appropriate. Work around an IE 11 bug.
+  if (typeof /./ !== 'function') {
+    _.isFunction = function(obj) {
+      return typeof obj == 'function' || false;
+    };
+  }
+
+  // Is a given object a finite number?
+  _.isFinite = function(obj) {
+    return isFinite(obj) && !isNaN(parseFloat(obj));
+  };
+
+  // Is the given value `NaN`? (NaN is the only number which does not equal itself).
+  _.isNaN = function(obj) {
+    return _.isNumber(obj) && obj !== +obj;
+  };
+
+  // Is a given value a boolean?
+  _.isBoolean = function(obj) {
+    return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
+  };
+
+  // Is a given value equal to null?
+  _.isNull = function(obj) {
+    return obj === null;
+  };
+
+  // Is a given variable undefined?
+  _.isUndefined = function(obj) {
+    return obj === void 0;
+  };
+
+  // Shortcut function for checking if an object has a given property directly
+  // on itself (in other words, not on a prototype).
+  _.has = function(obj, key) {
+    return obj != null && hasOwnProperty.call(obj, key);
+  };
+
+  // Utility Functions
+  // -----------------
+
+  // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
+  // previous owner. Returns a reference to the Underscore object.
+  _.noConflict = function() {
+    root._ = previousUnderscore;
+    return this;
+  };
+
+  // Keep the identity function around for default iteratees.
+  _.identity = function(value) {
+    return value;
+  };
+
+  _.constant = function(value) {
+    return function() {
+      return value;
+    };
+  };
+
+  _.noop = function(){};
+
+  _.property = function(key) {
+    return function(obj) {
+      return obj[key];
+    };
+  };
+
+  // Returns a predicate for checking whether an object has a given set of `key:value` pairs.
+  _.matches = function(attrs) {
+    var pairs = _.pairs(attrs), length = pairs.length;
+    return function(obj) {
+      if (obj == null) return !length;
+      obj = new Object(obj);
+      for (var i = 0; i < length; i++) {
+        var pair = pairs[i], key = pair[0];
+        if (pair[1] !== obj[key] || !(key in obj)) return false;
+      }
+      return true;
+    };
+  };
+
+  // Run a function **n** times.
+  _.times = function(n, iteratee, context) {
+    var accum = Array(Math.max(0, n));
+    iteratee = createCallback(iteratee, context, 1);
+    for (var i = 0; i < n; i++) accum[i] = iteratee(i);
+    return accum;
+  };
+
+  // Return a random integer between min and max (inclusive).
+  _.random = function(min, max) {
+    if (max == null) {
+      max = min;
+      min = 0;
+    }
+    return min + Math.floor(Math.random() * (max - min + 1));
+  };
+
+  // A (possibly faster) way to get the current timestamp as an integer.
+  _.now = Date.now || function() {
+    return new Date().getTime();
+  };
+
+   // List of HTML entities for escaping.
+  var escapeMap = {
+    '&': '&amp;',
+    '<': '&lt;',
+    '>': '&gt;',
+    '"': '&quot;',
+    "'": '&#x27;',
+    '`': '&#x60;'
+  };
+  var unescapeMap = _.invert(escapeMap);
+
+  // Functions for escaping and unescaping strings to/from HTML interpolation.
+  var createEscaper = function(map) {
+    var escaper = function(match) {
+      return map[match];
+    };
+    // Regexes for identifying a key that needs to be escaped
+    var source = '(?:' + _.keys(map).join('|') + ')';
+    var testRegexp = RegExp(source);
+    var replaceRegexp = RegExp(source, 'g');
+    return function(string) {
+      string = string == null ? '' : '' + string;
+      return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
+    };
+  };
+  _.escape = createEscaper(escapeMap);
+  _.unescape = createEscaper(unescapeMap);
+
+  // If the value of the named `property` is a function then invoke it with the
+  // `object` as context; otherwise, return it.
+  _.result = function(object, property) {
+    if (object == null) return void 0;
+    var value = object[property];
+    return _.isFunction(value) ? object[property]() : value;
+  };
+
+  // Generate a unique integer id (unique within the entire client session).
+  // Useful for temporary DOM ids.
+  var idCounter = 0;
+  _.uniqueId = function(prefix) {
+    var id = ++idCounter + '';
+    return prefix ? prefix + id : id;
+  };
+
+  // By default, Underscore uses ERB-style template delimiters, change the
+  // following template settings to use alternative delimiters.
+  _.templateSettings = {
+    evaluate    : /<%([\s\S]+?)%>/g,
+    interpolate : /<%=([\s\S]+?)%>/g,
+    escape      : /<%-([\s\S]+?)%>/g
+  };
+
+  // When customizing `templateSettings`, if you don't want to define an
+  // interpolation, evaluation or escaping regex, we need one that is
+  // guaranteed not to match.
+  var noMatch = /(.)^/;
+
+  // Certain characters need to be escaped so that they can be put into a
+  // string literal.
+  var escapes = {
+    "'":      "'",
+    '\\':     '\\',
+    '\r':     'r',
+    '\n':     'n',
+    '\u2028': 'u2028',
+    '\u2029': 'u2029'
+  };
+
+  var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
+
+  var escapeChar = function(match) {
+    return '\\' + escapes[match];
+  };
+
+  // JavaScript micro-templating, similar to John Resig's implementation.
+  // Underscore templating handles arbitrary delimiters, preserves whitespace,
+  // and correctly escapes quotes within interpolated code.
+  // NB: `oldSettings` only exists for backwards compatibility.
+  _.template = function(text, settings, oldSettings) {
+    if (!settings && oldSettings) settings = oldSettings;
+    settings = _.defaults({}, settings, _.templateSettings);
+
+    // Combine delimiters into one regular expression via alternation.
+    var matcher = RegExp([
+      (settings.escape || noMatch).source,
+      (settings.interpolate || noMatch).source,
+      (settings.evaluate || noMatch).source
+    ].join('|') + '|$', 'g');
+
+    // Compile the template source, escaping string literals appropriately.
+    var index = 0;
+    var source = "__p+='";
+    text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
+      source += text.slice(index, offset).replace(escaper, escapeChar);
+      index = offset + match.length;
+
+      if (escape) {
+        source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
+      } else if (interpolate) {
+        source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
+      } else if (evaluate) {
+        source += "';\n" + evaluate + "\n__p+='";
+      }
+
+      // Adobe VMs need the match returned to produce the correct offest.
+      return match;
+    });
+    source += "';\n";
+
+    // If a variable is not specified, place data values in local scope.
+    if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
+
+    source = "var __t,__p='',__j=Array.prototype.join," +
+      "print=function(){__p+=__j.call(arguments,'');};\n" +
+      source + 'return __p;\n';
+
+    try {
+      var render = new Function(settings.variable || 'obj', '_', source);
+    } catch (e) {
+      e.source = source;
+      throw e;
+    }
+
+    var template = function(data) {
+      return render.call(this, data, _);
+    };
+
+    // Provide the compiled source as a convenience for precompilation.
+    var argument = settings.variable || 'obj';
+    template.source = 'function(' + argument + '){\n' + source + '}';
+
+    return template;
+  };
+
+  // Add a "chain" function. Start chaining a wrapped Underscore object.
+  _.chain = function(obj) {
+    var instance = _(obj);
+    instance._chain = true;
+    return instance;
+  };
+
+  // OOP
+  // ---------------
+  // If Underscore is called as a function, it returns a wrapped object that
+  // can be used OO-style. This wrapper holds altered versions of all the
+  // underscore functions. Wrapped objects may be chained.
+
+  // Helper function to continue chaining intermediate results.
+  var result = function(obj) {
+    return this._chain ? _(obj).chain() : obj;
+  };
+
+  // Add your own custom functions to the Underscore object.
+  _.mixin = function(obj) {
+    _.each(_.functions(obj), function(name) {
+      var func = _[name] = obj[name];
+      _.prototype[name] = function() {
+        var args = [this._wrapped];
+        push.apply(args, arguments);
+        return result.call(this, func.apply(_, args));
+      };
+    });
+  };
+
+  // Add all of the Underscore functions to the wrapper object.
+  _.mixin(_);
+
+  // Add all mutator Array functions to the wrapper.
+  _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
+    var method = ArrayProto[name];
+    _.prototype[name] = function() {
+      var obj = this._wrapped;
+      method.apply(obj, arguments);
+      if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
+      return result.call(this, obj);
+    };
+  });
+
+  // Add all accessor Array functions to the wrapper.
+  _.each(['concat', 'join', 'slice'], function(name) {
+    var method = ArrayProto[name];
+    _.prototype[name] = function() {
+      return result.call(this, method.apply(this._wrapped, arguments));
+    };
+  });
+
+  // Extracts the result from a wrapped and chained object.
+  _.prototype.value = function() {
+    return this._wrapped;
+  };
+
+  // AMD registration happens at the end for compatibility with AMD loaders
+  // that may not enforce next-turn semantics on modules. Even though general
+  // practice for AMD registration is to be anonymous, underscore registers
+  // as a named module because, like jQuery, it is a base library that is
+  // popular enough to be bundled in a third party lib, but not be part of
+  // an AMD load request. Those cases could generate an error when an
+  // anonymous define() is called outside of a loader request.
+  if (typeof define === 'function' && define.amd) {
+    define('underscore', [], function() {
+      return _;
+    });
+  }
+}.call(this));

+ 395 - 0
course-design/main.js

@@ -0,0 +1,395 @@
+function addNode(parentId, nodeId, nodeLable, position) {
+  var panel = d3.select("#" + parentId);
+  panel.append('div')
+    .style('position', 'absolute')
+    .style('top', position.y).style('left', position.x)
+    .style('border', 'none').attr('align', 'center')
+    // .style('background','#4169E1')
+    .style('border-radius', '9px')
+    // .style('cursor', 'pointer')
+    .style('color', '#4169E1')
+    .style('font-size', '25px')
+    .style('padding-left', '10px')
+    .style('padding-right', '10px')
+    .style('padding-top', '5px')
+    .style('padding-bottom', '5px')
+    .style("margin", '0 auto')
+    .attr('id', nodeId).classed('node', true)
+    // .attr('data-toggle','modal')
+    // .attr('data-target',"#myModal")
+    // .attr('onclick', 'openA(\'' + nodeId + '\')')
+    .text(nodeLable);
+
+  panel.append('div')
+    .style('position', 'absolute')
+    .style('top', (parseInt(position.y.split("px")[0]) + 40).toString() + 'px').style('left', position.x)
+    .style('border', 'none').attr('align', 'center')
+    // .style('background','#4169E1')
+    .style('width', (document.getElementById(nodeId).offsetWidth).toString() + 'px')
+    .style('text-align', 'center')
+    .style('border-radius', '9px')
+    .style('cursor', 'pointer')
+    .style('color', '#4169E1')
+    .style('font-size', '25px')
+    .style('padding-left', '10px')
+    .style('padding-right', '10px')
+    .style('padding-top', '5px')
+    .style('padding-bottom', '5px')
+    .style("margin", '0 auto')
+    .classed('node', true)
+    // .attr('data-toggle','modal')
+    // .attr('data-target',"#myModal")
+    .attr('onclick', 'openA(\'' + nodeId + '\')')
+    .text("+");
+
+
+  return jsPlumb.getSelector('#' + nodeId)[0];
+}
+
+var aaa = 1;
+
+function bbb() {
+  if (event.keyCode == 13) {
+    aaa = aaa + 1;
+    var name = "types" + aaa.toString();
+    var str = '<div class="form-group"><label style="vertical-align: middle;display:inline-block;width: 100%;">' + aaa + '<input type="text" id="' + name + '" class="form-control" placeholder="请输入节点类别名字" style="width: 92%;display:inline-block;margin-left: 5px;" onkeydown="bbb()"></label></div>'
+    $("#bbb").append(str);
+    var inputs = document.getElementById("bbb").getElementsByTagName("input");
+    inputs[inputs.length-1].focus();
+  }
+}
+
+function addInput() {
+  if (event.keyCode == 13) {
+    aaa = aaa + 1;
+    var name = "names" + aaa.toString();
+    var str = '<div class="form-group"><label style="vertical-align: middle;display:inline-block;width: 100%;">' + aaa + '<input type="text" id="' + name + '" class="form-control" placeholder="请输入节点名字" style="width: 92%;display:inline-block;margin-left: 5px;" onkeydown="addInput()"></label></div>';
+    $("#aaa").append(str);
+    var inputs = document.getElementById("aaa").getElementsByTagName("input");
+    inputs[inputs.length-1].focus();
+  }
+}
+
+function openA(id) {
+  $("#myModal").modal('show');
+  $("#column").val(id.split("node")[1])
+}
+
+function addNodeA(parentId, nodeId, nodeLable, position) {
+  var panel = d3.select("#" + parentId);
+  panel.append('div')
+    .style('position', 'absolute')
+    .style('top', position.y).style('left', position.x)
+    .style('border', '1px #4169E1 solid').attr('align', 'center')
+    .style('background', '#4169E1')
+    .style('border-radius', '9px')
+    .style('color', 'white')
+    .style('font-size', '25px')
+    .style('padding-left', '10px')
+    .style('padding-right', '10px')
+    .style('padding-top', '5px')
+    .style('padding-bottom', '5px')
+    .style("margin", '0 auto')
+    .attr('id', nodeId).classed('node', true)
+    .text(nodeLable);
+
+  return jsPlumb.getSelector('#' + nodeId)[0];
+}
+
+function addNodeB(parentId, nodeId, nodeLable, position) {
+  var panel = d3.select("#" + parentId);
+  panel.append('div')
+    .style('position', 'absolute')
+    .style('top', position.y).style('left', position.x)
+    .style('border', '1px #4169E1 solid').attr('align', 'center')
+    .style('background', '#ffffff')
+    .style('border-radius', '9px')
+    .style('color', '#4169E1')
+    .style('font-size', '25px')
+    .style('padding-left', '10px')
+    .style('padding-right', '10px')
+    .style('padding-top', '5px')
+    .style('padding-bottom', '5px')
+    .style("margin", '0 auto')
+    .attr('id', nodeId).classed('node', true)
+    .text(nodeLable);
+
+  return jsPlumb.getSelector('#' + nodeId)[0];
+}
+
+function SubmitB() {
+  for (var i = 1; i <= aaa; i++) {
+    if (i == 1) {
+      var b = 20;
+      var a = addNode('flow-panel', 'node1', $('#types' + i).val(), { x: '80px', y: b.toString() + 'px' });
+    }
+    else if (i == 2) {
+      var b = 20;
+      var a = addNode('flow-panel', 'node2', $('#types' + i).val(), { x: '380px', y: b.toString() + 'px' });
+    }
+    else if (i == 3) {
+      var b = 20;
+      var a = addNode('flow-panel', 'node3', $('#types' + i).val(), { x: '680px', y: b.toString() + 'px' });
+    }
+    else {
+      var b = 20;
+      var a = addNode('flow-panel', 'node4', $('#types' + i).val(), { x: '980px', y: b.toString() + 'px' });
+    }
+    $('#types' + i).val('');
+  }
+  $("#bbb").html("");
+  aaa = 1;
+  var str = '<div class="form-group"><label style="vertical-align: middle;display:inline-block;width: 100%;">1<input type="text" id="types1" class="form-control" placeholder="请输入节点类别名字" style="width: 92%;display:inline-block;" onkeydown="bbb()"></label></div>'
+  $("#bbb").append(str);
+  $("#Modal").modal('hide');
+}
+
+function SubmitA(instance) {
+  var column = $('#column').val();
+  if (column == 1) {
+    for (var i = 1; i <= aaa; i++) {
+      var b = 20 + i * 80;
+      var a = addNodeA('flow-panel', 'nodeA' + i.toString(), $('#names' + i.toString()).val(), { x: '80px', y: b.toString() + 'px' });
+      addPorts(instance, a, ['out'], 'output');
+      $('#names' + i).val('')
+    }
+  }
+  else if (column == 2) {
+    for (var i = 1; i <= aaa; i++) {
+      var b = 20 + i * 80;
+      var a = addNodeB('flow-panel', 'nodeB' + i.toString(), $('#names' + i.toString()).val(), { x: '380px', y: b.toString() + 'px' });
+      addPorts(instance, a, ['in'], 'input');
+      addPorts(instance, a, ['out'], 'output');
+      $('#names' + i).val('')
+    }
+  }
+  else if (column == 3) {
+    for (var i = 1; i <= aaa; i++) {
+      var b = 20 + i * 80;
+      var a = addNodeB('flow-panel', 'nodeC' + i.toString(), $('#names' + i.toString()).val(), { x: '680px', y: b.toString() + 'px' });
+      addPorts(instance, a, ['in'], 'input');
+      addPorts(instance, a, ['out'], 'output');
+      $('#names' + i).val('')
+    }
+  }
+  else {
+    for (var i = 1; i <= aaa; i++) {
+      var b = 20 + i * 80;
+      var a = addNodeA('flow-panel', 'nodeD' + i.toString(), $('#names' + i.toString()).val(), { x: '980px', y: b.toString() + 'px' });
+      addPorts(instance, a, ['in'], 'input');
+      $('#names' + i).val('')
+    }
+  }
+  $('#column').val('');
+  $("#aaa").html("");
+  aaa = 1;
+  var str = '<div class="form-group"><label style="vertical-align: middle;display:inline-block;width: 100%;">1 <input type="text" id="names1" class="form-control" placeholder="请输入节点名字" style="width: 92%;display:inline-block;" onkeydown="addInput()"></label></div>'
+  $("#aaa").append(str);
+  $("#myModal").modal('hide');
+}
+
+function addPorts(instance, node, ports, type) {
+  //Assume horizental layout
+  var number_of_ports = ports.length;
+  var i = 0;
+  var height = $(node).height();  //Note, jquery does not include border for height
+  var y_offset = 1 / (number_of_ports + 1);
+  var y = 0;
+
+  var connectorStyle = {
+    // 端点的样式
+    // paintStyle: {
+    //     fill: '#7AB02C',
+    //     radius: 7
+    // },
+    // endpointStyle: { fill: 'lightgray', outlineStroke: 'darkgray', outlineWidth: 2 },
+    // // // 鼠标移上样式
+    // // hoverPaintStyle: {
+    // //     fill: '#216477',
+    // //     stroke: '#216477'
+    // // },
+
+    // // // 连线类型
+    // connector: ['Straight', {
+    //     stub: [40, 60],
+    //     gap: 10,
+    //     cornerRadius: 5,
+    //     alwaysRespectStubs: true
+    // }],
+    // // // 连线样式
+    // connectorStyle: {
+    //     strokeWidth: 3,
+    //     stroke: '#4169E1',
+    //     // joinstyle: 'round',
+    //     // outlineStroke: 'none',
+    //     // // 线外边的宽,值越大,线的点击范围越大
+    //     // outlineWidth: 10
+    // },
+    // connectorHoverStyle: {
+    //     stroke: 'green'
+    // },
+    connectorOverlays: [
+      // 箭头
+      ['Arrow', { width: 12, length: 12, location: 1 }]
+    ]
+  }
+
+  for (; i < number_of_ports; i++) {
+    var anchor = [0, 0, 0, 0];
+    var paintStyle = { radius: 4, fillStyle: '#7FFFAA' };
+    var isSource = false, isTarget = false;
+    if (type === 'output') {
+      anchor[0] = 1;
+      paintStyle.fillStyle = '#7FFFAA';
+      isSource = true;
+    } else {
+      isTarget = true;
+    }
+
+    anchor[1] = y + y_offset;
+    y = anchor[1];
+
+    instance.addEndpoint(node, {
+      uuid: node.getAttribute("id") + "-" + ports[i],
+      paintStyle: paintStyle,
+      anchor: anchor,
+      maxConnections: -1,
+      isSource: isSource,
+      isTarget: isTarget
+    }, connectorStyle);
+  }
+}
+
+function connectPorts(instance, node1, port1, node2, port2) {
+  // declare some common values:
+  var color = "gray";
+  var arrowCommon = { foldback: 0.8, fillStyle: color, width: 5 },
+    // use three-arg spec to create two different arrows with the common values:
+    overlays = [
+      ["Arrow", { location: 0.8 }, arrowCommon],
+      ["Arrow", { location: 0.2, direction: -1 }, arrowCommon]
+    ];
+
+  var uuid_source = node1.getAttribute("id") + "-" + port1;
+  var uuid_target = node2.getAttribute("id") + "-" + port2;
+
+  instance.connect({ uuids: [uuid_source, uuid_target] });
+}
+
+function getTreeData() {
+  var tree = [
+    {
+      text: "Nodes",
+      nodes: [
+        {
+          text: "Node1",
+        },
+        {
+          text: "Node2"
+        }
+      ]
+    }
+  ];
+
+  return tree;
+}
+
+jsPlumb.ready(function () {
+  console.log("jsPlumb is ready to use");
+
+  //Initialize JsPlumb
+  var color = "#4169E1";
+  var instance = jsPlumb.getInstance({
+    // notice the 'curviness' argument to this Bezier curve.  the curves on this page are far smoother
+    // than the curves on the first demo, which use the default curviness value.      
+    Connector: ["Straight", { curviness: 50 }],
+    DragOptions: { cursor: "pointer", zIndex: 2000 },
+    PaintStyle: { strokeStyle: color, lineWidth: 2 },
+    EndpointStyle: { radius: 4, fillStyle: color },
+    HoverPaintStyle: { strokeStyle: "#4169E1" },
+    EndpointHoverStyle: { fillStyle: "#7FFFAA" },
+    Container: "flow-panel"
+  });
+
+  //Initialize Control Tree View
+  $('#control-panel').treeview({ data: getTreeData() });
+
+  //Handle drag and drop
+  $('.list-group-item').attr('draggable', 'true').on('dragstart', function (ev) {
+    //ev.dataTransfer.setData("text", ev.target.id);
+    ev.originalEvent.dataTransfer.setData('text', ev.target.textContent);
+    console.log('drag start');
+  });
+
+  $('#flow-panel').on('drop', function (ev) {
+
+    //avoid event conlict for jsPlumb
+    if (ev.target.className.indexOf('_jsPlumb') >= 0) {
+      return;
+    }
+
+    ev.preventDefault();
+    var mx = '' + ev.originalEvent.offsetX + 'px';
+    var my = '' + ev.originalEvent.offsetY + 'px';
+
+    console.log('on drop : ' + ev.originalEvent.dataTransfer.getData('text'));
+    var uid = new Date().getTime();
+    var node = addNode('flow-panel', 'node' + uid, 'node', { x: mx, y: my });
+    addPorts(instance, node, ['out'], 'output');
+    addPorts(instance, node, ['in1', 'in2'], 'input');
+    instance.draggable($(node));
+  }).on('dragover', function (ev) {
+    ev.preventDefault();
+    console.log('on drag over');
+  });
+
+  $("#SubmitA").on('click', function () {
+    SubmitA(instance)
+  });
+  $("#SubmitB").on('click', function () {
+    SubmitB()
+  });
+
+  // for (var i = 0;i < 4;i++){
+  //   $("#node" + i).on('click', function(){
+  //     open(i)
+  //   });
+  // }
+
+
+  instance.doWhileSuspended(function () {
+
+    // declare some common values:
+    // var arrowCommon = { foldback:0.8, fillStyle:color, width:5 },
+    // // use three-arg spec to create two different arrows with the common values:
+    // overlays = [
+    //   [ "Arrow", { location:0.8 }, arrowCommon ],
+    //   [ "Arrow", { location:0.2, direction:-1 }, arrowCommon ]
+    // ];
+
+    // var node1 = addNode('flow-panel','node1', 'node1', {x:'80px',y:'20px'});
+    // var node2 = addNode('flow-panel','node2', 'node2', {x:'280px',y:'20px'});
+    // var node3 = addNode('flow-panel','node3', 'node3', {x:'500px',y:'20px'});
+    // var node4 = addNode('flow-panel','node4', 'node4', {x:'700px',y:'20px'});
+    // var node5 = addNode('flow-panel','node5', 'node5', {x:'80px',y:'100px'});
+    // var node6 = addNode('flow-panel','node6', 'node6', {x:'700px',y:'100px'});
+
+    // addPorts(instance, node1, ['out'],'output');
+    // addPorts(instance, node2, ['in'],'input');
+    // addPorts(instance, node2, ['out'],'output');
+    // addPorts(instance, node3, ['in'],'input');
+    // addPorts(instance, node3, ['out'],'output');
+    // addPorts(instance, node4, ['in'],'input');
+    // addPorts(instance, node5, ['out'],'output');
+    // addPorts(instance, node6, ['in'],'input');
+
+    // connectPorts(instance, node1, 'out', node2, 'in');
+
+
+    instance.draggable($('.node'));
+
+  });
+
+  jsPlumb.fire("jsFlowLoaded", instance);
+
+});

Some files were not shown because too many files changed in this diff