diff --git a/hyracks-control-cc/src/main/resources/edu/uci/ics/hyracks/control/cc/adminconsole/pages/AbstractPage.html b/hyracks-control-cc/src/main/resources/edu/uci/ics/hyracks/control/cc/adminconsole/pages/AbstractPage.html
index 9c4e57d..3fa9574 100644
--- a/hyracks-control-cc/src/main/resources/edu/uci/ics/hyracks/control/cc/adminconsole/pages/AbstractPage.html
+++ b/hyracks-control-cc/src/main/resources/edu/uci/ics/hyracks/control/cc/adminconsole/pages/AbstractPage.html
@@ -3,12 +3,7 @@
     <script type="text/javascript" src="/static/javascript/jquery/jquery.min.js"></script>
     <script type="text/javascript" src="/static/javascript/jquery/plugins/jquery.timer.js"></script>
     <script type="text/javascript" src="/static/javascript/jquery/plugins/jquery.getParams.js"></script>
-    <script type="text/javascript" src="/static/javascript/jqplot/jquery.jqplot.min.js"></script>
-    <script type="text/javascript" src="/static/javascript/jqplot/plugins/jqplot.highlighter.min.js"></script>
-    <script type="text/javascript" src="/static/javascript/jqplot/plugins/jqplot.cursor.min.js"></script>
-    <script type="text/javascript" src="/static/javascript/jqplot/plugins/jqplot.canvasTextRenderer.min.js"></script>
-    <script type="text/javascript" src="/static/javascript/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
-    <link rel="stylesheet" type="text/css" href="/static/javascript/jqplot/jquery.jqplot.min.css"></link>
+    <script type="text/javascript" src="/static/javascript/flot/jquery.flot.min.js"></script>
     <link rel="stylesheet" type="text/css" href="/static/stylesheet/adminconsole.css"></link>
 </head>
 <body>
diff --git a/hyracks-control-cc/src/main/resources/edu/uci/ics/hyracks/control/cc/adminconsole/pages/NodeDetailsPage.html b/hyracks-control-cc/src/main/resources/edu/uci/ics/hyracks/control/cc/adminconsole/pages/NodeDetailsPage.html
index c79ae20..f9f1a4f 100644
--- a/hyracks-control-cc/src/main/resources/edu/uci/ics/hyracks/control/cc/adminconsole/pages/NodeDetailsPage.html
+++ b/hyracks-control-cc/src/main/resources/edu/uci/ics/hyracks/control/cc/adminconsole/pages/NodeDetailsPage.html
@@ -1,276 +1,20 @@
 <wicket:extend xmlns:wicket>
-    <div id='system-load-chart' class="jqplot-target time-chart">
+    <h2>System Load</h2>
+    <div id='system-load-chart' class="time-chart">
     </div>
+
+    <h2>Garbage Collection</h2>
     <div id='gc-charts'>
     </div>
-    <div id='heap-usage-chart' class="jqplot-target time-chart">
+
+    <h2>Memory Usage</h2>
+    <div id='heap-usage-chart' class="time-chart">
     </div>
-    <div id='nonheap-usage-chart' class="jqplot-target time-chart">
+    <div id='nonheap-usage-chart' class="time-chart">
     </div>
-    <div id='thread-chart' class="jqplot-target time-chart">
+
+    <h2>Thread Statistics</h2>
+    <div id='thread-chart' class="time-chart">
     </div>
-    <script type="text/javascript">
-        $(document).ready(function() {
-            $.timer(function() {
-                window.location.reload();
-            }, 10000, true);
-            $.get('/rest/nodes/' + $.getURLParam('node-id'), function(data) {
-                var result = data.result;
-                var sysLoad = result['system-load-averages'];
-                var heapUsageInitSizes = result['heap-init-sizes'];
-                var heapUsageUsedSizes = result['heap-used-sizes'];
-                var heapUsageCommittedSizes = result['heap-committed-sizes'];
-                var heapUsageMaxSizes = result['heap-max-sizes'];
-                var nonheapUsageInitSizes = result['nonheap-init-sizes'];
-                var nonheapUsageUsedSizes = result['nonheap-used-sizes'];
-                var nonheapUsageCommittedSizes = result['nonheap-committed-sizes'];
-                var nonheapUsageMaxSizes = result['nonheap-max-sizes'];
-                var threadCounts = result['thread-counts'];
-                var peakThreadCounts = result['peak-thread-counts'];
-                var gcCollectionCounts = result['gc-collection-counts'];
-                var gcCollectionTimes = result['gc-collection-times'];
-                var sysLoadArray = [];
-                var heapUsageInitSizesArray = [];
-                var heapUsageUsedSizesArray = [];
-                var heapUsageCommittedSizesArray = [];
-                var heapUsageMaxSizesArray = [];
-                var nonheapUsageInitSizesArray = [];
-                var nonheapUsageUsedSizesArray = [];
-                var nonheapUsageCommittedSizesArray = [];
-                var nonheapUsageMaxSizesArray = [];
-                var threadCountsArray = [];
-                var peakThreadCountsArray = [];
-                var gcCollectionCountsArray = [];
-                var gcCollectionTimesArray = [];
-                var gcChartsDiv = document.getElementById('gc-charts');
-                for(var i = 0; i < gcCollectionCounts.length; ++i) {
-                    gcCollectionCountsArray.push([]);
-                    gcCollectionTimesArray.push([]);
-                    var gcCollectionCountDiv = document.createElement('div');
-                    gcCollectionCountDiv.id = 'gc-collection-count-' + i;
-                    gcCollectionCountDiv.style = "jqplot-target time-chart";
-                    gcChartsDiv.appendChild(gcCollectionCountDiv);
-                    var gcCollectionTimeDiv = document.createElement('div');
-                    gcCollectionTimeDiv.id = 'gc-collection-time-' + i;
-                    gcChartsDiv.appendChild(gcCollectionTimeDiv);
-                }
-                var rrdPtr = result['rrd-ptr'];
-                for(var i = 0; i < sysLoad.length; ++i) {
-                    sysLoadArray.push([i, sysLoad[rrdPtr]]);
-                    heapUsageInitSizesArray.push([i, heapUsageInitSizes[rrdPtr] / (1024 * 1024)]);
-                    heapUsageUsedSizesArray.push([i, heapUsageUsedSizes[rrdPtr] / (1024 * 1024)]);
-                    heapUsageCommittedSizesArray.push([i, heapUsageCommittedSizes[rrdPtr] / (1024 * 1024)]);
-                    heapUsageMaxSizesArray.push([i, heapUsageMaxSizes[rrdPtr] / (1024 * 1024)]);
-                    nonheapUsageInitSizesArray.push([i, nonheapUsageInitSizes[rrdPtr] / (1024 * 1024)]);
-                    nonheapUsageUsedSizesArray.push([i, nonheapUsageUsedSizes[rrdPtr] / (1024 * 1024)]);
-                    nonheapUsageCommittedSizesArray.push([i, nonheapUsageCommittedSizes[rrdPtr] / (1024 * 1024)]);
-                    nonheapUsageMaxSizesArray.push([i, nonheapUsageMaxSizes[rrdPtr] / (1024 * 1024)]);
-                    threadCountsArray.push([i, threadCounts[rrdPtr]]);
-                    peakThreadCountsArray.push([i, peakThreadCounts[rrdPtr]]);
-                    for(var j = 0; j < gcCollectionCounts.length; ++j) {
-                        gcCollectionCountsArray[j].push([i, gcCollectionCounts[j][rrdPtr]]);
-                    }
-                    for(var j = 0; j < gcCollectionTimes.length; ++j) {
-                        gcCollectionTimesArray[j].push([i, gcCollectionTimes[j][rrdPtr]]);
-                    }
-                    rrdPtr = (rrdPtr + 1) % sysLoad.length;
-                }
-                $('#system-load-chart').empty();
-                $.jqplot('system-load-chart', [sysLoadArray], {
-                    title: 'System Load',
-                    axes: {
-                        xaxis: {
-                            label: 'Time',
-                            tickOptions: {
-                                formatString:'%d'
-                            }
-                        },
-                        yaxis: {
-                            label: 'System Load',
-                            tickOptions:{
-                                formatString:'%.2f'
-                            }
-                        }
-                    },
-                    highlighter: {
-                        show: true,
-                        sizeAdjust: 7.5
-                    },
-                    cursor: {
-                        show: false
-                    }
-                });
-                var gcNames = result['gc-names'];
-                for(var i = 0; i < gcCollectionCounts.length; ++i) {
-                    $('#gc-collection-count-' + i).addClass("jqplot-target time-chart");
-                    $.jqplot('gc-collection-count-' + i, [gcCollectionCountsArray[i]], {
-                        title: 'GC Collection Counts(' + gcNames[i] + ')',
-                        axes: {
-                            xaxis: {
-                                label: 'Time',
-                                tickOptions: {
-                                    formatString:'%d'
-                                }
-                            },
-                            yaxis: {
-                                label: 'Collection Counts',
-                                tickOptions:{
-                                    formatString:'%d'
-                                }
-                            }
-                        },
-                        highlighter: {
-                            show: true,
-                            sizeAdjust: 7.5
-                        },
-                        cursor: {
-                            show: false
-                        }
-                    });
-                    $('#gc-collection-time-' + i).addClass("jqplot-target time-chart");
-                    $.jqplot('gc-collection-time-' + i, [gcCollectionTimesArray[i]], {
-                        title: 'GC Collection Times(' + gcNames[i] + ')',
-                        axes: {
-                            xaxis: {
-                                label: 'Time',
-                                tickOptions: {
-                                    formatString:'%d'
-                                }
-                            },
-                            yaxis: {
-                                label: 'Collection Times',
-                                tickOptions:{
-                                    formatString:'%d'
-                                }
-                            }
-                        },
-                        highlighter: {
-                            show: true,
-                            sizeAdjust: 7.5
-                        },
-                        cursor: {
-                            show: false
-                        }
-                    });
-                }
-                $('#heap-usage-chart').empty();
-                $.jqplot('heap-usage-chart', [heapUsageInitSizesArray, heapUsageUsedSizesArray, heapUsageCommittedSizesArray, heapUsageMaxSizesArray], {
-                    title: 'Heap Usage',
-                    series: [ 
-                        {
-                            lineWidth: 2, 
-                            markerOptions: { style:'dimaond' }
-                        }, 
-                        {
-                            showLine:false, 
-                            markerOptions: { size: 7, style:"x" }
-                        },
-                        { 
-                            markerOptions: { style:"circle" }
-                        }, 
-                        {
-                            lineWidth:5, 
-                            markerOptions: { style:"filledSquare", size:10 }
-                        }
-                    ],
-                    axes: {
-                        xaxis: {
-                            label: 'Time',
-                            tickOptions: {
-                                formatString:'%d'
-                            }
-                        },
-                        yaxis: {
-                            label: 'Memory Size',
-                            tickOptions:{
-                                formatString:'%.2f'
-                            }
-                        }
-                    },
-                    highlighter: {
-                        show: true,
-                        sizeAdjust: 7.5
-                    },
-                    cursor: {
-                        show: false
-                    }
-                });
-                $('#nonheap-usage-chart').empty();
-                $.jqplot('nonheap-usage-chart', [nonheapUsageInitSizesArray, nonheapUsageUsedSizesArray, nonheapUsageCommittedSizesArray, nonheapUsageMaxSizesArray], {
-                    title: 'Non Heap Usage',
-                    series: [ 
-                        {
-                            lineWidth: 2, 
-                            markerOptions: { style:'dimaond' }
-                        }, 
-                        {
-                            showLine:false, 
-                            markerOptions: { size: 7, style:"x" }
-                        },
-                        { 
-                            markerOptions: { style:"circle" }
-                        }, 
-                        {
-                            lineWidth:5, 
-                            markerOptions: { style:"filledSquare", size:10 }
-                        }
-                    ],
-                    axes: {
-                        xaxis: {
-                            label: 'Time',
-                            tickOptions: {
-                                formatString:'%d'
-                            }
-                        },
-                        yaxis: {
-                            label: 'Memory Size',
-                            tickOptions:{
-                                formatString:'%.2f'
-                            }
-                        }
-                    },
-                    highlighter: {
-                        show: true,
-                        sizeAdjust: 7.5
-                    },
-                    cursor: {
-                        show: false
-                    }
-                });
-                $('#thread-chart').empty();
-                $.jqplot('thread-chart', [threadCountsArray, peakThreadCountsArray], {
-                    title: 'Thread Counts',
-                    series: [ 
-                        {
-                            markerOptions: { style:'dimaond' }
-                        }, 
-                        {
-                            markerOptions: { style:"x" }
-                        }
-                    ],
-                    axes: {
-                        xaxis: {
-                            label: 'Time',
-                            tickOptions: {
-                                formatString:'%d'
-                            }
-                        },
-                        yaxis: {
-                            label: 'Threads',
-                            tickOptions:{
-                                formatString:'%d'
-                            }
-                        }
-                    },
-                    highlighter: {
-                        show: true,
-                        sizeAdjust: 7.5
-                    },
-                    cursor: {
-                        show: false
-                    }
-                });
-            });
-        });
-    </script>
+    <script src="/static/javascript/adminconsole/NodeDetailsPage.js" type="text/javascript"></script>
 </wicket:extend>
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/adminconsole/NodeDetailsPage.js b/hyracks-control-cc/src/main/resources/static/javascript/adminconsole/NodeDetailsPage.js
new file mode 100644
index 0000000..c97ec94
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/adminconsole/NodeDetailsPage.js
@@ -0,0 +1,146 @@
+$(function() {
+    var options = {
+        lines : {
+            show : true
+        },
+        points : {
+            show : false
+        },
+        xaxis : {
+            tickDecimals : 0,
+            tickSize : 0
+        }
+    };
+
+    function onDataReceived(data) {
+        var result = data.result;
+        var sysLoad = result['system-load-averages'];
+        var heapUsageInitSizes = result['heap-init-sizes'];
+        var heapUsageUsedSizes = result['heap-used-sizes'];
+        var heapUsageCommittedSizes = result['heap-committed-sizes'];
+        var heapUsageMaxSizes = result['heap-max-sizes'];
+        var nonheapUsageInitSizes = result['nonheap-init-sizes'];
+        var nonheapUsageUsedSizes = result['nonheap-used-sizes'];
+        var nonheapUsageCommittedSizes = result['nonheap-committed-sizes'];
+        var nonheapUsageMaxSizes = result['nonheap-max-sizes'];
+        var threadCounts = result['thread-counts'];
+        var peakThreadCounts = result['peak-thread-counts'];
+        var gcCollectionCounts = result['gc-collection-counts'];
+        var gcCollectionTimes = result['gc-collection-times'];
+        var sysLoadArray = [];
+        var heapUsageInitSizesArray = [];
+        var heapUsageUsedSizesArray = [];
+        var heapUsageCommittedSizesArray = [];
+        var heapUsageMaxSizesArray = [];
+        var nonheapUsageInitSizesArray = [];
+        var nonheapUsageUsedSizesArray = [];
+        var nonheapUsageCommittedSizesArray = [];
+        var nonheapUsageMaxSizesArray = [];
+        var threadCountsArray = [];
+        var peakThreadCountsArray = [];
+        var gcCollectionCountsArray = [];
+        var gcCollectionTimesArray = [];
+        var gcChartsDiv = document.getElementById('gc-charts');
+        for ( var i = 0; i < gcCollectionCounts.length; ++i) {
+            gcCollectionCountsArray.push([]);
+            gcCollectionTimesArray.push([]);
+            var gcCollectionCountDiv = document.createElement('div');
+            gcCollectionCountDiv.id = 'gc-collection-count-' + i;
+            gcCollectionCountDiv.style = "jqplot-target time-chart";
+            gcChartsDiv.appendChild(gcCollectionCountDiv);
+            var gcCollectionTimeDiv = document.createElement('div');
+            gcCollectionTimeDiv.id = 'gc-collection-time-' + i;
+            gcChartsDiv.appendChild(gcCollectionTimeDiv);
+        }
+        var rrdPtr = result['rrd-ptr'];
+        for ( var i = 0; i < sysLoad.length; ++i) {
+            sysLoadArray.push([ i, sysLoad[rrdPtr] ]);
+            heapUsageInitSizesArray.push([ i, heapUsageInitSizes[rrdPtr] / (1024 * 1024) ]);
+            heapUsageUsedSizesArray.push([ i, heapUsageUsedSizes[rrdPtr] / (1024 * 1024) ]);
+            heapUsageCommittedSizesArray.push([ i, heapUsageCommittedSizes[rrdPtr] / (1024 * 1024) ]);
+            heapUsageMaxSizesArray.push([ i, heapUsageMaxSizes[rrdPtr] / (1024 * 1024) ]);
+            nonheapUsageInitSizesArray.push([ i, nonheapUsageInitSizes[rrdPtr] / (1024 * 1024) ]);
+            nonheapUsageUsedSizesArray.push([ i, nonheapUsageUsedSizes[rrdPtr] / (1024 * 1024) ]);
+            nonheapUsageCommittedSizesArray.push([ i, nonheapUsageCommittedSizes[rrdPtr] / (1024 * 1024) ]);
+            nonheapUsageMaxSizesArray.push([ i, nonheapUsageMaxSizes[rrdPtr] / (1024 * 1024) ]);
+            threadCountsArray.push([ i, threadCounts[rrdPtr] ]);
+            peakThreadCountsArray.push([ i, peakThreadCounts[rrdPtr] ]);
+            for ( var j = 0; j < gcCollectionCounts.length; ++j) {
+                gcCollectionCountsArray[j].push([ i, gcCollectionCounts[j][rrdPtr] ]);
+            }
+            for ( var j = 0; j < gcCollectionTimes.length; ++j) {
+                gcCollectionTimesArray[j].push([ i, gcCollectionTimes[j][rrdPtr] ]);
+            }
+            rrdPtr = (rrdPtr + 1) % sysLoad.length;
+        }
+
+        $.plot($('#system-load-chart'), [ {
+            label : 'System Load',
+            data : sysLoadArray
+        } ], options);
+
+        var gcNames = result['gc-names'];
+        for ( var i = 0; i < gcCollectionCounts.length; ++i) {
+            $('#gc-collection-count-' + i).addClass("time-chart");
+            $.plot($('#gc-collection-count-' + i), [ {
+                label : gcNames[i] + ' Collection Count',
+                data : gcCollectionCountsArray[i]
+            } ], options);
+
+            $('#gc-collection-time-' + i).addClass("time-chart");
+            $.plot($('#gc-collection-time-' + i), [ {
+                label : gcNames[i] + ' Collection Time (ms)',
+                data : gcCollectionTimesArray[i]
+            } ], options);
+        }
+
+        $.plot($('#heap-usage-chart'), [ {
+            label : 'Heap Usage Initial Size (MB)',
+            data : heapUsageInitSizesArray
+        }, {
+            label : 'Heap Usage Used Size (MB)',
+            data : heapUsageUsedSizesArray
+        }, {
+            label : 'Heap Usage Committed Size (MB)',
+            data : heapUsageCommittedSizesArray
+        }, {
+            label : 'Heap Usage Max Size (MB)',
+            data : heapUsageMaxSizesArray
+        } ], options);
+
+        $.plot($('#nonheap-usage-chart'), [ {
+            label : 'Non-Heap Usage Initial Size (MB)',
+            data : nonheapUsageInitSizesArray
+        }, {
+            label : 'Non-Heap Usage Used Size (MB)',
+            data : nonheapUsageUsedSizesArray
+        }, {
+            label : 'Non-Heap Usage Committed Size (MB)',
+            data : nonheapUsageCommittedSizesArray
+        }, {
+            label : 'Non-Heap Usage Max Size (MB)',
+            data : nonheapUsageMaxSizesArray
+        } ], options);
+
+        $.plot($('#thread-chart'), [ {
+            label : 'Thread Count',
+            data : threadCountsArray
+        }, {
+            label : 'Peak Thread Count',
+            data : peakThreadCountsArray
+        } ], options);
+    }
+
+    function fetchData() {
+        $.ajax({
+            url : '/rest/nodes/' + $.getURLParam('node-id'),
+            method : 'GET',
+            dataType : 'json',
+            success : onDataReceived
+        });
+
+        setTimeout(fetchData, 10000);
+    }
+
+    fetchData();
+});
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/excanvas.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/excanvas.min.js
new file mode 100644
index 0000000..12c74f7
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/excanvas.min.js
@@ -0,0 +1 @@
+if(!document.createElement("canvas").getContext){(function(){var z=Math;var K=z.round;var J=z.sin;var U=z.cos;var b=z.abs;var k=z.sqrt;var D=10;var F=D/2;function T(){return this.context_||(this.context_=new W(this))}var O=Array.prototype.slice;function G(i,j,m){var Z=O.call(arguments,2);return function(){return i.apply(j,Z.concat(O.call(arguments)))}}function AD(Z){return String(Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function r(i){if(!i.namespaces.g_vml_){i.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML")}if(!i.namespaces.g_o_){i.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML")}if(!i.styleSheets.ex_canvas_){var Z=i.createStyleSheet();Z.owningElement.id="ex_canvas_";Z.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}"}}r(document);var E={init:function(Z){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var i=Z||document;i.createElement("canvas");i.attachEvent("onreadystatechange",G(this.init_,this,i))}},init_:function(m){var j=m.getElementsByTagName("canvas");for(var Z=0;Z<j.length;Z++){this.initElement(j[Z])}},initElement:function(i){if(!i.getContext){i.getContext=T;r(i.ownerDocument);i.innerHTML="";i.attachEvent("onpropertychange",S);i.attachEvent("onresize",w);var Z=i.attributes;if(Z.width&&Z.width.specified){i.style.width=Z.width.nodeValue+"px"}else{i.width=i.clientWidth}if(Z.height&&Z.height.specified){i.style.height=Z.height.nodeValue+"px"}else{i.height=i.clientHeight}}return i}};function S(i){var Z=i.srcElement;switch(i.propertyName){case"width":Z.getContext().clearRect();Z.style.width=Z.attributes.width.nodeValue+"px";Z.firstChild.style.width=Z.clientWidth+"px";break;case"height":Z.getContext().clearRect();Z.style.height=Z.attributes.height.nodeValue+"px";Z.firstChild.style.height=Z.clientHeight+"px";break}}function w(i){var Z=i.srcElement;if(Z.firstChild){Z.firstChild.style.width=Z.clientWidth+"px";Z.firstChild.style.height=Z.clientHeight+"px"}}E.init();var I=[];for(var AC=0;AC<16;AC++){for(var AB=0;AB<16;AB++){I[AC*16+AB]=AC.toString(16)+AB.toString(16)}}function V(){return[[1,0,0],[0,1,0],[0,0,1]]}function d(m,j){var i=V();for(var Z=0;Z<3;Z++){for(var AF=0;AF<3;AF++){var p=0;for(var AE=0;AE<3;AE++){p+=m[Z][AE]*j[AE][AF]}i[Z][AF]=p}}return i}function Q(i,Z){Z.fillStyle=i.fillStyle;Z.lineCap=i.lineCap;Z.lineJoin=i.lineJoin;Z.lineWidth=i.lineWidth;Z.miterLimit=i.miterLimit;Z.shadowBlur=i.shadowBlur;Z.shadowColor=i.shadowColor;Z.shadowOffsetX=i.shadowOffsetX;Z.shadowOffsetY=i.shadowOffsetY;Z.strokeStyle=i.strokeStyle;Z.globalAlpha=i.globalAlpha;Z.font=i.font;Z.textAlign=i.textAlign;Z.textBaseline=i.textBaseline;Z.arcScaleX_=i.arcScaleX_;Z.arcScaleY_=i.arcScaleY_;Z.lineScale_=i.lineScale_}var B={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",grey:"#808080",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",oldlace:"#FDF5E6",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",whitesmoke:"#F5F5F5",yellowgreen:"#9ACD32"};function g(i){var m=i.indexOf("(",3);var Z=i.indexOf(")",m+1);var j=i.substring(m+1,Z).split(",");if(j.length==4&&i.substr(3,1)=="a"){alpha=Number(j[3])}else{j[3]=1}return j}function C(Z){return parseFloat(Z)/100}function N(i,j,Z){return Math.min(Z,Math.max(j,i))}function c(AF){var j,i,Z;h=parseFloat(AF[0])/360%360;if(h<0){h++}s=N(C(AF[1]),0,1);l=N(C(AF[2]),0,1);if(s==0){j=i=Z=l}else{var m=l<0.5?l*(1+s):l+s-l*s;var AE=2*l-m;j=A(AE,m,h+1/3);i=A(AE,m,h);Z=A(AE,m,h-1/3)}return"#"+I[Math.floor(j*255)]+I[Math.floor(i*255)]+I[Math.floor(Z*255)]}function A(i,Z,j){if(j<0){j++}if(j>1){j--}if(6*j<1){return i+(Z-i)*6*j}else{if(2*j<1){return Z}else{if(3*j<2){return i+(Z-i)*(2/3-j)*6}else{return i}}}}function Y(Z){var AE,p=1;Z=String(Z);if(Z.charAt(0)=="#"){AE=Z}else{if(/^rgb/.test(Z)){var m=g(Z);var AE="#",AF;for(var j=0;j<3;j++){if(m[j].indexOf("%")!=-1){AF=Math.floor(C(m[j])*255)}else{AF=Number(m[j])}AE+=I[N(AF,0,255)]}p=m[3]}else{if(/^hsl/.test(Z)){var m=g(Z);AE=c(m);p=m[3]}else{AE=B[Z]||Z}}}return{color:AE,alpha:p}}var L={style:"normal",variant:"normal",weight:"normal",size:10,family:"sans-serif"};var f={};function X(Z){if(f[Z]){return f[Z]}var m=document.createElement("div");var j=m.style;try{j.font=Z}catch(i){}return f[Z]={style:j.fontStyle||L.style,variant:j.fontVariant||L.variant,weight:j.fontWeight||L.weight,size:j.fontSize||L.size,family:j.fontFamily||L.family}}function P(j,i){var Z={};for(var AF in j){Z[AF]=j[AF]}var AE=parseFloat(i.currentStyle.fontSize),m=parseFloat(j.size);if(typeof j.size=="number"){Z.size=j.size}else{if(j.size.indexOf("px")!=-1){Z.size=m}else{if(j.size.indexOf("em")!=-1){Z.size=AE*m}else{if(j.size.indexOf("%")!=-1){Z.size=(AE/100)*m}else{if(j.size.indexOf("pt")!=-1){Z.size=m/0.75}else{Z.size=AE}}}}}Z.size*=0.981;return Z}function AA(Z){return Z.style+" "+Z.variant+" "+Z.weight+" "+Z.size+"px "+Z.family}function t(Z){switch(Z){case"butt":return"flat";case"round":return"round";case"square":default:return"square"}}function W(i){this.m_=V();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.strokeStyle="#000";this.fillStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=D*1;this.globalAlpha=1;this.font="10px sans-serif";this.textAlign="left";this.textBaseline="alphabetic";this.canvas=i;var Z=i.ownerDocument.createElement("div");Z.style.width=i.clientWidth+"px";Z.style.height=i.clientHeight+"px";Z.style.overflow="hidden";Z.style.position="absolute";i.appendChild(Z);this.element_=Z;this.arcScaleX_=1;this.arcScaleY_=1;this.lineScale_=1}var M=W.prototype;M.clearRect=function(){if(this.textMeasureEl_){this.textMeasureEl_.removeNode(true);this.textMeasureEl_=null}this.element_.innerHTML=""};M.beginPath=function(){this.currentPath_=[]};M.moveTo=function(i,Z){var j=this.getCoords_(i,Z);this.currentPath_.push({type:"moveTo",x:j.x,y:j.y});this.currentX_=j.x;this.currentY_=j.y};M.lineTo=function(i,Z){var j=this.getCoords_(i,Z);this.currentPath_.push({type:"lineTo",x:j.x,y:j.y});this.currentX_=j.x;this.currentY_=j.y};M.bezierCurveTo=function(j,i,AI,AH,AG,AE){var Z=this.getCoords_(AG,AE);var AF=this.getCoords_(j,i);var m=this.getCoords_(AI,AH);e(this,AF,m,Z)};function e(Z,m,j,i){Z.currentPath_.push({type:"bezierCurveTo",cp1x:m.x,cp1y:m.y,cp2x:j.x,cp2y:j.y,x:i.x,y:i.y});Z.currentX_=i.x;Z.currentY_=i.y}M.quadraticCurveTo=function(AG,j,i,Z){var AF=this.getCoords_(AG,j);var AE=this.getCoords_(i,Z);var AH={x:this.currentX_+2/3*(AF.x-this.currentX_),y:this.currentY_+2/3*(AF.y-this.currentY_)};var m={x:AH.x+(AE.x-this.currentX_)/3,y:AH.y+(AE.y-this.currentY_)/3};e(this,AH,m,AE)};M.arc=function(AJ,AH,AI,AE,i,j){AI*=D;var AN=j?"at":"wa";var AK=AJ+U(AE)*AI-F;var AM=AH+J(AE)*AI-F;var Z=AJ+U(i)*AI-F;var AL=AH+J(i)*AI-F;if(AK==Z&&!j){AK+=0.125}var m=this.getCoords_(AJ,AH);var AG=this.getCoords_(AK,AM);var AF=this.getCoords_(Z,AL);this.currentPath_.push({type:AN,x:m.x,y:m.y,radius:AI,xStart:AG.x,yStart:AG.y,xEnd:AF.x,yEnd:AF.y})};M.rect=function(j,i,Z,m){this.moveTo(j,i);this.lineTo(j+Z,i);this.lineTo(j+Z,i+m);this.lineTo(j,i+m);this.closePath()};M.strokeRect=function(j,i,Z,m){var p=this.currentPath_;this.beginPath();this.moveTo(j,i);this.lineTo(j+Z,i);this.lineTo(j+Z,i+m);this.lineTo(j,i+m);this.closePath();this.stroke();this.currentPath_=p};M.fillRect=function(j,i,Z,m){var p=this.currentPath_;this.beginPath();this.moveTo(j,i);this.lineTo(j+Z,i);this.lineTo(j+Z,i+m);this.lineTo(j,i+m);this.closePath();this.fill();this.currentPath_=p};M.createLinearGradient=function(i,m,Z,j){var p=new v("gradient");p.x0_=i;p.y0_=m;p.x1_=Z;p.y1_=j;return p};M.createRadialGradient=function(m,AE,j,i,p,Z){var AF=new v("gradientradial");AF.x0_=m;AF.y0_=AE;AF.r0_=j;AF.x1_=i;AF.y1_=p;AF.r1_=Z;return AF};M.drawImage=function(AO,j){var AH,AF,AJ,AV,AM,AK,AQ,AX;var AI=AO.runtimeStyle.width;var AN=AO.runtimeStyle.height;AO.runtimeStyle.width="auto";AO.runtimeStyle.height="auto";var AG=AO.width;var AT=AO.height;AO.runtimeStyle.width=AI;AO.runtimeStyle.height=AN;if(arguments.length==3){AH=arguments[1];AF=arguments[2];AM=AK=0;AQ=AJ=AG;AX=AV=AT}else{if(arguments.length==5){AH=arguments[1];AF=arguments[2];AJ=arguments[3];AV=arguments[4];AM=AK=0;AQ=AG;AX=AT}else{if(arguments.length==9){AM=arguments[1];AK=arguments[2];AQ=arguments[3];AX=arguments[4];AH=arguments[5];AF=arguments[6];AJ=arguments[7];AV=arguments[8]}else{throw Error("Invalid number of arguments")}}}var AW=this.getCoords_(AH,AF);var m=AQ/2;var i=AX/2;var AU=[];var Z=10;var AE=10;AU.push(" <g_vml_:group",' coordsize="',D*Z,",",D*AE,'"',' coordorigin="0,0"',' style="width:',Z,"px;height:",AE,"px;position:absolute;");if(this.m_[0][0]!=1||this.m_[0][1]||this.m_[1][1]!=1||this.m_[1][0]){var p=[];p.push("M11=",this.m_[0][0],",","M12=",this.m_[1][0],",","M21=",this.m_[0][1],",","M22=",this.m_[1][1],",","Dx=",K(AW.x/D),",","Dy=",K(AW.y/D),"");var AS=AW;var AR=this.getCoords_(AH+AJ,AF);var AP=this.getCoords_(AH,AF+AV);var AL=this.getCoords_(AH+AJ,AF+AV);AS.x=z.max(AS.x,AR.x,AP.x,AL.x);AS.y=z.max(AS.y,AR.y,AP.y,AL.y);AU.push("padding:0 ",K(AS.x/D),"px ",K(AS.y/D),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",p.join(""),", sizingmethod='clip');")}else{AU.push("top:",K(AW.y/D),"px;left:",K(AW.x/D),"px;")}AU.push(' ">','<g_vml_:image src="',AO.src,'"',' style="width:',D*AJ,"px;"," height:",D*AV,'px"',' cropleft="',AM/AG,'"',' croptop="',AK/AT,'"',' cropright="',(AG-AM-AQ)/AG,'"',' cropbottom="',(AT-AK-AX)/AT,'"'," />","</g_vml_:group>");this.element_.insertAdjacentHTML("BeforeEnd",AU.join(""))};M.stroke=function(AM){var m=10;var AN=10;var AE=5000;var AG={x:null,y:null};var AL={x:null,y:null};for(var AH=0;AH<this.currentPath_.length;AH+=AE){var AK=[];var AF=false;AK.push("<g_vml_:shape",' filled="',!!AM,'"',' style="position:absolute;width:',m,"px;height:",AN,'px;"',' coordorigin="0,0"',' coordsize="',D*m,",",D*AN,'"',' stroked="',!AM,'"',' path="');var AO=false;for(var AI=AH;AI<Math.min(AH+AE,this.currentPath_.length);AI++){if(AI%AE==0&&AI>0){AK.push(" m ",K(this.currentPath_[AI-1].x),",",K(this.currentPath_[AI-1].y))}var Z=this.currentPath_[AI];var AJ;switch(Z.type){case"moveTo":AJ=Z;AK.push(" m ",K(Z.x),",",K(Z.y));break;case"lineTo":AK.push(" l ",K(Z.x),",",K(Z.y));break;case"close":AK.push(" x ");Z=null;break;case"bezierCurveTo":AK.push(" c ",K(Z.cp1x),",",K(Z.cp1y),",",K(Z.cp2x),",",K(Z.cp2y),",",K(Z.x),",",K(Z.y));break;case"at":case"wa":AK.push(" ",Z.type," ",K(Z.x-this.arcScaleX_*Z.radius),",",K(Z.y-this.arcScaleY_*Z.radius)," ",K(Z.x+this.arcScaleX_*Z.radius),",",K(Z.y+this.arcScaleY_*Z.radius)," ",K(Z.xStart),",",K(Z.yStart)," ",K(Z.xEnd),",",K(Z.yEnd));break}if(Z){if(AG.x==null||Z.x<AG.x){AG.x=Z.x}if(AL.x==null||Z.x>AL.x){AL.x=Z.x}if(AG.y==null||Z.y<AG.y){AG.y=Z.y}if(AL.y==null||Z.y>AL.y){AL.y=Z.y}}}AK.push(' ">');if(!AM){R(this,AK)}else{a(this,AK,AG,AL)}AK.push("</g_vml_:shape>");this.element_.insertAdjacentHTML("beforeEnd",AK.join(""))}};function R(j,AE){var i=Y(j.strokeStyle);var m=i.color;var p=i.alpha*j.globalAlpha;var Z=j.lineScale_*j.lineWidth;if(Z<1){p*=Z}AE.push("<g_vml_:stroke",' opacity="',p,'"',' joinstyle="',j.lineJoin,'"',' miterlimit="',j.miterLimit,'"',' endcap="',t(j.lineCap),'"',' weight="',Z,'px"',' color="',m,'" />')}function a(AO,AG,Ah,AP){var AH=AO.fillStyle;var AY=AO.arcScaleX_;var AX=AO.arcScaleY_;var Z=AP.x-Ah.x;var m=AP.y-Ah.y;if(AH instanceof v){var AL=0;var Ac={x:0,y:0};var AU=0;var AK=1;if(AH.type_=="gradient"){var AJ=AH.x0_/AY;var j=AH.y0_/AX;var AI=AH.x1_/AY;var Aj=AH.y1_/AX;var Ag=AO.getCoords_(AJ,j);var Af=AO.getCoords_(AI,Aj);var AE=Af.x-Ag.x;var p=Af.y-Ag.y;AL=Math.atan2(AE,p)*180/Math.PI;if(AL<0){AL+=360}if(AL<0.000001){AL=0}}else{var Ag=AO.getCoords_(AH.x0_,AH.y0_);Ac={x:(Ag.x-Ah.x)/Z,y:(Ag.y-Ah.y)/m};Z/=AY*D;m/=AX*D;var Aa=z.max(Z,m);AU=2*AH.r0_/Aa;AK=2*AH.r1_/Aa-AU}var AS=AH.colors_;AS.sort(function(Ak,i){return Ak.offset-i.offset});var AN=AS.length;var AR=AS[0].color;var AQ=AS[AN-1].color;var AW=AS[0].alpha*AO.globalAlpha;var AV=AS[AN-1].alpha*AO.globalAlpha;var Ab=[];for(var Ae=0;Ae<AN;Ae++){var AM=AS[Ae];Ab.push(AM.offset*AK+AU+" "+AM.color)}AG.push('<g_vml_:fill type="',AH.type_,'"',' method="none" focus="100%"',' color="',AR,'"',' color2="',AQ,'"',' colors="',Ab.join(","),'"',' opacity="',AV,'"',' g_o_:opacity2="',AW,'"',' angle="',AL,'"',' focusposition="',Ac.x,",",Ac.y,'" />')}else{if(AH instanceof u){if(Z&&m){var AF=-Ah.x;var AZ=-Ah.y;AG.push("<g_vml_:fill",' position="',AF/Z*AY*AY,",",AZ/m*AX*AX,'"',' type="tile"',' src="',AH.src_,'" />')}}else{var Ai=Y(AO.fillStyle);var AT=Ai.color;var Ad=Ai.alpha*AO.globalAlpha;AG.push('<g_vml_:fill color="',AT,'" opacity="',Ad,'" />')}}}M.fill=function(){this.stroke(true)};M.closePath=function(){this.currentPath_.push({type:"close"})};M.getCoords_=function(j,i){var Z=this.m_;return{x:D*(j*Z[0][0]+i*Z[1][0]+Z[2][0])-F,y:D*(j*Z[0][1]+i*Z[1][1]+Z[2][1])-F}};M.save=function(){var Z={};Q(this,Z);this.aStack_.push(Z);this.mStack_.push(this.m_);this.m_=d(V(),this.m_)};M.restore=function(){if(this.aStack_.length){Q(this.aStack_.pop(),this);this.m_=this.mStack_.pop()}};function H(Z){return isFinite(Z[0][0])&&isFinite(Z[0][1])&&isFinite(Z[1][0])&&isFinite(Z[1][1])&&isFinite(Z[2][0])&&isFinite(Z[2][1])}function y(i,Z,j){if(!H(Z)){return }i.m_=Z;if(j){var p=Z[0][0]*Z[1][1]-Z[0][1]*Z[1][0];i.lineScale_=k(b(p))}}M.translate=function(j,i){var Z=[[1,0,0],[0,1,0],[j,i,1]];y(this,d(Z,this.m_),false)};M.rotate=function(i){var m=U(i);var j=J(i);var Z=[[m,j,0],[-j,m,0],[0,0,1]];y(this,d(Z,this.m_),false)};M.scale=function(j,i){this.arcScaleX_*=j;this.arcScaleY_*=i;var Z=[[j,0,0],[0,i,0],[0,0,1]];y(this,d(Z,this.m_),true)};M.transform=function(p,m,AF,AE,i,Z){var j=[[p,m,0],[AF,AE,0],[i,Z,1]];y(this,d(j,this.m_),true)};M.setTransform=function(AE,p,AG,AF,j,i){var Z=[[AE,p,0],[AG,AF,0],[j,i,1]];y(this,Z,true)};M.drawText_=function(AK,AI,AH,AN,AG){var AM=this.m_,AQ=1000,i=0,AP=AQ,AF={x:0,y:0},AE=[];var Z=P(X(this.font),this.element_);var j=AA(Z);var AR=this.element_.currentStyle;var p=this.textAlign.toLowerCase();switch(p){case"left":case"center":case"right":break;case"end":p=AR.direction=="ltr"?"right":"left";break;case"start":p=AR.direction=="rtl"?"right":"left";break;default:p="left"}switch(this.textBaseline){case"hanging":case"top":AF.y=Z.size/1.75;break;case"middle":break;default:case null:case"alphabetic":case"ideographic":case"bottom":AF.y=-Z.size/2.25;break}switch(p){case"right":i=AQ;AP=0.05;break;case"center":i=AP=AQ/2;break}var AO=this.getCoords_(AI+AF.x,AH+AF.y);AE.push('<g_vml_:line from="',-i,' 0" to="',AP,' 0.05" ',' coordsize="100 100" coordorigin="0 0"',' filled="',!AG,'" stroked="',!!AG,'" style="position:absolute;width:1px;height:1px;">');if(AG){R(this,AE)}else{a(this,AE,{x:-i,y:0},{x:AP,y:Z.size})}var AL=AM[0][0].toFixed(3)+","+AM[1][0].toFixed(3)+","+AM[0][1].toFixed(3)+","+AM[1][1].toFixed(3)+",0,0";var AJ=K(AO.x/D)+","+K(AO.y/D);AE.push('<g_vml_:skew on="t" matrix="',AL,'" ',' offset="',AJ,'" origin="',i,' 0" />','<g_vml_:path textpathok="true" />','<g_vml_:textpath on="true" string="',AD(AK),'" style="v-text-align:',p,";font:",AD(j),'" /></g_vml_:line>');this.element_.insertAdjacentHTML("beforeEnd",AE.join(""))};M.fillText=function(j,Z,m,i){this.drawText_(j,Z,m,i,false)};M.strokeText=function(j,Z,m,i){this.drawText_(j,Z,m,i,true)};M.measureText=function(j){if(!this.textMeasureEl_){var Z='<span style="position:absolute;top:-20000px;left:0;padding:0;margin:0;border:none;white-space:pre;"></span>';this.element_.insertAdjacentHTML("beforeEnd",Z);this.textMeasureEl_=this.element_.lastChild}var i=this.element_.ownerDocument;this.textMeasureEl_.innerHTML="";this.textMeasureEl_.style.font=this.font;this.textMeasureEl_.appendChild(i.createTextNode(j));return{width:this.textMeasureEl_.offsetWidth}};M.clip=function(){};M.arcTo=function(){};M.createPattern=function(i,Z){return new u(i,Z)};function v(Z){this.type_=Z;this.x0_=0;this.y0_=0;this.r0_=0;this.x1_=0;this.y1_=0;this.r1_=0;this.colors_=[]}v.prototype.addColorStop=function(i,Z){Z=Y(Z);this.colors_.push({offset:i,color:Z.color,alpha:Z.alpha})};function u(i,Z){q(i);switch(Z){case"repeat":case null:case"":this.repetition_="repeat";break;case"repeat-x":case"repeat-y":case"no-repeat":this.repetition_=Z;break;default:n("SYNTAX_ERR")}this.src_=i.src;this.width_=i.width;this.height_=i.height}function n(Z){throw new o(Z)}function q(Z){if(!Z||Z.nodeType!=1||Z.tagName!="IMG"){n("TYPE_MISMATCH_ERR")}if(Z.readyState!="complete"){n("INVALID_STATE_ERR")}}function o(Z){this.code=this[Z];this.message=Z+": DOM Exception "+this.code}var x=o.prototype=new Error;x.INDEX_SIZE_ERR=1;x.DOMSTRING_SIZE_ERR=2;x.HIERARCHY_REQUEST_ERR=3;x.WRONG_DOCUMENT_ERR=4;x.INVALID_CHARACTER_ERR=5;x.NO_DATA_ALLOWED_ERR=6;x.NO_MODIFICATION_ALLOWED_ERR=7;x.NOT_FOUND_ERR=8;x.NOT_SUPPORTED_ERR=9;x.INUSE_ATTRIBUTE_ERR=10;x.INVALID_STATE_ERR=11;x.SYNTAX_ERR=12;x.INVALID_MODIFICATION_ERR=13;x.NAMESPACE_ERR=14;x.INVALID_ACCESS_ERR=15;x.VALIDATION_ERR=16;x.TYPE_MISMATCH_ERR=17;G_vmlCanvasManager=E;CanvasRenderingContext2D=W;CanvasGradient=v;CanvasPattern=u;DOMException=o})()};
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.colorhelpers.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.colorhelpers.min.js
new file mode 100644
index 0000000..7f44c57
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.colorhelpers.min.js
@@ -0,0 +1 @@
+(function(b){b.color={};b.color.make=function(f,e,c,d){var h={};h.r=f||0;h.g=e||0;h.b=c||0;h.a=d!=null?d:1;h.add=function(k,j){for(var g=0;g<k.length;++g){h[k.charAt(g)]+=j}return h.normalize()};h.scale=function(k,j){for(var g=0;g<k.length;++g){h[k.charAt(g)]*=j}return h.normalize()};h.toString=function(){if(h.a>=1){return"rgb("+[h.r,h.g,h.b].join(",")+")"}else{return"rgba("+[h.r,h.g,h.b,h.a].join(",")+")"}};h.normalize=function(){function g(j,k,i){return k<j?j:(k>i?i:k)}h.r=g(0,parseInt(h.r),255);h.g=g(0,parseInt(h.g),255);h.b=g(0,parseInt(h.b),255);h.a=g(0,h.a,1);return h};h.clone=function(){return b.color.make(h.r,h.b,h.g,h.a)};return h.normalize()};b.color.extract=function(e,d){var f;do{f=e.css(d).toLowerCase();if(f!=""&&f!="transparent"){break}e=e.parent()}while(!b.nodeName(e.get(0),"body"));if(f=="rgba(0, 0, 0, 0)"){f="transparent"}return b.color.parse(f)};b.color.parse=function(f){var e,c=b.color.make;if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return c(parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10))}if(e=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(f)){return c(parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),parseFloat(e[4]))}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return c(parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55)}if(e=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(f)){return c(parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55,parseFloat(e[4]))}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return c(parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16))}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return c(parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16))}var d=b.trim(f).toLowerCase();if(d=="transparent"){return c(255,255,255,0)}else{e=a[d]||[0,0,0];return c(e[0],e[1],e[2])}};var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.crosshair.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.crosshair.min.js
new file mode 100644
index 0000000..ccaf240
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.crosshair.min.js
@@ -0,0 +1 @@
+(function(b){var a={crosshair:{mode:null,color:"rgba(170, 0, 0, 0.80)",lineWidth:1}};function c(h){var j={x:-1,y:-1,locked:false};h.setCrosshair=function e(l){if(!l){j.x=-1}else{var k=h.p2c(l);j.x=Math.max(0,Math.min(k.left,h.width()));j.y=Math.max(0,Math.min(k.top,h.height()))}h.triggerRedrawOverlay()};h.clearCrosshair=h.setCrosshair;h.lockCrosshair=function f(k){if(k){h.setCrosshair(k)}j.locked=true};h.unlockCrosshair=function g(){j.locked=false};function d(k){if(j.locked){return}if(j.x!=-1){j.x=-1;h.triggerRedrawOverlay()}}function i(k){if(j.locked){return}if(h.getSelection&&h.getSelection()){j.x=-1;return}var l=h.offset();j.x=Math.max(0,Math.min(k.pageX-l.left,h.width()));j.y=Math.max(0,Math.min(k.pageY-l.top,h.height()));h.triggerRedrawOverlay()}h.hooks.bindEvents.push(function(l,k){if(!l.getOptions().crosshair.mode){return}k.mouseout(d);k.mousemove(i)});h.hooks.drawOverlay.push(function(m,k){var n=m.getOptions().crosshair;if(!n.mode){return}var l=m.getPlotOffset();k.save();k.translate(l.left,l.top);if(j.x!=-1){k.strokeStyle=n.color;k.lineWidth=n.lineWidth;k.lineJoin="round";k.beginPath();if(n.mode.indexOf("x")!=-1){k.moveTo(j.x,0);k.lineTo(j.x,m.height())}if(n.mode.indexOf("y")!=-1){k.moveTo(0,j.y);k.lineTo(m.width(),j.y)}k.stroke()}k.restore()});h.hooks.shutdown.push(function(l,k){k.unbind("mouseout",d);k.unbind("mousemove",i)})}b.plot.plugins.push({init:c,options:a,name:"crosshair",version:"1.0"})})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.fillbetween.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.fillbetween.min.js
new file mode 100644
index 0000000..47f3dfb
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.fillbetween.min.js
@@ -0,0 +1 @@
+(function(b){var a={series:{fillBetween:null}};function c(f){function d(j,h){var g;for(g=0;g<h.length;++g){if(h[g].id==j.fillBetween){return h[g]}}if(typeof j.fillBetween=="number"){g=j.fillBetween;if(g<0||g>=h.length){return null}return h[g]}return null}function e(B,u,g){if(u.fillBetween==null){return}var p=d(u,B.getData());if(!p){return}var y=g.pointsize,E=g.points,h=p.datapoints.pointsize,x=p.datapoints.points,r=[],w,v,k,G,F,q,t=u.lines.show,o=y>2&&g.format[2].y,n=t&&u.lines.steps,D=true,C=0,A=0,z;while(true){if(C>=E.length){break}z=r.length;if(E[C]==null){for(m=0;m<y;++m){r.push(E[C+m])}C+=y}else{if(A>=x.length){if(!t){for(m=0;m<y;++m){r.push(E[C+m])}}C+=y}else{if(x[A]==null){for(m=0;m<y;++m){r.push(null)}D=true;A+=h}else{w=E[C];v=E[C+1];G=x[A];F=x[A+1];q=0;if(w==G){for(m=0;m<y;++m){r.push(E[C+m])}q=F;C+=y;A+=h}else{if(w>G){if(t&&C>0&&E[C-y]!=null){k=v+(E[C-y+1]-v)*(G-w)/(E[C-y]-w);r.push(G);r.push(k);for(m=2;m<y;++m){r.push(E[C+m])}q=F}A+=h}else{if(D&&t){C+=y;continue}for(m=0;m<y;++m){r.push(E[C+m])}if(t&&A>0&&x[A-h]!=null){q=F+(x[A-h+1]-F)*(w-G)/(x[A-h]-G)}C+=y}}D=false;if(z!=r.length&&o){r[z+2]=q}}}}if(n&&z!=r.length&&z>0&&r[z]!=null&&r[z]!=r[z-y]&&r[z+1]!=r[z-y+1]){for(m=0;m<y;++m){r[z+y+m]=r[z+m]}r[z+1]=r[z-y+1]}}g.points=r}f.hooks.processDatapoints.push(e)}b.plot.plugins.push({init:c,options:a,name:"fillbetween",version:"1.0"})})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.image.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.image.min.js
new file mode 100644
index 0000000..9480c1e
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.image.min.js
@@ -0,0 +1 @@
+(function(c){var a={series:{images:{show:false,alpha:1,anchor:"corner"}}};c.plot.image={};c.plot.image.loadDataImages=function(g,f,k){var j=[],h=[];var i=f.series.images.show;c.each(g,function(l,m){if(!(i||m.images.show)){return}if(m.data){m=m.data}c.each(m,function(n,o){if(typeof o[0]=="string"){j.push(o[0]);h.push(o)}})});c.plot.image.load(j,function(l){c.each(h,function(n,o){var m=o[0];if(l[m]){o[0]=l[m]}});k()})};c.plot.image.load=function(h,i){var g=h.length,f={};if(g==0){i({})}c.each(h,function(k,j){var l=function(){--g;f[j]=this;if(g==0){i(f)}};c("<img />").load(l).error(l).attr("src",j)})};function d(q,o,l){var m=q.getPlotOffset();if(!l.images||!l.images.show){return}var r=l.datapoints.points,n=l.datapoints.pointsize;for(var t=0;t<r.length;t+=n){var y=r[t],w=r[t+1],g=r[t+2],v=r[t+3],f=r[t+4],h=l.xaxis,u=l.yaxis,x;if(!y||y.width<=0||y.height<=0){continue}if(w>v){x=v;v=w;w=x}if(g>f){x=f;f=g;g=x}if(l.images.anchor=="center"){x=0.5*(v-w)/(y.width-1);w-=x;v+=x;x=0.5*(f-g)/(y.height-1);g-=x;f+=x}if(w==v||g==f||w>=h.max||v<=h.min||g>=u.max||f<=u.min){continue}var k=0,s=0,j=y.width,p=y.height;if(w<h.min){k+=(j-k)*(h.min-w)/(v-w);w=h.min}if(v>h.max){j+=(j-k)*(h.max-v)/(v-w);v=h.max}if(g<u.min){p+=(s-p)*(u.min-g)/(f-g);g=u.min}if(f>u.max){s+=(s-p)*(u.max-f)/(f-g);f=u.max}w=h.p2c(w);v=h.p2c(v);g=u.p2c(g);f=u.p2c(f);if(w>v){x=v;v=w;w=x}if(g>f){x=f;f=g;g=x}x=o.globalAlpha;o.globalAlpha*=l.images.alpha;o.drawImage(y,k,s,j-k,p-s,w+m.left,g+m.top,v-w,f-g);o.globalAlpha=x}}function b(i,f,g,h){if(!f.images.show){return}h.format=[{required:true},{x:true,number:true,required:true},{y:true,number:true,required:true},{x:true,number:true,required:true},{y:true,number:true,required:true}]}function e(f){f.hooks.processRawData.push(b);f.hooks.drawSeries.push(d)}c.plot.plugins.push({init:e,options:a,name:"image",version:"1.1"})})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.min.js
new file mode 100644
index 0000000..4467fc5
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.min.js
@@ -0,0 +1,6 @@
+/* Javascript plotting library for jQuery, v. 0.7.
+ *
+ * Released under the MIT license by IOLA, December 2007.
+ *
+ */
+(function(b){b.color={};b.color.make=function(d,e,g,f){var c={};c.r=d||0;c.g=e||0;c.b=g||0;c.a=f!=null?f:1;c.add=function(h,j){for(var k=0;k<h.length;++k){c[h.charAt(k)]+=j}return c.normalize()};c.scale=function(h,j){for(var k=0;k<h.length;++k){c[h.charAt(k)]*=j}return c.normalize()};c.toString=function(){if(c.a>=1){return"rgb("+[c.r,c.g,c.b].join(",")+")"}else{return"rgba("+[c.r,c.g,c.b,c.a].join(",")+")"}};c.normalize=function(){function h(k,j,l){return j<k?k:(j>l?l:j)}c.r=h(0,parseInt(c.r),255);c.g=h(0,parseInt(c.g),255);c.b=h(0,parseInt(c.b),255);c.a=h(0,c.a,1);return c};c.clone=function(){return b.color.make(c.r,c.b,c.g,c.a)};return c.normalize()};b.color.extract=function(d,e){var c;do{c=d.css(e).toLowerCase();if(c!=""&&c!="transparent"){break}d=d.parent()}while(!b.nodeName(d.get(0),"body"));if(c=="rgba(0, 0, 0, 0)"){c="transparent"}return b.color.parse(c)};b.color.parse=function(c){var d,f=b.color.make;if(d=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c)){return f(parseInt(d[1],10),parseInt(d[2],10),parseInt(d[3],10))}if(d=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(c)){return f(parseInt(d[1],10),parseInt(d[2],10),parseInt(d[3],10),parseFloat(d[4]))}if(d=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c)){return f(parseFloat(d[1])*2.55,parseFloat(d[2])*2.55,parseFloat(d[3])*2.55)}if(d=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(c)){return f(parseFloat(d[1])*2.55,parseFloat(d[2])*2.55,parseFloat(d[3])*2.55,parseFloat(d[4]))}if(d=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c)){return f(parseInt(d[1],16),parseInt(d[2],16),parseInt(d[3],16))}if(d=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c)){return f(parseInt(d[1]+d[1],16),parseInt(d[2]+d[2],16),parseInt(d[3]+d[3],16))}var e=b.trim(c).toLowerCase();if(e=="transparent"){return f(255,255,255,0)}else{d=a[e]||[0,0,0];return f(d[0],d[1],d[2])}};var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);(function(c){function b(av,ai,J,af){var Q=[],O={colors:["#edc240","#afd8f8","#cb4b4b","#4da74d","#9440ed"],legend:{show:true,noColumns:1,labelFormatter:null,labelBoxBorderColor:"#ccc",container:null,position:"ne",margin:5,backgroundColor:null,backgroundOpacity:0.85},xaxis:{show:null,position:"bottom",mode:null,color:null,tickColor:null,transform:null,inverseTransform:null,min:null,max:null,autoscaleMargin:null,ticks:null,tickFormatter:null,labelWidth:null,labelHeight:null,reserveSpace:null,tickLength:null,alignTicksWithAxis:null,tickDecimals:null,tickSize:null,minTickSize:null,monthNames:null,timeformat:null,twelveHourClock:false},yaxis:{autoscaleMargin:0.02,position:"left"},xaxes:[],yaxes:[],series:{points:{show:false,radius:3,lineWidth:2,fill:true,fillColor:"#ffffff",symbol:"circle"},lines:{lineWidth:2,fill:false,fillColor:null,steps:false},bars:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null,align:"left",horizontal:false},shadowSize:3},grid:{show:true,aboveData:false,color:"#545454",backgroundColor:null,borderColor:null,tickColor:null,labelMargin:5,axisMargin:8,borderWidth:2,minBorderMargin:null,markings:null,markingsColor:"#f4f4f4",markingsLineWidth:2,clickable:false,hoverable:false,autoHighlight:true,mouseActiveRadius:10},hooks:{}},az=null,ad=null,y=null,H=null,A=null,p=[],aw=[],q={left:0,right:0,top:0,bottom:0},G=0,I=0,h=0,w=0,ak={processOptions:[],processRawData:[],processDatapoints:[],drawSeries:[],draw:[],bindEvents:[],drawOverlay:[],shutdown:[]},aq=this;aq.setData=aj;aq.setupGrid=t;aq.draw=W;aq.getPlaceholder=function(){return av};aq.getCanvas=function(){return az};aq.getPlotOffset=function(){return q};aq.width=function(){return h};aq.height=function(){return w};aq.offset=function(){var aB=y.offset();aB.left+=q.left;aB.top+=q.top;return aB};aq.getData=function(){return Q};aq.getAxes=function(){var aC={},aB;c.each(p.concat(aw),function(aD,aE){if(aE){aC[aE.direction+(aE.n!=1?aE.n:"")+"axis"]=aE}});return aC};aq.getXAxes=function(){return p};aq.getYAxes=function(){return aw};aq.c2p=C;aq.p2c=ar;aq.getOptions=function(){return O};aq.highlight=x;aq.unhighlight=T;aq.triggerRedrawOverlay=f;aq.pointOffset=function(aB){return{left:parseInt(p[aA(aB,"x")-1].p2c(+aB.x)+q.left),top:parseInt(aw[aA(aB,"y")-1].p2c(+aB.y)+q.top)}};aq.shutdown=ag;aq.resize=function(){B();g(az);g(ad)};aq.hooks=ak;F(aq);Z(J);X();aj(ai);t();W();ah();function an(aD,aB){aB=[aq].concat(aB);for(var aC=0;aC<aD.length;++aC){aD[aC].apply(this,aB)}}function F(){for(var aB=0;aB<af.length;++aB){var aC=af[aB];aC.init(aq);if(aC.options){c.extend(true,O,aC.options)}}}function Z(aC){var aB;c.extend(true,O,aC);if(O.xaxis.color==null){O.xaxis.color=O.grid.color}if(O.yaxis.color==null){O.yaxis.color=O.grid.color}if(O.xaxis.tickColor==null){O.xaxis.tickColor=O.grid.tickColor}if(O.yaxis.tickColor==null){O.yaxis.tickColor=O.grid.tickColor}if(O.grid.borderColor==null){O.grid.borderColor=O.grid.color}if(O.grid.tickColor==null){O.grid.tickColor=c.color.parse(O.grid.color).scale("a",0.22).toString()}for(aB=0;aB<Math.max(1,O.xaxes.length);++aB){O.xaxes[aB]=c.extend(true,{},O.xaxis,O.xaxes[aB])}for(aB=0;aB<Math.max(1,O.yaxes.length);++aB){O.yaxes[aB]=c.extend(true,{},O.yaxis,O.yaxes[aB])}if(O.xaxis.noTicks&&O.xaxis.ticks==null){O.xaxis.ticks=O.xaxis.noTicks}if(O.yaxis.noTicks&&O.yaxis.ticks==null){O.yaxis.ticks=O.yaxis.noTicks}if(O.x2axis){O.xaxes[1]=c.extend(true,{},O.xaxis,O.x2axis);O.xaxes[1].position="top"}if(O.y2axis){O.yaxes[1]=c.extend(true,{},O.yaxis,O.y2axis);O.yaxes[1].position="right"}if(O.grid.coloredAreas){O.grid.markings=O.grid.coloredAreas}if(O.grid.coloredAreasColor){O.grid.markingsColor=O.grid.coloredAreasColor}if(O.lines){c.extend(true,O.series.lines,O.lines)}if(O.points){c.extend(true,O.series.points,O.points)}if(O.bars){c.extend(true,O.series.bars,O.bars)}if(O.shadowSize!=null){O.series.shadowSize=O.shadowSize}for(aB=0;aB<O.xaxes.length;++aB){V(p,aB+1).options=O.xaxes[aB]}for(aB=0;aB<O.yaxes.length;++aB){V(aw,aB+1).options=O.yaxes[aB]}for(var aD in ak){if(O.hooks[aD]&&O.hooks[aD].length){ak[aD]=ak[aD].concat(O.hooks[aD])}}an(ak.processOptions,[O])}function aj(aB){Q=Y(aB);ax();z()}function Y(aE){var aC=[];for(var aB=0;aB<aE.length;++aB){var aD=c.extend(true,{},O.series);if(aE[aB].data!=null){aD.data=aE[aB].data;delete aE[aB].data;c.extend(true,aD,aE[aB]);aE[aB].data=aD.data}else{aD.data=aE[aB]}aC.push(aD)}return aC}function aA(aC,aD){var aB=aC[aD+"axis"];if(typeof aB=="object"){aB=aB.n}if(typeof aB!="number"){aB=1}return aB}function m(){return c.grep(p.concat(aw),function(aB){return aB})}function C(aE){var aC={},aB,aD;for(aB=0;aB<p.length;++aB){aD=p[aB];if(aD&&aD.used){aC["x"+aD.n]=aD.c2p(aE.left)}}for(aB=0;aB<aw.length;++aB){aD=aw[aB];if(aD&&aD.used){aC["y"+aD.n]=aD.c2p(aE.top)}}if(aC.x1!==undefined){aC.x=aC.x1}if(aC.y1!==undefined){aC.y=aC.y1}return aC}function ar(aF){var aD={},aC,aE,aB;for(aC=0;aC<p.length;++aC){aE=p[aC];if(aE&&aE.used){aB="x"+aE.n;if(aF[aB]==null&&aE.n==1){aB="x"}if(aF[aB]!=null){aD.left=aE.p2c(aF[aB]);break}}}for(aC=0;aC<aw.length;++aC){aE=aw[aC];if(aE&&aE.used){aB="y"+aE.n;if(aF[aB]==null&&aE.n==1){aB="y"}if(aF[aB]!=null){aD.top=aE.p2c(aF[aB]);break}}}return aD}function V(aC,aB){if(!aC[aB-1]){aC[aB-1]={n:aB,direction:aC==p?"x":"y",options:c.extend(true,{},aC==p?O.xaxis:O.yaxis)}}return aC[aB-1]}function ax(){var aG;var aM=Q.length,aB=[],aE=[];for(aG=0;aG<Q.length;++aG){var aJ=Q[aG].color;if(aJ!=null){--aM;if(typeof aJ=="number"){aE.push(aJ)}else{aB.push(c.color.parse(Q[aG].color))}}}for(aG=0;aG<aE.length;++aG){aM=Math.max(aM,aE[aG]+1)}var aC=[],aF=0;aG=0;while(aC.length<aM){var aI;if(O.colors.length==aG){aI=c.color.make(100,100,100)}else{aI=c.color.parse(O.colors[aG])}var aD=aF%2==1?-1:1;aI.scale("rgb",1+aD*Math.ceil(aF/2)*0.2);aC.push(aI);++aG;if(aG>=O.colors.length){aG=0;++aF}}var aH=0,aN;for(aG=0;aG<Q.length;++aG){aN=Q[aG];if(aN.color==null){aN.color=aC[aH].toString();++aH}else{if(typeof aN.color=="number"){aN.color=aC[aN.color].toString()}}if(aN.lines.show==null){var aL,aK=true;for(aL in aN){if(aN[aL]&&aN[aL].show){aK=false;break}}if(aK){aN.lines.show=true}}aN.xaxis=V(p,aA(aN,"x"));aN.yaxis=V(aw,aA(aN,"y"))}}function z(){var aO=Number.POSITIVE_INFINITY,aI=Number.NEGATIVE_INFINITY,aB=Number.MAX_VALUE,aU,aS,aR,aN,aD,aJ,aT,aP,aH,aG,aC,a0,aX,aL;function aF(a3,a2,a1){if(a2<a3.datamin&&a2!=-aB){a3.datamin=a2}if(a1>a3.datamax&&a1!=aB){a3.datamax=a1}}c.each(m(),function(a1,a2){a2.datamin=aO;a2.datamax=aI;a2.used=false});for(aU=0;aU<Q.length;++aU){aJ=Q[aU];aJ.datapoints={points:[]};an(ak.processRawData,[aJ,aJ.data,aJ.datapoints])}for(aU=0;aU<Q.length;++aU){aJ=Q[aU];var aZ=aJ.data,aW=aJ.datapoints.format;if(!aW){aW=[];aW.push({x:true,number:true,required:true});aW.push({y:true,number:true,required:true});if(aJ.bars.show||(aJ.lines.show&&aJ.lines.fill)){aW.push({y:true,number:true,required:false,defaultValue:0});if(aJ.bars.horizontal){delete aW[aW.length-1].y;aW[aW.length-1].x=true}}aJ.datapoints.format=aW}if(aJ.datapoints.pointsize!=null){continue}aJ.datapoints.pointsize=aW.length;aP=aJ.datapoints.pointsize;aT=aJ.datapoints.points;insertSteps=aJ.lines.show&&aJ.lines.steps;aJ.xaxis.used=aJ.yaxis.used=true;for(aS=aR=0;aS<aZ.length;++aS,aR+=aP){aL=aZ[aS];var aE=aL==null;if(!aE){for(aN=0;aN<aP;++aN){a0=aL[aN];aX=aW[aN];if(aX){if(aX.number&&a0!=null){a0=+a0;if(isNaN(a0)){a0=null}else{if(a0==Infinity){a0=aB}else{if(a0==-Infinity){a0=-aB}}}}if(a0==null){if(aX.required){aE=true}if(aX.defaultValue!=null){a0=aX.defaultValue}}}aT[aR+aN]=a0}}if(aE){for(aN=0;aN<aP;++aN){a0=aT[aR+aN];if(a0!=null){aX=aW[aN];if(aX.x){aF(aJ.xaxis,a0,a0)}if(aX.y){aF(aJ.yaxis,a0,a0)}}aT[aR+aN]=null}}else{if(insertSteps&&aR>0&&aT[aR-aP]!=null&&aT[aR-aP]!=aT[aR]&&aT[aR-aP+1]!=aT[aR+1]){for(aN=0;aN<aP;++aN){aT[aR+aP+aN]=aT[aR+aN]}aT[aR+1]=aT[aR-aP+1];aR+=aP}}}}for(aU=0;aU<Q.length;++aU){aJ=Q[aU];an(ak.processDatapoints,[aJ,aJ.datapoints])}for(aU=0;aU<Q.length;++aU){aJ=Q[aU];aT=aJ.datapoints.points,aP=aJ.datapoints.pointsize;var aK=aO,aQ=aO,aM=aI,aV=aI;for(aS=0;aS<aT.length;aS+=aP){if(aT[aS]==null){continue}for(aN=0;aN<aP;++aN){a0=aT[aS+aN];aX=aW[aN];if(!aX||a0==aB||a0==-aB){continue}if(aX.x){if(a0<aK){aK=a0}if(a0>aM){aM=a0}}if(aX.y){if(a0<aQ){aQ=a0}if(a0>aV){aV=a0}}}}if(aJ.bars.show){var aY=aJ.bars.align=="left"?0:-aJ.bars.barWidth/2;if(aJ.bars.horizontal){aQ+=aY;aV+=aY+aJ.bars.barWidth}else{aK+=aY;aM+=aY+aJ.bars.barWidth}}aF(aJ.xaxis,aK,aM);aF(aJ.yaxis,aQ,aV)}c.each(m(),function(a1,a2){if(a2.datamin==aO){a2.datamin=null}if(a2.datamax==aI){a2.datamax=null}})}function j(aB,aC){var aD=document.createElement("canvas");aD.className=aC;aD.width=G;aD.height=I;if(!aB){c(aD).css({position:"absolute",left:0,top:0})}c(aD).appendTo(av);if(!aD.getContext){aD=window.G_vmlCanvasManager.initElement(aD)}aD.getContext("2d").save();return aD}function B(){G=av.width();I=av.height();if(G<=0||I<=0){throw"Invalid dimensions for plot, width = "+G+", height = "+I}}function g(aC){if(aC.width!=G){aC.width=G}if(aC.height!=I){aC.height=I}var aB=aC.getContext("2d");aB.restore();aB.save()}function X(){var aC,aB=av.children("canvas.base"),aD=av.children("canvas.overlay");if(aB.length==0||aD==0){av.html("");av.css({padding:0});if(av.css("position")=="static"){av.css("position","relative")}B();az=j(true,"base");ad=j(false,"overlay");aC=false}else{az=aB.get(0);ad=aD.get(0);aC=true}H=az.getContext("2d");A=ad.getContext("2d");y=c([ad,az]);if(aC){av.data("plot").shutdown();aq.resize();A.clearRect(0,0,G,I);y.unbind();av.children().not([az,ad]).remove()}av.data("plot",aq)}function ah(){if(O.grid.hoverable){y.mousemove(aa);y.mouseleave(l)}if(O.grid.clickable){y.click(R)}an(ak.bindEvents,[y])}function ag(){if(M){clearTimeout(M)}y.unbind("mousemove",aa);y.unbind("mouseleave",l);y.unbind("click",R);an(ak.shutdown,[y])}function r(aG){function aC(aH){return aH}var aF,aB,aD=aG.options.transform||aC,aE=aG.options.inverseTransform;if(aG.direction=="x"){aF=aG.scale=h/Math.abs(aD(aG.max)-aD(aG.min));aB=Math.min(aD(aG.max),aD(aG.min))}else{aF=aG.scale=w/Math.abs(aD(aG.max)-aD(aG.min));aF=-aF;aB=Math.max(aD(aG.max),aD(aG.min))}if(aD==aC){aG.p2c=function(aH){return(aH-aB)*aF}}else{aG.p2c=function(aH){return(aD(aH)-aB)*aF}}if(!aE){aG.c2p=function(aH){return aB+aH/aF}}else{aG.c2p=function(aH){return aE(aB+aH/aF)}}}function L(aD){var aB=aD.options,aF,aJ=aD.ticks||[],aI=[],aE,aK=aB.labelWidth,aG=aB.labelHeight,aC;function aH(aM,aL){return c('<div style="position:absolute;top:-10000px;'+aL+'font-size:smaller"><div class="'+aD.direction+"Axis "+aD.direction+aD.n+'Axis">'+aM.join("")+"</div></div>").appendTo(av)}if(aD.direction=="x"){if(aK==null){aK=Math.floor(G/(aJ.length>0?aJ.length:1))}if(aG==null){aI=[];for(aF=0;aF<aJ.length;++aF){aE=aJ[aF].label;if(aE){aI.push('<div class="tickLabel" style="float:left;width:'+aK+'px">'+aE+"</div>")}}if(aI.length>0){aI.push('<div style="clear:left"></div>');aC=aH(aI,"width:10000px;");aG=aC.height();aC.remove()}}}else{if(aK==null||aG==null){for(aF=0;aF<aJ.length;++aF){aE=aJ[aF].label;if(aE){aI.push('<div class="tickLabel">'+aE+"</div>")}}if(aI.length>0){aC=aH(aI,"");if(aK==null){aK=aC.children().width()}if(aG==null){aG=aC.find("div.tickLabel").height()}aC.remove()}}}if(aK==null){aK=0}if(aG==null){aG=0}aD.labelWidth=aK;aD.labelHeight=aG}function au(aD){var aC=aD.labelWidth,aL=aD.labelHeight,aH=aD.options.position,aF=aD.options.tickLength,aG=O.grid.axisMargin,aJ=O.grid.labelMargin,aK=aD.direction=="x"?p:aw,aE;var aB=c.grep(aK,function(aN){return aN&&aN.options.position==aH&&aN.reserveSpace});if(c.inArray(aD,aB)==aB.length-1){aG=0}if(aF==null){aF="full"}var aI=c.grep(aK,function(aN){return aN&&aN.reserveSpace});var aM=c.inArray(aD,aI)==0;if(!aM&&aF=="full"){aF=5}if(!isNaN(+aF)){aJ+=+aF}if(aD.direction=="x"){aL+=aJ;if(aH=="bottom"){q.bottom+=aL+aG;aD.box={top:I-q.bottom,height:aL}}else{aD.box={top:q.top+aG,height:aL};q.top+=aL+aG}}else{aC+=aJ;if(aH=="left"){aD.box={left:q.left+aG,width:aC};q.left+=aC+aG}else{q.right+=aC+aG;aD.box={left:G-q.right,width:aC}}}aD.position=aH;aD.tickLength=aF;aD.box.padding=aJ;aD.innermost=aM}function U(aB){if(aB.direction=="x"){aB.box.left=q.left;aB.box.width=h}else{aB.box.top=q.top;aB.box.height=w}}function t(){var aC,aE=m();c.each(aE,function(aF,aG){aG.show=aG.options.show;if(aG.show==null){aG.show=aG.used}aG.reserveSpace=aG.show||aG.options.reserveSpace;n(aG)});allocatedAxes=c.grep(aE,function(aF){return aF.reserveSpace});q.left=q.right=q.top=q.bottom=0;if(O.grid.show){c.each(allocatedAxes,function(aF,aG){S(aG);P(aG);ap(aG,aG.ticks);L(aG)});for(aC=allocatedAxes.length-1;aC>=0;--aC){au(allocatedAxes[aC])}var aD=O.grid.minBorderMargin;if(aD==null){aD=0;for(aC=0;aC<Q.length;++aC){aD=Math.max(aD,Q[aC].points.radius+Q[aC].points.lineWidth/2)}}for(var aB in q){q[aB]+=O.grid.borderWidth;q[aB]=Math.max(aD,q[aB])}}h=G-q.left-q.right;w=I-q.bottom-q.top;c.each(aE,function(aF,aG){r(aG)});if(O.grid.show){c.each(allocatedAxes,function(aF,aG){U(aG)});k()}o()}function n(aE){var aF=aE.options,aD=+(aF.min!=null?aF.min:aE.datamin),aB=+(aF.max!=null?aF.max:aE.datamax),aH=aB-aD;if(aH==0){var aC=aB==0?1:0.01;if(aF.min==null){aD-=aC}if(aF.max==null||aF.min!=null){aB+=aC}}else{var aG=aF.autoscaleMargin;if(aG!=null){if(aF.min==null){aD-=aH*aG;if(aD<0&&aE.datamin!=null&&aE.datamin>=0){aD=0}}if(aF.max==null){aB+=aH*aG;if(aB>0&&aE.datamax!=null&&aE.datamax<=0){aB=0}}}}aE.min=aD;aE.max=aB}function S(aG){var aM=aG.options;var aH;if(typeof aM.ticks=="number"&&aM.ticks>0){aH=aM.ticks}else{aH=0.3*Math.sqrt(aG.direction=="x"?G:I)}var aT=(aG.max-aG.min)/aH,aO,aB,aN,aR,aS,aQ,aI;if(aM.mode=="time"){var aJ={second:1000,minute:60*1000,hour:60*60*1000,day:24*60*60*1000,month:30*24*60*60*1000,year:365.2425*24*60*60*1000};var aK=[[1,"second"],[2,"second"],[5,"second"],[10,"second"],[30,"second"],[1,"minute"],[2,"minute"],[5,"minute"],[10,"minute"],[30,"minute"],[1,"hour"],[2,"hour"],[4,"hour"],[8,"hour"],[12,"hour"],[1,"day"],[2,"day"],[3,"day"],[0.25,"month"],[0.5,"month"],[1,"month"],[2,"month"],[3,"month"],[6,"month"],[1,"year"]];var aC=0;if(aM.minTickSize!=null){if(typeof aM.tickSize=="number"){aC=aM.tickSize}else{aC=aM.minTickSize[0]*aJ[aM.minTickSize[1]]}}for(var aS=0;aS<aK.length-1;++aS){if(aT<(aK[aS][0]*aJ[aK[aS][1]]+aK[aS+1][0]*aJ[aK[aS+1][1]])/2&&aK[aS][0]*aJ[aK[aS][1]]>=aC){break}}aO=aK[aS][0];aN=aK[aS][1];if(aN=="year"){aQ=Math.pow(10,Math.floor(Math.log(aT/aJ.year)/Math.LN10));aI=(aT/aJ.year)/aQ;if(aI<1.5){aO=1}else{if(aI<3){aO=2}else{if(aI<7.5){aO=5}else{aO=10}}}aO*=aQ}aG.tickSize=aM.tickSize||[aO,aN];aB=function(aX){var a2=[],a0=aX.tickSize[0],a3=aX.tickSize[1],a1=new Date(aX.min);var aW=a0*aJ[a3];if(a3=="second"){a1.setUTCSeconds(a(a1.getUTCSeconds(),a0))}if(a3=="minute"){a1.setUTCMinutes(a(a1.getUTCMinutes(),a0))}if(a3=="hour"){a1.setUTCHours(a(a1.getUTCHours(),a0))}if(a3=="month"){a1.setUTCMonth(a(a1.getUTCMonth(),a0))}if(a3=="year"){a1.setUTCFullYear(a(a1.getUTCFullYear(),a0))}a1.setUTCMilliseconds(0);if(aW>=aJ.minute){a1.setUTCSeconds(0)}if(aW>=aJ.hour){a1.setUTCMinutes(0)}if(aW>=aJ.day){a1.setUTCHours(0)}if(aW>=aJ.day*4){a1.setUTCDate(1)}if(aW>=aJ.year){a1.setUTCMonth(0)}var a5=0,a4=Number.NaN,aY;do{aY=a4;a4=a1.getTime();a2.push(a4);if(a3=="month"){if(a0<1){a1.setUTCDate(1);var aV=a1.getTime();a1.setUTCMonth(a1.getUTCMonth()+1);var aZ=a1.getTime();a1.setTime(a4+a5*aJ.hour+(aZ-aV)*a0);a5=a1.getUTCHours();a1.setUTCHours(0)}else{a1.setUTCMonth(a1.getUTCMonth()+a0)}}else{if(a3=="year"){a1.setUTCFullYear(a1.getUTCFullYear()+a0)}else{a1.setTime(a4+aW)}}}while(a4<aX.max&&a4!=aY);return a2};aR=function(aV,aY){var a0=new Date(aV);if(aM.timeformat!=null){return c.plot.formatDate(a0,aM.timeformat,aM.monthNames)}var aW=aY.tickSize[0]*aJ[aY.tickSize[1]];var aX=aY.max-aY.min;var aZ=(aM.twelveHourClock)?" %p":"";if(aW<aJ.minute){fmt="%h:%M:%S"+aZ}else{if(aW<aJ.day){if(aX<2*aJ.day){fmt="%h:%M"+aZ}else{fmt="%b %d %h:%M"+aZ}}else{if(aW<aJ.month){fmt="%b %d"}else{if(aW<aJ.year){if(aX<aJ.year){fmt="%b"}else{fmt="%b %y"}}else{fmt="%y"}}}}return c.plot.formatDate(a0,fmt,aM.monthNames)}}else{var aU=aM.tickDecimals;var aP=-Math.floor(Math.log(aT)/Math.LN10);if(aU!=null&&aP>aU){aP=aU}aQ=Math.pow(10,-aP);aI=aT/aQ;if(aI<1.5){aO=1}else{if(aI<3){aO=2;if(aI>2.25&&(aU==null||aP+1<=aU)){aO=2.5;++aP}}else{if(aI<7.5){aO=5}else{aO=10}}}aO*=aQ;if(aM.minTickSize!=null&&aO<aM.minTickSize){aO=aM.minTickSize}aG.tickDecimals=Math.max(0,aU!=null?aU:aP);aG.tickSize=aM.tickSize||aO;aB=function(aX){var aZ=[];var a0=a(aX.min,aX.tickSize),aW=0,aV=Number.NaN,aY;do{aY=aV;aV=a0+aW*aX.tickSize;aZ.push(aV);++aW}while(aV<aX.max&&aV!=aY);return aZ};aR=function(aV,aW){return aV.toFixed(aW.tickDecimals)}}if(aM.alignTicksWithAxis!=null){var aF=(aG.direction=="x"?p:aw)[aM.alignTicksWithAxis-1];if(aF&&aF.used&&aF!=aG){var aL=aB(aG);if(aL.length>0){if(aM.min==null){aG.min=Math.min(aG.min,aL[0])}if(aM.max==null&&aL.length>1){aG.max=Math.max(aG.max,aL[aL.length-1])}}aB=function(aX){var aY=[],aV,aW;for(aW=0;aW<aF.ticks.length;++aW){aV=(aF.ticks[aW].v-aF.min)/(aF.max-aF.min);aV=aX.min+aV*(aX.max-aX.min);aY.push(aV)}return aY};if(aG.mode!="time"&&aM.tickDecimals==null){var aE=Math.max(0,-Math.floor(Math.log(aT)/Math.LN10)+1),aD=aB(aG);if(!(aD.length>1&&/\..*0$/.test((aD[1]-aD[0]).toFixed(aE)))){aG.tickDecimals=aE}}}}aG.tickGenerator=aB;if(c.isFunction(aM.tickFormatter)){aG.tickFormatter=function(aV,aW){return""+aM.tickFormatter(aV,aW)}}else{aG.tickFormatter=aR}}function P(aF){var aH=aF.options.ticks,aG=[];if(aH==null||(typeof aH=="number"&&aH>0)){aG=aF.tickGenerator(aF)}else{if(aH){if(c.isFunction(aH)){aG=aH({min:aF.min,max:aF.max})}else{aG=aH}}}var aE,aB;aF.ticks=[];for(aE=0;aE<aG.length;++aE){var aC=null;var aD=aG[aE];if(typeof aD=="object"){aB=+aD[0];if(aD.length>1){aC=aD[1]}}else{aB=+aD}if(aC==null){aC=aF.tickFormatter(aB,aF)}if(!isNaN(aB)){aF.ticks.push({v:aB,label:aC})}}}function ap(aB,aC){if(aB.options.autoscaleMargin&&aC.length>0){if(aB.options.min==null){aB.min=Math.min(aB.min,aC[0].v)}if(aB.options.max==null&&aC.length>1){aB.max=Math.max(aB.max,aC[aC.length-1].v)}}}function W(){H.clearRect(0,0,G,I);var aC=O.grid;if(aC.show&&aC.backgroundColor){N()}if(aC.show&&!aC.aboveData){ac()}for(var aB=0;aB<Q.length;++aB){an(ak.drawSeries,[H,Q[aB]]);d(Q[aB])}an(ak.draw,[H]);if(aC.show&&aC.aboveData){ac()}}function D(aB,aI){var aE,aH,aG,aD,aF=m();for(i=0;i<aF.length;++i){aE=aF[i];if(aE.direction==aI){aD=aI+aE.n+"axis";if(!aB[aD]&&aE.n==1){aD=aI+"axis"}if(aB[aD]){aH=aB[aD].from;aG=aB[aD].to;break}}}if(!aB[aD]){aE=aI=="x"?p[0]:aw[0];aH=aB[aI+"1"];aG=aB[aI+"2"]}if(aH!=null&&aG!=null&&aH>aG){var aC=aH;aH=aG;aG=aC}return{from:aH,to:aG,axis:aE}}function N(){H.save();H.translate(q.left,q.top);H.fillStyle=am(O.grid.backgroundColor,w,0,"rgba(255, 255, 255, 0)");H.fillRect(0,0,h,w);H.restore()}function ac(){var aF;H.save();H.translate(q.left,q.top);var aH=O.grid.markings;if(aH){if(c.isFunction(aH)){var aK=aq.getAxes();aK.xmin=aK.xaxis.min;aK.xmax=aK.xaxis.max;aK.ymin=aK.yaxis.min;aK.ymax=aK.yaxis.max;aH=aH(aK)}for(aF=0;aF<aH.length;++aF){var aD=aH[aF],aC=D(aD,"x"),aI=D(aD,"y");if(aC.from==null){aC.from=aC.axis.min}if(aC.to==null){aC.to=aC.axis.max}if(aI.from==null){aI.from=aI.axis.min}if(aI.to==null){aI.to=aI.axis.max}if(aC.to<aC.axis.min||aC.from>aC.axis.max||aI.to<aI.axis.min||aI.from>aI.axis.max){continue}aC.from=Math.max(aC.from,aC.axis.min);aC.to=Math.min(aC.to,aC.axis.max);aI.from=Math.max(aI.from,aI.axis.min);aI.to=Math.min(aI.to,aI.axis.max);if(aC.from==aC.to&&aI.from==aI.to){continue}aC.from=aC.axis.p2c(aC.from);aC.to=aC.axis.p2c(aC.to);aI.from=aI.axis.p2c(aI.from);aI.to=aI.axis.p2c(aI.to);if(aC.from==aC.to||aI.from==aI.to){H.beginPath();H.strokeStyle=aD.color||O.grid.markingsColor;H.lineWidth=aD.lineWidth||O.grid.markingsLineWidth;H.moveTo(aC.from,aI.from);H.lineTo(aC.to,aI.to);H.stroke()}else{H.fillStyle=aD.color||O.grid.markingsColor;H.fillRect(aC.from,aI.to,aC.to-aC.from,aI.from-aI.to)}}}var aK=m(),aM=O.grid.borderWidth;for(var aE=0;aE<aK.length;++aE){var aB=aK[aE],aG=aB.box,aQ=aB.tickLength,aN,aL,aP,aJ;if(!aB.show||aB.ticks.length==0){continue}H.strokeStyle=aB.options.tickColor||c.color.parse(aB.options.color).scale("a",0.22).toString();H.lineWidth=1;if(aB.direction=="x"){aN=0;if(aQ=="full"){aL=(aB.position=="top"?0:w)}else{aL=aG.top-q.top+(aB.position=="top"?aG.height:0)}}else{aL=0;if(aQ=="full"){aN=(aB.position=="left"?0:h)}else{aN=aG.left-q.left+(aB.position=="left"?aG.width:0)}}if(!aB.innermost){H.beginPath();aP=aJ=0;if(aB.direction=="x"){aP=h}else{aJ=w}if(H.lineWidth==1){aN=Math.floor(aN)+0.5;aL=Math.floor(aL)+0.5}H.moveTo(aN,aL);H.lineTo(aN+aP,aL+aJ);H.stroke()}H.beginPath();for(aF=0;aF<aB.ticks.length;++aF){var aO=aB.ticks[aF].v;aP=aJ=0;if(aO<aB.min||aO>aB.max||(aQ=="full"&&aM>0&&(aO==aB.min||aO==aB.max))){continue}if(aB.direction=="x"){aN=aB.p2c(aO);aJ=aQ=="full"?-w:aQ;if(aB.position=="top"){aJ=-aJ}}else{aL=aB.p2c(aO);aP=aQ=="full"?-h:aQ;if(aB.position=="left"){aP=-aP}}if(H.lineWidth==1){if(aB.direction=="x"){aN=Math.floor(aN)+0.5}else{aL=Math.floor(aL)+0.5}}H.moveTo(aN,aL);H.lineTo(aN+aP,aL+aJ)}H.stroke()}if(aM){H.lineWidth=aM;H.strokeStyle=O.grid.borderColor;H.strokeRect(-aM/2,-aM/2,h+aM,w+aM)}H.restore()}function k(){av.find(".tickLabels").remove();var aG=['<div class="tickLabels" style="font-size:smaller">'];var aJ=m();for(var aD=0;aD<aJ.length;++aD){var aC=aJ[aD],aF=aC.box;if(!aC.show){continue}aG.push('<div class="'+aC.direction+"Axis "+aC.direction+aC.n+'Axis" style="color:'+aC.options.color+'">');for(var aE=0;aE<aC.ticks.length;++aE){var aH=aC.ticks[aE];if(!aH.label||aH.v<aC.min||aH.v>aC.max){continue}var aK={},aI;if(aC.direction=="x"){aI="center";aK.left=Math.round(q.left+aC.p2c(aH.v)-aC.labelWidth/2);if(aC.position=="bottom"){aK.top=aF.top+aF.padding}else{aK.bottom=I-(aF.top+aF.height-aF.padding)}}else{aK.top=Math.round(q.top+aC.p2c(aH.v)-aC.labelHeight/2);if(aC.position=="left"){aK.right=G-(aF.left+aF.width-aF.padding);aI="right"}else{aK.left=aF.left+aF.padding;aI="left"}}aK.width=aC.labelWidth;var aB=["position:absolute","text-align:"+aI];for(var aL in aK){aB.push(aL+":"+aK[aL]+"px")}aG.push('<div class="tickLabel" style="'+aB.join(";")+'">'+aH.label+"</div>")}aG.push("</div>")}aG.push("</div>");av.append(aG.join(""))}function d(aB){if(aB.lines.show){at(aB)}if(aB.bars.show){e(aB)}if(aB.points.show){ao(aB)}}function at(aE){function aD(aP,aQ,aI,aU,aT){var aV=aP.points,aJ=aP.pointsize,aN=null,aM=null;H.beginPath();for(var aO=aJ;aO<aV.length;aO+=aJ){var aL=aV[aO-aJ],aS=aV[aO-aJ+1],aK=aV[aO],aR=aV[aO+1];if(aL==null||aK==null){continue}if(aS<=aR&&aS<aT.min){if(aR<aT.min){continue}aL=(aT.min-aS)/(aR-aS)*(aK-aL)+aL;aS=aT.min}else{if(aR<=aS&&aR<aT.min){if(aS<aT.min){continue}aK=(aT.min-aS)/(aR-aS)*(aK-aL)+aL;aR=aT.min}}if(aS>=aR&&aS>aT.max){if(aR>aT.max){continue}aL=(aT.max-aS)/(aR-aS)*(aK-aL)+aL;aS=aT.max}else{if(aR>=aS&&aR>aT.max){if(aS>aT.max){continue}aK=(aT.max-aS)/(aR-aS)*(aK-aL)+aL;aR=aT.max}}if(aL<=aK&&aL<aU.min){if(aK<aU.min){continue}aS=(aU.min-aL)/(aK-aL)*(aR-aS)+aS;aL=aU.min}else{if(aK<=aL&&aK<aU.min){if(aL<aU.min){continue}aR=(aU.min-aL)/(aK-aL)*(aR-aS)+aS;aK=aU.min}}if(aL>=aK&&aL>aU.max){if(aK>aU.max){continue}aS=(aU.max-aL)/(aK-aL)*(aR-aS)+aS;aL=aU.max}else{if(aK>=aL&&aK>aU.max){if(aL>aU.max){continue}aR=(aU.max-aL)/(aK-aL)*(aR-aS)+aS;aK=aU.max}}if(aL!=aN||aS!=aM){H.moveTo(aU.p2c(aL)+aQ,aT.p2c(aS)+aI)}aN=aK;aM=aR;H.lineTo(aU.p2c(aK)+aQ,aT.p2c(aR)+aI)}H.stroke()}function aF(aI,aQ,aP){var aW=aI.points,aV=aI.pointsize,aN=Math.min(Math.max(0,aP.min),aP.max),aX=0,aU,aT=false,aM=1,aL=0,aR=0;while(true){if(aV>0&&aX>aW.length+aV){break}aX+=aV;var aZ=aW[aX-aV],aK=aW[aX-aV+aM],aY=aW[aX],aJ=aW[aX+aM];if(aT){if(aV>0&&aZ!=null&&aY==null){aR=aX;aV=-aV;aM=2;continue}if(aV<0&&aX==aL+aV){H.fill();aT=false;aV=-aV;aM=1;aX=aL=aR+aV;continue}}if(aZ==null||aY==null){continue}if(aZ<=aY&&aZ<aQ.min){if(aY<aQ.min){continue}aK=(aQ.min-aZ)/(aY-aZ)*(aJ-aK)+aK;aZ=aQ.min}else{if(aY<=aZ&&aY<aQ.min){if(aZ<aQ.min){continue}aJ=(aQ.min-aZ)/(aY-aZ)*(aJ-aK)+aK;aY=aQ.min}}if(aZ>=aY&&aZ>aQ.max){if(aY>aQ.max){continue}aK=(aQ.max-aZ)/(aY-aZ)*(aJ-aK)+aK;aZ=aQ.max}else{if(aY>=aZ&&aY>aQ.max){if(aZ>aQ.max){continue}aJ=(aQ.max-aZ)/(aY-aZ)*(aJ-aK)+aK;aY=aQ.max}}if(!aT){H.beginPath();H.moveTo(aQ.p2c(aZ),aP.p2c(aN));aT=true}if(aK>=aP.max&&aJ>=aP.max){H.lineTo(aQ.p2c(aZ),aP.p2c(aP.max));H.lineTo(aQ.p2c(aY),aP.p2c(aP.max));continue}else{if(aK<=aP.min&&aJ<=aP.min){H.lineTo(aQ.p2c(aZ),aP.p2c(aP.min));H.lineTo(aQ.p2c(aY),aP.p2c(aP.min));continue}}var aO=aZ,aS=aY;if(aK<=aJ&&aK<aP.min&&aJ>=aP.min){aZ=(aP.min-aK)/(aJ-aK)*(aY-aZ)+aZ;aK=aP.min}else{if(aJ<=aK&&aJ<aP.min&&aK>=aP.min){aY=(aP.min-aK)/(aJ-aK)*(aY-aZ)+aZ;aJ=aP.min}}if(aK>=aJ&&aK>aP.max&&aJ<=aP.max){aZ=(aP.max-aK)/(aJ-aK)*(aY-aZ)+aZ;aK=aP.max}else{if(aJ>=aK&&aJ>aP.max&&aK<=aP.max){aY=(aP.max-aK)/(aJ-aK)*(aY-aZ)+aZ;aJ=aP.max}}if(aZ!=aO){H.lineTo(aQ.p2c(aO),aP.p2c(aK))}H.lineTo(aQ.p2c(aZ),aP.p2c(aK));H.lineTo(aQ.p2c(aY),aP.p2c(aJ));if(aY!=aS){H.lineTo(aQ.p2c(aY),aP.p2c(aJ));H.lineTo(aQ.p2c(aS),aP.p2c(aJ))}}}H.save();H.translate(q.left,q.top);H.lineJoin="round";var aG=aE.lines.lineWidth,aB=aE.shadowSize;if(aG>0&&aB>0){H.lineWidth=aB;H.strokeStyle="rgba(0,0,0,0.1)";var aH=Math.PI/18;aD(aE.datapoints,Math.sin(aH)*(aG/2+aB/2),Math.cos(aH)*(aG/2+aB/2),aE.xaxis,aE.yaxis);H.lineWidth=aB/2;aD(aE.datapoints,Math.sin(aH)*(aG/2+aB/4),Math.cos(aH)*(aG/2+aB/4),aE.xaxis,aE.yaxis)}H.lineWidth=aG;H.strokeStyle=aE.color;var aC=ae(aE.lines,aE.color,0,w);if(aC){H.fillStyle=aC;aF(aE.datapoints,aE.xaxis,aE.yaxis)}if(aG>0){aD(aE.datapoints,0,0,aE.xaxis,aE.yaxis)}H.restore()}function ao(aE){function aH(aN,aM,aU,aK,aS,aT,aQ,aJ){var aR=aN.points,aI=aN.pointsize;for(var aL=0;aL<aR.length;aL+=aI){var aP=aR[aL],aO=aR[aL+1];if(aP==null||aP<aT.min||aP>aT.max||aO<aQ.min||aO>aQ.max){continue}H.beginPath();aP=aT.p2c(aP);aO=aQ.p2c(aO)+aK;if(aJ=="circle"){H.arc(aP,aO,aM,0,aS?Math.PI:Math.PI*2,false)}else{aJ(H,aP,aO,aM,aS)}H.closePath();if(aU){H.fillStyle=aU;H.fill()}H.stroke()}}H.save();H.translate(q.left,q.top);var aG=aE.points.lineWidth,aC=aE.shadowSize,aB=aE.points.radius,aF=aE.points.symbol;if(aG>0&&aC>0){var aD=aC/2;H.lineWidth=aD;H.strokeStyle="rgba(0,0,0,0.1)";aH(aE.datapoints,aB,null,aD+aD/2,true,aE.xaxis,aE.yaxis,aF);H.strokeStyle="rgba(0,0,0,0.2)";aH(aE.datapoints,aB,null,aD/2,true,aE.xaxis,aE.yaxis,aF)}H.lineWidth=aG;H.strokeStyle=aE.color;aH(aE.datapoints,aB,ae(aE.points,aE.color),0,false,aE.xaxis,aE.yaxis,aF);H.restore()}function E(aN,aM,aV,aI,aQ,aF,aD,aL,aK,aU,aR,aC){var aE,aT,aJ,aP,aG,aB,aO,aH,aS;if(aR){aH=aB=aO=true;aG=false;aE=aV;aT=aN;aP=aM+aI;aJ=aM+aQ;if(aT<aE){aS=aT;aT=aE;aE=aS;aG=true;aB=false}}else{aG=aB=aO=true;aH=false;aE=aN+aI;aT=aN+aQ;aJ=aV;aP=aM;if(aP<aJ){aS=aP;aP=aJ;aJ=aS;aH=true;aO=false}}if(aT<aL.min||aE>aL.max||aP<aK.min||aJ>aK.max){return}if(aE<aL.min){aE=aL.min;aG=false}if(aT>aL.max){aT=aL.max;aB=false}if(aJ<aK.min){aJ=aK.min;aH=false}if(aP>aK.max){aP=aK.max;aO=false}aE=aL.p2c(aE);aJ=aK.p2c(aJ);aT=aL.p2c(aT);aP=aK.p2c(aP);if(aD){aU.beginPath();aU.moveTo(aE,aJ);aU.lineTo(aE,aP);aU.lineTo(aT,aP);aU.lineTo(aT,aJ);aU.fillStyle=aD(aJ,aP);aU.fill()}if(aC>0&&(aG||aB||aO||aH)){aU.beginPath();aU.moveTo(aE,aJ+aF);if(aG){aU.lineTo(aE,aP+aF)}else{aU.moveTo(aE,aP+aF)}if(aO){aU.lineTo(aT,aP+aF)}else{aU.moveTo(aT,aP+aF)}if(aB){aU.lineTo(aT,aJ+aF)}else{aU.moveTo(aT,aJ+aF)}if(aH){aU.lineTo(aE,aJ+aF)}else{aU.moveTo(aE,aJ+aF)}aU.stroke()}}function e(aD){function aC(aJ,aI,aL,aG,aK,aN,aM){var aO=aJ.points,aF=aJ.pointsize;for(var aH=0;aH<aO.length;aH+=aF){if(aO[aH]==null){continue}E(aO[aH],aO[aH+1],aO[aH+2],aI,aL,aG,aK,aN,aM,H,aD.bars.horizontal,aD.bars.lineWidth)}}H.save();H.translate(q.left,q.top);H.lineWidth=aD.bars.lineWidth;H.strokeStyle=aD.color;var aB=aD.bars.align=="left"?0:-aD.bars.barWidth/2;var aE=aD.bars.fill?function(aF,aG){return ae(aD.bars,aD.color,aF,aG)}:null;aC(aD.datapoints,aB,aB+aD.bars.barWidth,0,aE,aD.xaxis,aD.yaxis);H.restore()}function ae(aD,aB,aC,aF){var aE=aD.fill;if(!aE){return null}if(aD.fillColor){return am(aD.fillColor,aC,aF,aB)}var aG=c.color.parse(aB);aG.a=typeof aE=="number"?aE:0.4;aG.normalize();return aG.toString()}function o(){av.find(".legend").remove();if(!O.legend.show){return}var aH=[],aF=false,aN=O.legend.labelFormatter,aM,aJ;for(var aE=0;aE<Q.length;++aE){aM=Q[aE];aJ=aM.label;if(!aJ){continue}if(aE%O.legend.noColumns==0){if(aF){aH.push("</tr>")}aH.push("<tr>");aF=true}if(aN){aJ=aN(aJ,aM)}aH.push('<td class="legendColorBox"><div style="border:1px solid '+O.legend.labelBoxBorderColor+';padding:1px"><div style="width:4px;height:0;border:5px solid '+aM.color+';overflow:hidden"></div></div></td><td class="legendLabel">'+aJ+"</td>")}if(aF){aH.push("</tr>")}if(aH.length==0){return}var aL='<table style="font-size:smaller;color:'+O.grid.color+'">'+aH.join("")+"</table>";if(O.legend.container!=null){c(O.legend.container).html(aL)}else{var aI="",aC=O.legend.position,aD=O.legend.margin;if(aD[0]==null){aD=[aD,aD]}if(aC.charAt(0)=="n"){aI+="top:"+(aD[1]+q.top)+"px;"}else{if(aC.charAt(0)=="s"){aI+="bottom:"+(aD[1]+q.bottom)+"px;"}}if(aC.charAt(1)=="e"){aI+="right:"+(aD[0]+q.right)+"px;"}else{if(aC.charAt(1)=="w"){aI+="left:"+(aD[0]+q.left)+"px;"}}var aK=c('<div class="legend">'+aL.replace('style="','style="position:absolute;'+aI+";")+"</div>").appendTo(av);if(O.legend.backgroundOpacity!=0){var aG=O.legend.backgroundColor;if(aG==null){aG=O.grid.backgroundColor;if(aG&&typeof aG=="string"){aG=c.color.parse(aG)}else{aG=c.color.extract(aK,"background-color")}aG.a=1;aG=aG.toString()}var aB=aK.children();c('<div style="position:absolute;width:'+aB.width()+"px;height:"+aB.height()+"px;"+aI+"background-color:"+aG+';"> </div>').prependTo(aK).css("opacity",O.legend.backgroundOpacity)}}}var ab=[],M=null;function K(aI,aG,aD){var aO=O.grid.mouseActiveRadius,a0=aO*aO+1,aY=null,aR=false,aW,aU;for(aW=Q.length-1;aW>=0;--aW){if(!aD(Q[aW])){continue}var aP=Q[aW],aH=aP.xaxis,aF=aP.yaxis,aV=aP.datapoints.points,aT=aP.datapoints.pointsize,aQ=aH.c2p(aI),aN=aF.c2p(aG),aC=aO/aH.scale,aB=aO/aF.scale;if(aH.options.inverseTransform){aC=Number.MAX_VALUE}if(aF.options.inverseTransform){aB=Number.MAX_VALUE}if(aP.lines.show||aP.points.show){for(aU=0;aU<aV.length;aU+=aT){var aK=aV[aU],aJ=aV[aU+1];if(aK==null){continue}if(aK-aQ>aC||aK-aQ<-aC||aJ-aN>aB||aJ-aN<-aB){continue}var aM=Math.abs(aH.p2c(aK)-aI),aL=Math.abs(aF.p2c(aJ)-aG),aS=aM*aM+aL*aL;if(aS<a0){a0=aS;aY=[aW,aU/aT]}}}if(aP.bars.show&&!aY){var aE=aP.bars.align=="left"?0:-aP.bars.barWidth/2,aX=aE+aP.bars.barWidth;for(aU=0;aU<aV.length;aU+=aT){var aK=aV[aU],aJ=aV[aU+1],aZ=aV[aU+2];if(aK==null){continue}if(Q[aW].bars.horizontal?(aQ<=Math.max(aZ,aK)&&aQ>=Math.min(aZ,aK)&&aN>=aJ+aE&&aN<=aJ+aX):(aQ>=aK+aE&&aQ<=aK+aX&&aN>=Math.min(aZ,aJ)&&aN<=Math.max(aZ,aJ))){aY=[aW,aU/aT]}}}}if(aY){aW=aY[0];aU=aY[1];aT=Q[aW].datapoints.pointsize;return{datapoint:Q[aW].datapoints.points.slice(aU*aT,(aU+1)*aT),dataIndex:aU,series:Q[aW],seriesIndex:aW}}return null}function aa(aB){if(O.grid.hoverable){u("plothover",aB,function(aC){return aC.hoverable!=false})}}function l(aB){if(O.grid.hoverable){u("plothover",aB,function(aC){return false})}}function R(aB){u("plotclick",aB,function(aC){return aC.clickable!=false})}function u(aC,aB,aD){var aE=y.offset(),aH=aB.pageX-aE.left-q.left,aF=aB.pageY-aE.top-q.top,aJ=C({left:aH,top:aF});aJ.pageX=aB.pageX;aJ.pageY=aB.pageY;var aK=K(aH,aF,aD);if(aK){aK.pageX=parseInt(aK.series.xaxis.p2c(aK.datapoint[0])+aE.left+q.left);aK.pageY=parseInt(aK.series.yaxis.p2c(aK.datapoint[1])+aE.top+q.top)}if(O.grid.autoHighlight){for(var aG=0;aG<ab.length;++aG){var aI=ab[aG];if(aI.auto==aC&&!(aK&&aI.series==aK.series&&aI.point[0]==aK.datapoint[0]&&aI.point[1]==aK.datapoint[1])){T(aI.series,aI.point)}}if(aK){x(aK.series,aK.datapoint,aC)}}av.trigger(aC,[aJ,aK])}function f(){if(!M){M=setTimeout(s,30)}}function s(){M=null;A.save();A.clearRect(0,0,G,I);A.translate(q.left,q.top);var aC,aB;for(aC=0;aC<ab.length;++aC){aB=ab[aC];if(aB.series.bars.show){v(aB.series,aB.point)}else{ay(aB.series,aB.point)}}A.restore();an(ak.drawOverlay,[A])}function x(aD,aB,aF){if(typeof aD=="number"){aD=Q[aD]}if(typeof aB=="number"){var aE=aD.datapoints.pointsize;aB=aD.datapoints.points.slice(aE*aB,aE*(aB+1))}var aC=al(aD,aB);if(aC==-1){ab.push({series:aD,point:aB,auto:aF});f()}else{if(!aF){ab[aC].auto=false}}}function T(aD,aB){if(aD==null&&aB==null){ab=[];f()}if(typeof aD=="number"){aD=Q[aD]}if(typeof aB=="number"){aB=aD.data[aB]}var aC=al(aD,aB);if(aC!=-1){ab.splice(aC,1);f()}}function al(aD,aE){for(var aB=0;aB<ab.length;++aB){var aC=ab[aB];if(aC.series==aD&&aC.point[0]==aE[0]&&aC.point[1]==aE[1]){return aB}}return -1}function ay(aE,aD){var aC=aD[0],aI=aD[1],aH=aE.xaxis,aG=aE.yaxis;if(aC<aH.min||aC>aH.max||aI<aG.min||aI>aG.max){return}var aF=aE.points.radius+aE.points.lineWidth/2;A.lineWidth=aF;A.strokeStyle=c.color.parse(aE.color).scale("a",0.5).toString();var aB=1.5*aF,aC=aH.p2c(aC),aI=aG.p2c(aI);A.beginPath();if(aE.points.symbol=="circle"){A.arc(aC,aI,aB,0,2*Math.PI,false)}else{aE.points.symbol(A,aC,aI,aB,false)}A.closePath();A.stroke()}function v(aE,aB){A.lineWidth=aE.bars.lineWidth;A.strokeStyle=c.color.parse(aE.color).scale("a",0.5).toString();var aD=c.color.parse(aE.color).scale("a",0.5).toString();var aC=aE.bars.align=="left"?0:-aE.bars.barWidth/2;E(aB[0],aB[1],aB[2]||0,aC,aC+aE.bars.barWidth,0,function(){return aD},aE.xaxis,aE.yaxis,A,aE.bars.horizontal,aE.bars.lineWidth)}function am(aJ,aB,aH,aC){if(typeof aJ=="string"){return aJ}else{var aI=H.createLinearGradient(0,aH,0,aB);for(var aE=0,aD=aJ.colors.length;aE<aD;++aE){var aF=aJ.colors[aE];if(typeof aF!="string"){var aG=c.color.parse(aC);if(aF.brightness!=null){aG=aG.scale("rgb",aF.brightness)}if(aF.opacity!=null){aG.a*=aF.opacity}aF=aG.toString()}aI.addColorStop(aE/(aD-1),aF)}return aI}}}c.plot=function(g,e,d){var f=new b(c(g),e,d,c.plot.plugins);return f};c.plot.version="0.7";c.plot.plugins=[];c.plot.formatDate=function(l,f,h){var o=function(d){d=""+d;return d.length==1?"0"+d:d};var e=[];var p=false,j=false;var n=l.getUTCHours();var k=n<12;if(h==null){h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}if(f.search(/%p|%P/)!=-1){if(n>12){n=n-12}else{if(n==0){n=12}}}for(var g=0;g<f.length;++g){var m=f.charAt(g);if(p){switch(m){case"h":m=""+n;break;case"H":m=o(n);break;case"M":m=o(l.getUTCMinutes());break;case"S":m=o(l.getUTCSeconds());break;case"d":m=""+l.getUTCDate();break;case"m":m=""+(l.getUTCMonth()+1);break;case"y":m=""+l.getUTCFullYear();break;case"b":m=""+h[l.getUTCMonth()];break;case"p":m=(k)?("am"):("pm");break;case"P":m=(k)?("AM"):("PM");break;case"0":m="";j=true;break}if(m&&j){m=o(m);j=false}e.push(m);if(!j){p=false}}else{if(m=="%"){p=true}else{e.push(m)}}}return e.join("")};function a(e,d){return d*Math.floor(e/d)}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.navigate.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.navigate.min.js
new file mode 100644
index 0000000..ecf63c9
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.navigate.min.js
@@ -0,0 +1 @@
+(function(i){i.fn.drag=function(j,k,l){if(k){this.bind("dragstart",j)}if(l){this.bind("dragend",l)}return !j?this.trigger("drag"):this.bind("drag",k?k:j)};var d=i.event,c=d.special,h=c.drag={not:":input",distance:0,which:1,dragging:false,setup:function(j){j=i.extend({distance:h.distance,which:h.which,not:h.not},j||{});j.distance=e(j.distance);d.add(this,"mousedown",f,j);if(this.attachEvent){this.attachEvent("ondragstart",a)}},teardown:function(){d.remove(this,"mousedown",f);if(this===h.dragging){h.dragging=h.proxy=false}g(this,true);if(this.detachEvent){this.detachEvent("ondragstart",a)}}};c.dragstart=c.dragend={setup:function(){},teardown:function(){}};function f(j){var k=this,l,m=j.data||{};if(m.elem){k=j.dragTarget=m.elem;j.dragProxy=h.proxy||k;j.cursorOffsetX=m.pageX-m.left;j.cursorOffsetY=m.pageY-m.top;j.offsetX=j.pageX-j.cursorOffsetX;j.offsetY=j.pageY-j.cursorOffsetY}else{if(h.dragging||(m.which>0&&j.which!=m.which)||i(j.target).is(m.not)){return}}switch(j.type){case"mousedown":i.extend(m,i(k).offset(),{elem:k,target:j.target,pageX:j.pageX,pageY:j.pageY});d.add(document,"mousemove mouseup",f,m);g(k,false);h.dragging=null;return false;case !h.dragging&&"mousemove":if(e(j.pageX-m.pageX)+e(j.pageY-m.pageY)<m.distance){break}j.target=m.target;l=b(j,"dragstart",k);if(l!==false){h.dragging=k;h.proxy=j.dragProxy=i(l||k)[0]}case"mousemove":if(h.dragging){l=b(j,"drag",k);if(c.drop){c.drop.allowed=(l!==false);c.drop.handler(j)}if(l!==false){break}j.type="mouseup"}case"mouseup":d.remove(document,"mousemove mouseup",f);if(h.dragging){if(c.drop){c.drop.handler(j)}b(j,"dragend",k)}g(k,true);h.dragging=h.proxy=m.elem=false;break}return true}function b(m,k,j){m.type=k;var l=i.event.handle.call(j,m);return l===false?false:l||m.result}function e(j){return Math.pow(j,2)}function a(){return(h.dragging===false)}function g(j,k){if(!j){return}j.unselectable=k?"off":"on";j.onselectstart=function(){return k};if(j.style){j.style.MozUserSelect=k?"":"none"}}})(jQuery);(function(f){var e=["DOMMouseScroll","mousewheel"];f.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var a=e.length;a;){this.addEventListener(e[--a],d,false)}}else{this.onmousewheel=d}},teardown:function(){if(this.removeEventListener){for(var a=e.length;a;){this.removeEventListener(e[--a],d,false)}}else{this.onmousewheel=null}}};f.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}});function d(b){var h=[].slice.call(arguments,1),a=0,c=true;b=f.event.fix(b||window.event);b.type="mousewheel";if(b.wheelDelta){a=b.wheelDelta/120}if(b.detail){a=-b.detail/3}h.unshift(b,a);return f.event.handle.apply(this,h)}})(jQuery);(function(b){var a={xaxis:{zoomRange:null,panRange:null},zoom:{interactive:false,trigger:"dblclick",amount:1.5},pan:{interactive:false,cursor:"move",frameRate:20}};function c(o){function m(q,p){var r=o.offset();r.left=q.pageX-r.left;r.top=q.pageY-r.top;if(p){o.zoomOut({center:r})}else{o.zoom({center:r})}}function d(p,q){m(p,q<0);return false}var i="default",g=0,e=0,n=null;function f(p){if(p.which!=1){return false}var q=o.getPlaceholder().css("cursor");if(q){i=q}o.getPlaceholder().css("cursor",o.getOptions().pan.cursor);g=p.pageX;e=p.pageY}function j(q){var p=o.getOptions().pan.frameRate;if(n||!p){return}n=setTimeout(function(){o.pan({left:g-q.pageX,top:e-q.pageY});g=q.pageX;e=q.pageY;n=null},1/p*1000)}function h(p){if(n){clearTimeout(n);n=null}o.getPlaceholder().css("cursor",i);o.pan({left:g-p.pageX,top:e-p.pageY})}function l(q,p){var r=q.getOptions();if(r.zoom.interactive){p[r.zoom.trigger](m);p.mousewheel(d)}if(r.pan.interactive){p.bind("dragstart",{distance:10},f);p.bind("drag",j);p.bind("dragend",h)}}o.zoomOut=function(p){if(!p){p={}}if(!p.amount){p.amount=o.getOptions().zoom.amount}p.amount=1/p.amount;o.zoom(p)};o.zoom=function(q){if(!q){q={}}var x=q.center,r=q.amount||o.getOptions().zoom.amount,p=o.width(),t=o.height();if(!x){x={left:p/2,top:t/2}}var s=x.left/p,v=x.top/t,u={x:{min:x.left-s*p/r,max:x.left+(1-s)*p/r},y:{min:x.top-v*t/r,max:x.top+(1-v)*t/r}};b.each(o.getAxes(),function(z,C){var D=C.options,B=u[C.direction].min,w=u[C.direction].max,E=D.zoomRange;if(E===false){return}B=C.c2p(B);w=C.c2p(w);if(B>w){var A=B;B=w;w=A}var y=w-B;if(E&&((E[0]!=null&&y<E[0])||(E[1]!=null&&y>E[1]))){return}D.min=B;D.max=w});o.setupGrid();o.draw();if(!q.preventEvent){o.getPlaceholder().trigger("plotzoom",[o])}};o.pan=function(p){var q={x:+p.left,y:+p.top};if(isNaN(q.x)){q.x=0}if(isNaN(q.y)){q.y=0}b.each(o.getAxes(),function(s,u){var v=u.options,t,r,w=q[u.direction];t=u.c2p(u.p2c(u.min)+w),r=u.c2p(u.p2c(u.max)+w);var x=v.panRange;if(x===false){return}if(x){if(x[0]!=null&&x[0]>t){w=x[0]-t;t+=w;r+=w}if(x[1]!=null&&x[1]<r){w=x[1]-r;t+=w;r+=w}}v.min=t;v.max=r});o.setupGrid();o.draw();if(!p.preventEvent){o.getPlaceholder().trigger("plotpan",[o])}};function k(q,p){p.unbind(q.getOptions().zoom.trigger,m);p.unbind("mousewheel",d);p.unbind("dragstart",f);p.unbind("drag",j);p.unbind("dragend",h);if(n){clearTimeout(n)}}o.hooks.bindEvents.push(l);o.hooks.shutdown.push(k)}b.plot.plugins.push({init:c,options:a,name:"navigate",version:"1.3"})})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.pie.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.pie.min.js
new file mode 100644
index 0000000..b7bf870
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.pie.min.js
@@ -0,0 +1 @@
+(function(b){function c(D){var h=null;var L=null;var n=null;var B=null;var p=null;var M=0;var F=true;var o=10;var w=0.95;var A=0;var d=false;var z=false;var j=[];D.hooks.processOptions.push(g);D.hooks.bindEvents.push(e);function g(O,N){if(N.series.pie.show){N.grid.show=false;if(N.series.pie.label.show=="auto"){if(N.legend.show){N.series.pie.label.show=false}else{N.series.pie.label.show=true}}if(N.series.pie.radius=="auto"){if(N.series.pie.label.show){N.series.pie.radius=3/4}else{N.series.pie.radius=1}}if(N.series.pie.tilt>1){N.series.pie.tilt=1}if(N.series.pie.tilt<0){N.series.pie.tilt=0}O.hooks.processDatapoints.push(E);O.hooks.drawOverlay.push(H);O.hooks.draw.push(r)}}function e(P,N){var O=P.getOptions();if(O.series.pie.show&&O.grid.hoverable){N.unbind("mousemove").mousemove(t)}if(O.series.pie.show&&O.grid.clickable){N.unbind("click").click(l)}}function G(O){var P="";function N(S,T){if(!T){T=0}for(var R=0;R<S.length;++R){for(var Q=0;Q<T;Q++){P+="\t"}if(typeof S[R]=="object"){P+=""+R+":\n";N(S[R],T+1)}else{P+=""+R+": "+S[R]+"\n"}}}N(O);alert(P)}function q(P){for(var N=0;N<P.length;++N){var O=parseFloat(P[N].data[0][1]);if(O){M+=O}}}function E(Q,N,O,P){if(!d){d=true;h=Q.getCanvas();L=b(h).parent();a=Q.getOptions();Q.setData(K(Q.getData()))}}function I(){A=L.children().filter(".legend").children().width();n=Math.min(h.width,(h.height/a.series.pie.tilt))/2;p=(h.height/2)+a.series.pie.offset.top;B=(h.width/2);if(a.series.pie.offset.left=="auto"){if(a.legend.position.match("w")){B+=A/2}else{B-=A/2}}else{B+=a.series.pie.offset.left}if(B<n){B=n}else{if(B>h.width-n){B=h.width-n}}}function v(O){for(var N=0;N<O.length;++N){if(typeof(O[N].data)=="number"){O[N].data=[[1,O[N].data]]}else{if(typeof(O[N].data)=="undefined"||typeof(O[N].data[0])=="undefined"){if(typeof(O[N].data)!="undefined"&&typeof(O[N].data.label)!="undefined"){O[N].label=O[N].data.label}O[N].data=[[1,0]]}}}return O}function K(Q){Q=v(Q);q(Q);var P=0;var S=0;var N=a.series.pie.combine.color;var R=[];for(var O=0;O<Q.length;++O){Q[O].data[0][1]=parseFloat(Q[O].data[0][1]);if(!Q[O].data[0][1]){Q[O].data[0][1]=0}if(Q[O].data[0][1]/M<=a.series.pie.combine.threshold){P+=Q[O].data[0][1];S++;if(!N){N=Q[O].color}}else{R.push({data:[[1,Q[O].data[0][1]]],color:Q[O].color,label:Q[O].label,angle:(Q[O].data[0][1]*(Math.PI*2))/M,percent:(Q[O].data[0][1]/M*100)})}}if(S>0){R.push({data:[[1,P]],color:N,label:a.series.pie.combine.label,angle:(P*(Math.PI*2))/M,percent:(P/M*100)})}return R}function r(S,Q){if(!L){return}ctx=Q;I();var T=S.getData();var P=0;while(F&&P<o){F=false;if(P>0){n*=w}P+=1;N();if(a.series.pie.tilt<=0.8){O()}R()}if(P>=o){N();L.prepend('<div class="error">Could not draw pie with labels contained inside canvas</div>')}if(S.setSeries&&S.insertLegend){S.setSeries(T);S.insertLegend()}function N(){ctx.clearRect(0,0,h.width,h.height);L.children().filter(".pieLabel, .pieLabelBackground").remove()}function O(){var Z=5;var Y=15;var W=10;var X=0.02;if(a.series.pie.radius>1){var U=a.series.pie.radius}else{var U=n*a.series.pie.radius}if(U>=(h.width/2)-Z||U*a.series.pie.tilt>=(h.height/2)-Y||U<=W){return}ctx.save();ctx.translate(Z,Y);ctx.globalAlpha=X;ctx.fillStyle="#000";ctx.translate(B,p);ctx.scale(1,a.series.pie.tilt);for(var V=1;V<=W;V++){ctx.beginPath();ctx.arc(0,0,U,0,Math.PI*2,false);ctx.fill();U-=V}ctx.restore()}function R(){startAngle=Math.PI*a.series.pie.startAngle;if(a.series.pie.radius>1){var U=a.series.pie.radius}else{var U=n*a.series.pie.radius}ctx.save();ctx.translate(B,p);ctx.scale(1,a.series.pie.tilt);ctx.save();var Y=startAngle;for(var W=0;W<T.length;++W){T[W].startAngle=Y;X(T[W].angle,T[W].color,true)}ctx.restore();ctx.save();ctx.lineWidth=a.series.pie.stroke.width;Y=startAngle;for(var W=0;W<T.length;++W){X(T[W].angle,a.series.pie.stroke.color,false)}ctx.restore();J(ctx);if(a.series.pie.label.show){V()}ctx.restore();function X(ab,Z,aa){if(ab<=0){return}if(aa){ctx.fillStyle=Z}else{ctx.strokeStyle=Z;ctx.lineJoin="round"}ctx.beginPath();if(Math.abs(ab-Math.PI*2)>1e-9){ctx.moveTo(0,0)}else{if(b.browser.msie){ab-=0.0001}}ctx.arc(0,0,U,Y,Y+ab,false);ctx.closePath();Y+=ab;if(aa){ctx.fill()}else{ctx.stroke()}}function V(){var ac=startAngle;if(a.series.pie.label.radius>1){var Z=a.series.pie.label.radius}else{var Z=n*a.series.pie.label.radius}for(var ab=0;ab<T.length;++ab){if(T[ab].percent>=a.series.pie.label.threshold*100){aa(T[ab],ac,ab)}ac+=T[ab].angle}function aa(ap,ai,ag){if(ap.data[0][1]==0){return}var ar=a.legend.labelFormatter,aq,ae=a.series.pie.label.formatter;if(ar){aq=ar(ap.label,ap)}else{aq=ap.label}if(ae){aq=ae(aq,ap)}var aj=((ai+ap.angle)+ai)/2;var ao=B+Math.round(Math.cos(aj)*Z);var am=p+Math.round(Math.sin(aj)*Z)*a.series.pie.tilt;var af='<span class="pieLabel" id="pieLabel'+ag+'" style="position:absolute;top:'+am+"px;left:"+ao+'px;">'+aq+"</span>";L.append(af);var an=L.children("#pieLabel"+ag);var ad=(am-an.height()/2);var ah=(ao-an.width()/2);an.css("top",ad);an.css("left",ah);if(0-ad>0||0-ah>0||h.height-(ad+an.height())<0||h.width-(ah+an.width())<0){F=true}if(a.series.pie.label.background.opacity!=0){var ak=a.series.pie.label.background.color;if(ak==null){ak=ap.color}var al="top:"+ad+"px;left:"+ah+"px;";b('<div class="pieLabelBackground" style="position:absolute;width:'+an.width()+"px;height:"+an.height()+"px;"+al+"background-color:"+ak+';"> </div>').insertBefore(an).css("opacity",a.series.pie.label.background.opacity)}}}}}function J(N){if(a.series.pie.innerRadius>0){N.save();innerRadius=a.series.pie.innerRadius>1?a.series.pie.innerRadius:n*a.series.pie.innerRadius;N.globalCompositeOperation="destination-out";N.beginPath();N.fillStyle=a.series.pie.stroke.color;N.arc(0,0,innerRadius,0,Math.PI*2,false);N.fill();N.closePath();N.restore();N.save();N.beginPath();N.strokeStyle=a.series.pie.stroke.color;N.arc(0,0,innerRadius,0,Math.PI*2,false);N.stroke();N.closePath();N.restore()}}function s(Q,R){for(var S=false,P=-1,N=Q.length,O=N-1;++P<N;O=P){((Q[P][1]<=R[1]&&R[1]<Q[O][1])||(Q[O][1]<=R[1]&&R[1]<Q[P][1]))&&(R[0]<(Q[O][0]-Q[P][0])*(R[1]-Q[P][1])/(Q[O][1]-Q[P][1])+Q[P][0])&&(S=!S)}return S}function u(R,P){var T=D.getData(),O=D.getOptions(),N=O.series.pie.radius>1?O.series.pie.radius:n*O.series.pie.radius;for(var Q=0;Q<T.length;++Q){var S=T[Q];if(S.pie.show){ctx.save();ctx.beginPath();ctx.moveTo(0,0);ctx.arc(0,0,N,S.startAngle,S.startAngle+S.angle,false);ctx.closePath();x=R-B;y=P-p;if(ctx.isPointInPath){if(ctx.isPointInPath(R-B,P-p)){ctx.restore();return{datapoint:[S.percent,S.data],dataIndex:0,series:S,seriesIndex:Q}}}else{p1X=(N*Math.cos(S.startAngle));p1Y=(N*Math.sin(S.startAngle));p2X=(N*Math.cos(S.startAngle+(S.angle/4)));p2Y=(N*Math.sin(S.startAngle+(S.angle/4)));p3X=(N*Math.cos(S.startAngle+(S.angle/2)));p3Y=(N*Math.sin(S.startAngle+(S.angle/2)));p4X=(N*Math.cos(S.startAngle+(S.angle/1.5)));p4Y=(N*Math.sin(S.startAngle+(S.angle/1.5)));p5X=(N*Math.cos(S.startAngle+S.angle));p5Y=(N*Math.sin(S.startAngle+S.angle));arrPoly=[[0,0],[p1X,p1Y],[p2X,p2Y],[p3X,p3Y],[p4X,p4Y],[p5X,p5Y]];arrPoint=[x,y];if(s(arrPoly,arrPoint)){ctx.restore();return{datapoint:[S.percent,S.data],dataIndex:0,series:S,seriesIndex:Q}}}ctx.restore()}}return null}function t(N){m("plothover",N)}function l(N){m("plotclick",N)}function m(N,T){var O=D.offset(),R=parseInt(T.pageX-O.left),P=parseInt(T.pageY-O.top),V=u(R,P);if(a.grid.autoHighlight){for(var Q=0;Q<j.length;++Q){var S=j[Q];if(S.auto==N&&!(V&&S.series==V.series)){f(S.series)}}}if(V){k(V.series,N)}var U={pageX:T.pageX,pageY:T.pageY};L.trigger(N,[U,V])}function k(O,P){if(typeof O=="number"){O=series[O]}var N=C(O);if(N==-1){j.push({series:O,auto:P});D.triggerRedrawOverlay()}else{if(!P){j[N].auto=false}}}function f(O){if(O==null){j=[];D.triggerRedrawOverlay()}if(typeof O=="number"){O=series[O]}var N=C(O);if(N!=-1){j.splice(N,1);D.triggerRedrawOverlay()}}function C(P){for(var N=0;N<j.length;++N){var O=j[N];if(O.series==P){return N}}return -1}function H(Q,R){var P=Q.getOptions();var N=P.series.pie.radius>1?P.series.pie.radius:n*P.series.pie.radius;R.save();R.translate(B,p);R.scale(1,P.series.pie.tilt);for(i=0;i<j.length;++i){O(j[i].series)}J(R);R.restore();function O(S){if(S.angle<0){return}R.fillStyle="rgba(255, 255, 255, "+P.series.pie.highlight.opacity+")";R.beginPath();if(Math.abs(S.angle-Math.PI*2)>1e-9){R.moveTo(0,0)}R.arc(0,0,N,S.startAngle,S.startAngle+S.angle,false);R.closePath();R.fill()}}}var a={series:{pie:{show:false,radius:"auto",innerRadius:0,startAngle:3/2,tilt:1,offset:{top:0,left:"auto"},stroke:{color:"#FFF",width:1},label:{show:"auto",formatter:function(d,e){return'<div style="font-size:x-small;text-align:center;padding:2px;color:'+e.color+';">'+d+"<br/>"+Math.round(e.percent)+"%</div>"},radius:1,background:{color:null,opacity:0},threshold:0},combine:{threshold:-1,color:null,label:"Other"},highlight:{opacity:0.5}}}};b.plot.plugins.push({init:c,options:a,name:"pie",version:"1.0"})})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.resize.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.resize.min.js
new file mode 100644
index 0000000..1fa0771
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.resize.min.js
@@ -0,0 +1 @@
+(function(n,p,u){var w=n([]),s=n.resize=n.extend(n.resize,{}),o,l="setTimeout",m="resize",t=m+"-special-event",v="delay",r="throttleWindow";s[v]=250;s[r]=true;n.event.special[m]={setup:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.add(a);n.data(this,t,{w:a.width(),h:a.height()});if(w.length===1){q()}},teardown:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.not(a);a.removeData(t);if(!w.length){clearTimeout(o)}},add:function(b){if(!s[r]&&this[l]){return false}var c;function a(d,h,g){var f=n(this),e=n.data(this,t);e.w=h!==u?h:f.width();e.h=g!==u?g:f.height();c.apply(this,arguments)}if(n.isFunction(b)){c=b;return a}else{c=b.handler;b.handler=a}}};function q(){o=p[l](function(){w.each(function(){var d=n(this),a=d.width(),b=d.height(),c=n.data(this,t);if(a!==c.w||b!==c.h){d.trigger(m,[c.w=a,c.h=b])}});q()},s[v])}})(jQuery,this);(function(b){var a={};function c(f){function e(){var h=f.getPlaceholder();if(h.width()==0||h.height()==0){return}f.resize();f.setupGrid();f.draw()}function g(i,h){i.getPlaceholder().resize(e)}function d(i,h){i.getPlaceholder().unbind("resize",e)}f.hooks.bindEvents.push(g);f.hooks.shutdown.push(d)}b.plot.plugins.push({init:c,options:a,name:"resize",version:"1.0"})})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.selection.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.selection.min.js
new file mode 100644
index 0000000..badc005
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.selection.min.js
@@ -0,0 +1 @@
+(function(a){function b(k){var p={first:{x:-1,y:-1},second:{x:-1,y:-1},show:false,active:false};var m={};var r=null;function e(s){if(p.active){l(s);k.getPlaceholder().trigger("plotselecting",[g()])}}function n(s){if(s.which!=1){return}document.body.focus();if(document.onselectstart!==undefined&&m.onselectstart==null){m.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!==undefined&&m.ondrag==null){m.ondrag=document.ondrag;document.ondrag=function(){return false}}d(p.first,s);p.active=true;r=function(t){j(t)};a(document).one("mouseup",r)}function j(s){r=null;if(document.onselectstart!==undefined){document.onselectstart=m.onselectstart}if(document.ondrag!==undefined){document.ondrag=m.ondrag}p.active=false;l(s);if(f()){i()}else{k.getPlaceholder().trigger("plotunselected",[]);k.getPlaceholder().trigger("plotselecting",[null])}return false}function g(){if(!f()){return null}var u={},t=p.first,s=p.second;a.each(k.getAxes(),function(v,w){if(w.used){var y=w.c2p(t[w.direction]),x=w.c2p(s[w.direction]);u[v]={from:Math.min(y,x),to:Math.max(y,x)}}});return u}function i(){var s=g();k.getPlaceholder().trigger("plotselected",[s]);if(s.xaxis&&s.yaxis){k.getPlaceholder().trigger("selected",[{x1:s.xaxis.from,y1:s.yaxis.from,x2:s.xaxis.to,y2:s.yaxis.to}])}}function h(t,u,s){return u<t?t:(u>s?s:u)}function d(w,t){var v=k.getOptions();var u=k.getPlaceholder().offset();var s=k.getPlotOffset();w.x=h(0,t.pageX-u.left-s.left,k.width());w.y=h(0,t.pageY-u.top-s.top,k.height());if(v.selection.mode=="y"){w.x=w==p.first?0:k.width()}if(v.selection.mode=="x"){w.y=w==p.first?0:k.height()}}function l(s){if(s.pageX==null){return}d(p.second,s);if(f()){p.show=true;k.triggerRedrawOverlay()}else{q(true)}}function q(s){if(p.show){p.show=false;k.triggerRedrawOverlay();if(!s){k.getPlaceholder().trigger("plotunselected",[])}}}function c(s,w){var t,y,z,A,x=k.getAxes();for(var u in x){t=x[u];if(t.direction==w){A=w+t.n+"axis";if(!s[A]&&t.n==1){A=w+"axis"}if(s[A]){y=s[A].from;z=s[A].to;break}}}if(!s[A]){t=w=="x"?k.getXAxes()[0]:k.getYAxes()[0];y=s[w+"1"];z=s[w+"2"]}if(y!=null&&z!=null&&y>z){var v=y;y=z;z=v}return{from:y,to:z,axis:t}}function o(t,s){var v,u,w=k.getOptions();if(w.selection.mode=="y"){p.first.x=0;p.second.x=k.width()}else{u=c(t,"x");p.first.x=u.axis.p2c(u.from);p.second.x=u.axis.p2c(u.to)}if(w.selection.mode=="x"){p.first.y=0;p.second.y=k.height()}else{u=c(t,"y");p.first.y=u.axis.p2c(u.from);p.second.y=u.axis.p2c(u.to)}p.show=true;k.triggerRedrawOverlay();if(!s&&f()){i()}}function f(){var s=5;return Math.abs(p.second.x-p.first.x)>=s&&Math.abs(p.second.y-p.first.y)>=s}k.clearSelection=q;k.setSelection=o;k.getSelection=g;k.hooks.bindEvents.push(function(t,s){var u=t.getOptions();if(u.selection.mode!=null){s.mousemove(e);s.mousedown(n)}});k.hooks.drawOverlay.push(function(v,D){if(p.show&&f()){var t=v.getPlotOffset();var s=v.getOptions();D.save();D.translate(t.left,t.top);var z=a.color.parse(s.selection.color);D.strokeStyle=z.scale("a",0.8).toString();D.lineWidth=1;D.lineJoin="round";D.fillStyle=z.scale("a",0.4).toString();var B=Math.min(p.first.x,p.second.x),A=Math.min(p.first.y,p.second.y),C=Math.abs(p.second.x-p.first.x),u=Math.abs(p.second.y-p.first.y);D.fillRect(B,A,C,u);D.strokeRect(B,A,C,u);D.restore()}});k.hooks.shutdown.push(function(t,s){s.unbind("mousemove",e);s.unbind("mousedown",n);if(r){a(document).unbind("mouseup",r)}})}a.plot.plugins.push({init:b,options:{selection:{mode:null,color:"#e8cfac"}},name:"selection",version:"1.1"})})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.stack.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.stack.min.js
new file mode 100644
index 0000000..bba2a0e
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.stack.min.js
@@ -0,0 +1 @@
+(function(b){var a={series:{stack:null}};function c(f){function d(k,j){var h=null;for(var g=0;g<j.length;++g){if(k==j[g]){break}if(j[g].stack==k.stack){h=j[g]}}return h}function e(C,v,g){if(v.stack==null){return}var p=d(v,C.getData());if(!p){return}var z=g.pointsize,F=g.points,h=p.datapoints.pointsize,y=p.datapoints.points,t=[],x,w,k,J,I,r,u=v.lines.show,G=v.bars.horizontal,o=z>2&&(G?g.format[2].x:g.format[2].y),n=u&&v.lines.steps,E=true,q=G?1:0,H=G?0:1,D=0,B=0,A;while(true){if(D>=F.length){break}A=t.length;if(F[D]==null){for(m=0;m<z;++m){t.push(F[D+m])}D+=z}else{if(B>=y.length){if(!u){for(m=0;m<z;++m){t.push(F[D+m])}}D+=z}else{if(y[B]==null){for(m=0;m<z;++m){t.push(null)}E=true;B+=h}else{x=F[D+q];w=F[D+H];J=y[B+q];I=y[B+H];r=0;if(x==J){for(m=0;m<z;++m){t.push(F[D+m])}t[A+H]+=I;r=I;D+=z;B+=h}else{if(x>J){if(u&&D>0&&F[D-z]!=null){k=w+(F[D-z+H]-w)*(J-x)/(F[D-z+q]-x);t.push(J);t.push(k+I);for(m=2;m<z;++m){t.push(F[D+m])}r=I}B+=h}else{if(E&&u){D+=z;continue}for(m=0;m<z;++m){t.push(F[D+m])}if(u&&B>0&&y[B-h]!=null){r=I+(y[B-h+H]-I)*(x-J)/(y[B-h+q]-J)}t[A+H]+=r;D+=z}}E=false;if(A!=t.length&&o){t[A+2]+=r}}}}if(n&&A!=t.length&&A>0&&t[A]!=null&&t[A]!=t[A-z]&&t[A+1]!=t[A-z+1]){for(m=0;m<z;++m){t[A+z+m]=t[A+m]}t[A+1]=t[A-z+1]}}g.points=t}f.hooks.processDatapoints.push(e)}b.plot.plugins.push({init:c,options:a,name:"stack",version:"1.2"})})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.symbol.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.symbol.min.js
new file mode 100644
index 0000000..272e003
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.symbol.min.js
@@ -0,0 +1 @@
+(function(b){function a(h,e,g){var d={square:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI)/2;k.rect(j-l,n-l,l+l,l+l)},diamond:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI/2);k.moveTo(j-l,n);k.lineTo(j,n-l);k.lineTo(j+l,n);k.lineTo(j,n+l);k.lineTo(j-l,n)},triangle:function(l,k,o,j,n){var m=j*Math.sqrt(2*Math.PI/Math.sin(Math.PI/3));var i=m*Math.sin(Math.PI/3);l.moveTo(k-m/2,o+i/2);l.lineTo(k+m/2,o+i/2);if(!n){l.lineTo(k,o-i/2);l.lineTo(k-m/2,o+i/2)}},cross:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI)/2;k.moveTo(j-l,n-l);k.lineTo(j+l,n+l);k.moveTo(j-l,n+l);k.lineTo(j+l,n-l)}};var f=e.points.symbol;if(d[f]){e.points.symbol=d[f]}}function c(d){d.hooks.processDatapoints.push(a)}b.plot.plugins.push({init:c,name:"symbols",version:"1.0"})})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.threshold.min.js b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.threshold.min.js
new file mode 100644
index 0000000..d8b79df
--- /dev/null
+++ b/hyracks-control-cc/src/main/resources/static/javascript/flot/jquery.flot.threshold.min.js
@@ -0,0 +1 @@
+(function(B){var A={series:{threshold:null}};function C(D){function E(L,S,M){if(!S.threshold){return }var F=M.pointsize,I,O,N,G,K,H=B.extend({},S);H.datapoints={points:[],pointsize:F};H.label=null;H.color=S.threshold.color;H.threshold=null;H.originSeries=S;H.data=[];var P=S.threshold.below,Q=M.points,R=S.lines.show;threspoints=[];newpoints=[];for(I=0;I<Q.length;I+=F){O=Q[I];N=Q[I+1];K=G;if(N<P){G=threspoints}else{G=newpoints}if(R&&K!=G&&O!=null&&I>0&&Q[I-F]!=null){var J=(O-Q[I-F])/(N-Q[I-F+1])*(P-N)+O;K.push(J);K.push(P);for(m=2;m<F;++m){K.push(Q[I+m])}G.push(null);G.push(null);for(m=2;m<F;++m){G.push(Q[I+m])}G.push(J);G.push(P);for(m=2;m<F;++m){G.push(Q[I+m])}}G.push(O);G.push(N)}M.points=newpoints;H.datapoints.points=threspoints;if(H.datapoints.points.length>0){L.getData().push(H)}}D.hooks.processDatapoints.push(E)}B.plot.plugins.push({init:C,options:A,name:"threshold",version:"1.0"})})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/excanvas.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/excanvas.js
deleted file mode 100644
index 4ca9653..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/excanvas.js
+++ /dev/null
@@ -1,1438 +0,0 @@
-// Memory Leaks patch from http://explorercanvas.googlecode.com/svn/trunk/ 
-//  svn : r73
-// ------------------------------------------------------------------
-// Copyright 2006 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
-// Known Issues:
-//
-// * Patterns only support repeat.
-// * Radial gradient are not implemented. The VML version of these look very
-//   different from the canvas one.
-// * Clipping paths are not implemented.
-// * Coordsize. The width and height attribute have higher priority than the
-//   width and height style values which isn't correct.
-// * Painting mode isn't implemented.
-// * Canvas width/height should is using content-box by default. IE in
-//   Quirks mode will draw the canvas using border-box. Either change your
-//   doctype to HTML5
-//   (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype)
-//   or use Box Sizing Behavior from WebFX
-//   (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html)
-// * Non uniform scaling does not correctly scale strokes.
-// * Optimize. There is always room for speed improvements.
-
-// Only add this code if we do not already have a canvas implementation
-if (!document.createElement('canvas').getContext) {
-
-(function() {
-
-  // alias some functions to make (compiled) code shorter
-  var m = Math;
-  var mr = m.round;
-  var ms = m.sin;
-  var mc = m.cos;
-  var abs = m.abs;
-  var sqrt = m.sqrt;
-
-  // this is used for sub pixel precision
-  var Z = 10;
-  var Z2 = Z / 2;
-
-  var IE_VERSION = +navigator.userAgent.match(/MSIE ([\d.]+)?/)[1];
-
-  /**
-   * This funtion is assigned to the <canvas> elements as element.getContext().
-   * @this {HTMLElement}
-   * @return {CanvasRenderingContext2D_}
-   */
-  function getContext() {
-    return this.context_ ||
-        (this.context_ = new CanvasRenderingContext2D_(this));
-  }
-
-  var slice = Array.prototype.slice;
-
-  /**
-   * Binds a function to an object. The returned function will always use the
-   * passed in {@code obj} as {@code this}.
-   *
-   * Example:
-   *
-   *   g = bind(f, obj, a, b)
-   *   g(c, d) // will do f.call(obj, a, b, c, d)
-   *
-   * @param {Function} f The function to bind the object to
-   * @param {Object} obj The object that should act as this when the function
-   *     is called
-   * @param {*} var_args Rest arguments that will be used as the initial
-   *     arguments when the function is called
-   * @return {Function} A new function that has bound this
-   */
-  function bind(f, obj, var_args) {
-    var a = slice.call(arguments, 2);
-    return function() {
-      return f.apply(obj, a.concat(slice.call(arguments)));
-    };
-  }
-
-  function encodeHtmlAttribute(s) {
-    return String(s).replace(/&/g, '&amp;').replace(/"/g, '&quot;');
-  }
-
-  function addNamespace(doc, prefix, urn) {
-    if (!doc.namespaces[prefix]) {
-      doc.namespaces.add(prefix, urn, '#default#VML');
-    }
-  }
-
-  function addNamespacesAndStylesheet(doc) {
-    addNamespace(doc, 'g_vml_', 'urn:schemas-microsoft-com:vml');
-    addNamespace(doc, 'g_o_', 'urn:schemas-microsoft-com:office:office');
-
-    // Setup default CSS.  Only add one style sheet per document
-    if (!doc.styleSheets['ex_canvas_']) {
-      var ss = doc.createStyleSheet();
-      ss.owningElement.id = 'ex_canvas_';
-      ss.cssText = 'canvas{display:inline-block;overflow:hidden;' +
-          // default size is 300x150 in Gecko and Opera
-          'text-align:left;width:300px;height:150px}';
-    }
-  }
-
-  // Add namespaces and stylesheet at startup.
-  addNamespacesAndStylesheet(document);
-
-  var G_vmlCanvasManager_ = {
-    init: function(opt_doc) {
-      var doc = opt_doc || document;
-      // Create a dummy element so that IE will allow canvas elements to be
-      // recognized.
-      doc.createElement('canvas');
-      doc.attachEvent('onreadystatechange', bind(this.init_, this, doc));
-    },
-
-    init_: function(doc) {
-      // find all canvas elements
-      var els = doc.getElementsByTagName('canvas');
-      for (var i = 0; i < els.length; i++) {
-        this.initElement(els[i]);
-      }
-    },
-
-    /**
-     * Public initializes a canvas element so that it can be used as canvas
-     * element from now on. This is called automatically before the page is
-     * loaded but if you are creating elements using createElement you need to
-     * make sure this is called on the element.
-     * @param {HTMLElement} el The canvas element to initialize.
-     * @return {HTMLElement} the element that was created.
-     */
-    initElement: function(el) {
-      if (!el.getContext) {
-        el.getContext = getContext;
-
-        // Add namespaces and stylesheet to document of the element.
-        addNamespacesAndStylesheet(el.ownerDocument);
-
-        // Remove fallback content. There is no way to hide text nodes so we
-        // just remove all childNodes. We could hide all elements and remove
-        // text nodes but who really cares about the fallback content.
-        el.innerHTML = '';
-
-        // do not use inline function because that will leak memory
-        el.attachEvent('onpropertychange', onPropertyChange);
-        el.attachEvent('onresize', onResize);
-
-        var attrs = el.attributes;
-        if (attrs.width && attrs.width.specified) {
-          // TODO: use runtimeStyle and coordsize
-          // el.getContext().setWidth_(attrs.width.nodeValue);
-          el.style.width = attrs.width.nodeValue + 'px';
-        } else {
-          el.width = el.clientWidth;
-        }
-        if (attrs.height && attrs.height.specified) {
-          // TODO: use runtimeStyle and coordsize
-          // el.getContext().setHeight_(attrs.height.nodeValue);
-          el.style.height = attrs.height.nodeValue + 'px';
-        } else {
-          el.height = el.clientHeight;
-        }
-        //el.getContext().setCoordsize_()
-      }
-      return el;
-    },
-
-    // Memory Leaks patch : see http://code.google.com/p/explorercanvas/issues/detail?id=82
-    uninitElement: function(el){
-      if (el.getContext) {
-        var ctx = el.getContext();
-        delete ctx.element_;
-        delete ctx.canvas;
-        el.innerHTML = "";
-        //el.outerHTML = "";
-        el.context_ = null;
-        el.getContext = null;
-        el.detachEvent("onpropertychange", onPropertyChange);
-        el.detachEvent("onresize", onResize);
-      }
-    }
-  };
-
-  function onPropertyChange(e) {
-    var el = e.srcElement;
-
-    switch (e.propertyName) {
-      case 'width':
-        el.getContext().clearRect();
-        el.style.width = el.attributes.width.nodeValue + 'px';
-        // In IE8 this does not trigger onresize.
-        el.firstChild.style.width =  el.clientWidth + 'px';
-        break;
-      case 'height':
-        el.getContext().clearRect();
-        el.style.height = el.attributes.height.nodeValue + 'px';
-        el.firstChild.style.height = el.clientHeight + 'px';
-        break;
-    }
-  }
-
-  function onResize(e) {
-    var el = e.srcElement;
-    if (el.firstChild) {
-      el.firstChild.style.width =  el.clientWidth + 'px';
-      el.firstChild.style.height = el.clientHeight + 'px';
-    }
-  }
-
-  G_vmlCanvasManager_.init();
-
-  // precompute "00" to "FF"
-  var decToHex = [];
-  for (var i = 0; i < 16; i++) {
-    for (var j = 0; j < 16; j++) {
-      decToHex[i * 16 + j] = i.toString(16) + j.toString(16);
-    }
-  }
-
-  function createMatrixIdentity() {
-    return [
-      [1, 0, 0],
-      [0, 1, 0],
-      [0, 0, 1]
-    ];
-  }
-
-  function matrixMultiply(m1, m2) {
-    var result = createMatrixIdentity();
-
-    for (var x = 0; x < 3; x++) {
-      for (var y = 0; y < 3; y++) {
-        var sum = 0;
-
-        for (var z = 0; z < 3; z++) {
-          sum += m1[x][z] * m2[z][y];
-        }
-
-        result[x][y] = sum;
-      }
-    }
-    return result;
-  }
-
-  function copyState(o1, o2) {
-    o2.fillStyle     = o1.fillStyle;
-    o2.lineCap       = o1.lineCap;
-    o2.lineJoin      = o1.lineJoin;
-    o2.lineWidth     = o1.lineWidth;
-    o2.miterLimit    = o1.miterLimit;
-    o2.shadowBlur    = o1.shadowBlur;
-    o2.shadowColor   = o1.shadowColor;
-    o2.shadowOffsetX = o1.shadowOffsetX;
-    o2.shadowOffsetY = o1.shadowOffsetY;
-    o2.strokeStyle   = o1.strokeStyle;
-    o2.globalAlpha   = o1.globalAlpha;
-    o2.font          = o1.font;
-    o2.textAlign     = o1.textAlign;
-    o2.textBaseline  = o1.textBaseline;
-    o2.arcScaleX_    = o1.arcScaleX_;
-    o2.arcScaleY_    = o1.arcScaleY_;
-    o2.lineScale_    = o1.lineScale_;
-  }
-
-  var colorData = {
-    aliceblue: '#F0F8FF',
-    antiquewhite: '#FAEBD7',
-    aquamarine: '#7FFFD4',
-    azure: '#F0FFFF',
-    beige: '#F5F5DC',
-    bisque: '#FFE4C4',
-    black: '#000000',
-    blanchedalmond: '#FFEBCD',
-    blueviolet: '#8A2BE2',
-    brown: '#A52A2A',
-    burlywood: '#DEB887',
-    cadetblue: '#5F9EA0',
-    chartreuse: '#7FFF00',
-    chocolate: '#D2691E',
-    coral: '#FF7F50',
-    cornflowerblue: '#6495ED',
-    cornsilk: '#FFF8DC',
-    crimson: '#DC143C',
-    cyan: '#00FFFF',
-    darkblue: '#00008B',
-    darkcyan: '#008B8B',
-    darkgoldenrod: '#B8860B',
-    darkgray: '#A9A9A9',
-    darkgreen: '#006400',
-    darkgrey: '#A9A9A9',
-    darkkhaki: '#BDB76B',
-    darkmagenta: '#8B008B',
-    darkolivegreen: '#556B2F',
-    darkorange: '#FF8C00',
-    darkorchid: '#9932CC',
-    darkred: '#8B0000',
-    darksalmon: '#E9967A',
-    darkseagreen: '#8FBC8F',
-    darkslateblue: '#483D8B',
-    darkslategray: '#2F4F4F',
-    darkslategrey: '#2F4F4F',
-    darkturquoise: '#00CED1',
-    darkviolet: '#9400D3',
-    deeppink: '#FF1493',
-    deepskyblue: '#00BFFF',
-    dimgray: '#696969',
-    dimgrey: '#696969',
-    dodgerblue: '#1E90FF',
-    firebrick: '#B22222',
-    floralwhite: '#FFFAF0',
-    forestgreen: '#228B22',
-    gainsboro: '#DCDCDC',
-    ghostwhite: '#F8F8FF',
-    gold: '#FFD700',
-    goldenrod: '#DAA520',
-    grey: '#808080',
-    greenyellow: '#ADFF2F',
-    honeydew: '#F0FFF0',
-    hotpink: '#FF69B4',
-    indianred: '#CD5C5C',
-    indigo: '#4B0082',
-    ivory: '#FFFFF0',
-    khaki: '#F0E68C',
-    lavender: '#E6E6FA',
-    lavenderblush: '#FFF0F5',
-    lawngreen: '#7CFC00',
-    lemonchiffon: '#FFFACD',
-    lightblue: '#ADD8E6',
-    lightcoral: '#F08080',
-    lightcyan: '#E0FFFF',
-    lightgoldenrodyellow: '#FAFAD2',
-    lightgreen: '#90EE90',
-    lightgrey: '#D3D3D3',
-    lightpink: '#FFB6C1',
-    lightsalmon: '#FFA07A',
-    lightseagreen: '#20B2AA',
-    lightskyblue: '#87CEFA',
-    lightslategray: '#778899',
-    lightslategrey: '#778899',
-    lightsteelblue: '#B0C4DE',
-    lightyellow: '#FFFFE0',
-    limegreen: '#32CD32',
-    linen: '#FAF0E6',
-    magenta: '#FF00FF',
-    mediumaquamarine: '#66CDAA',
-    mediumblue: '#0000CD',
-    mediumorchid: '#BA55D3',
-    mediumpurple: '#9370DB',
-    mediumseagreen: '#3CB371',
-    mediumslateblue: '#7B68EE',
-    mediumspringgreen: '#00FA9A',
-    mediumturquoise: '#48D1CC',
-    mediumvioletred: '#C71585',
-    midnightblue: '#191970',
-    mintcream: '#F5FFFA',
-    mistyrose: '#FFE4E1',
-    moccasin: '#FFE4B5',
-    navajowhite: '#FFDEAD',
-    oldlace: '#FDF5E6',
-    olivedrab: '#6B8E23',
-    orange: '#FFA500',
-    orangered: '#FF4500',
-    orchid: '#DA70D6',
-    palegoldenrod: '#EEE8AA',
-    palegreen: '#98FB98',
-    paleturquoise: '#AFEEEE',
-    palevioletred: '#DB7093',
-    papayawhip: '#FFEFD5',
-    peachpuff: '#FFDAB9',
-    peru: '#CD853F',
-    pink: '#FFC0CB',
-    plum: '#DDA0DD',
-    powderblue: '#B0E0E6',
-    rosybrown: '#BC8F8F',
-    royalblue: '#4169E1',
-    saddlebrown: '#8B4513',
-    salmon: '#FA8072',
-    sandybrown: '#F4A460',
-    seagreen: '#2E8B57',
-    seashell: '#FFF5EE',
-    sienna: '#A0522D',
-    skyblue: '#87CEEB',
-    slateblue: '#6A5ACD',
-    slategray: '#708090',
-    slategrey: '#708090',
-    snow: '#FFFAFA',
-    springgreen: '#00FF7F',
-    steelblue: '#4682B4',
-    tan: '#D2B48C',
-    thistle: '#D8BFD8',
-    tomato: '#FF6347',
-    turquoise: '#40E0D0',
-    violet: '#EE82EE',
-    wheat: '#F5DEB3',
-    whitesmoke: '#F5F5F5',
-    yellowgreen: '#9ACD32'
-  };
-
-
-  function getRgbHslContent(styleString) {
-    var start = styleString.indexOf('(', 3);
-    var end = styleString.indexOf(')', start + 1);
-    var parts = styleString.substring(start + 1, end).split(',');
-    // add alpha if needed
-    if (parts.length != 4 || styleString.charAt(3) != 'a') {
-      parts[3] = 1;
-    }
-    return parts;
-  }
-
-  function percent(s) {
-    return parseFloat(s) / 100;
-  }
-
-  function clamp(v, min, max) {
-    return Math.min(max, Math.max(min, v));
-  }
-
-  function hslToRgb(parts){
-    var r, g, b, h, s, l;
-    h = parseFloat(parts[0]) / 360 % 360;
-    if (h < 0)
-      h++;
-    s = clamp(percent(parts[1]), 0, 1);
-    l = clamp(percent(parts[2]), 0, 1);
-    if (s == 0) {
-      r = g = b = l; // achromatic
-    } else {
-      var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
-      var p = 2 * l - q;
-      r = hueToRgb(p, q, h + 1 / 3);
-      g = hueToRgb(p, q, h);
-      b = hueToRgb(p, q, h - 1 / 3);
-    }
-
-    return '#' + decToHex[Math.floor(r * 255)] +
-        decToHex[Math.floor(g * 255)] +
-        decToHex[Math.floor(b * 255)];
-  }
-
-  function hueToRgb(m1, m2, h) {
-    if (h < 0)
-      h++;
-    if (h > 1)
-      h--;
-
-    if (6 * h < 1)
-      return m1 + (m2 - m1) * 6 * h;
-    else if (2 * h < 1)
-      return m2;
-    else if (3 * h < 2)
-      return m1 + (m2 - m1) * (2 / 3 - h) * 6;
-    else
-      return m1;
-  }
-
-  var processStyleCache = {};
-
-  function processStyle(styleString) {
-    if (styleString in processStyleCache) {
-      return processStyleCache[styleString];
-    }
-
-    var str, alpha = 1;
-
-    styleString = String(styleString);
-    if (styleString.charAt(0) == '#') {
-      str = styleString;
-    } else if (/^rgb/.test(styleString)) {
-      var parts = getRgbHslContent(styleString);
-      var str = '#', n;
-      for (var i = 0; i < 3; i++) {
-        if (parts[i].indexOf('%') != -1) {
-          n = Math.floor(percent(parts[i]) * 255);
-        } else {
-          n = +parts[i];
-        }
-        str += decToHex[clamp(n, 0, 255)];
-      }
-      alpha = +parts[3];
-    } else if (/^hsl/.test(styleString)) {
-      var parts = getRgbHslContent(styleString);
-      str = hslToRgb(parts);
-      alpha = parts[3];
-    } else {
-      str = colorData[styleString] || styleString;
-    }
-    return processStyleCache[styleString] = {color: str, alpha: alpha};
-  }
-
-  var DEFAULT_STYLE = {
-    style: 'normal',
-    variant: 'normal',
-    weight: 'normal',
-    size: 10,
-    family: 'sans-serif'
-  };
-
-  // Internal text style cache
-  var fontStyleCache = {};
-
-  function processFontStyle(styleString) {
-    if (fontStyleCache[styleString]) {
-      return fontStyleCache[styleString];
-    }
-
-    var el = document.createElement('div');
-    var style = el.style;
-    try {
-      style.font = styleString;
-    } catch (ex) {
-      // Ignore failures to set to invalid font.
-    }
-
-    return fontStyleCache[styleString] = {
-      style: style.fontStyle || DEFAULT_STYLE.style,
-      variant: style.fontVariant || DEFAULT_STYLE.variant,
-      weight: style.fontWeight || DEFAULT_STYLE.weight,
-      size: style.fontSize || DEFAULT_STYLE.size,
-      family: style.fontFamily || DEFAULT_STYLE.family
-    };
-  }
-
-  function getComputedStyle(style, element) {
-    var computedStyle = {};
-
-    for (var p in style) {
-      computedStyle[p] = style[p];
-    }
-
-    // Compute the size
-    var canvasFontSize = parseFloat(element.currentStyle.fontSize),
-        fontSize = parseFloat(style.size);
-
-    if (typeof style.size == 'number') {
-      computedStyle.size = style.size;
-    } else if (style.size.indexOf('px') != -1) {
-      computedStyle.size = fontSize;
-    } else if (style.size.indexOf('em') != -1) {
-      computedStyle.size = canvasFontSize * fontSize;
-    } else if(style.size.indexOf('%') != -1) {
-      computedStyle.size = (canvasFontSize / 100) * fontSize;
-    } else if (style.size.indexOf('pt') != -1) {
-      computedStyle.size = fontSize / .75;
-    } else {
-      computedStyle.size = canvasFontSize;
-    }
-
-    // Different scaling between normal text and VML text. This was found using
-    // trial and error to get the same size as non VML text.
-    computedStyle.size *= 0.981;
-
-    // Fix for VML handling of bare font family names.  Add a '' around font family names.
-    computedStyle.family =  "'" + computedStyle.family.replace(/(\'|\")/g,'').replace(/\s*,\s*/g, "', '") + "'";
-
-    return computedStyle;
-  }
-
-  function buildStyle(style) {
-    return style.style + ' ' + style.variant + ' ' + style.weight + ' ' +
-        style.size + 'px ' + style.family;
-  }
-
-  var lineCapMap = {
-    'butt': 'flat',
-    'round': 'round'
-  };
-
-  function processLineCap(lineCap) {
-    return lineCapMap[lineCap] || 'square';
-  }
-
-  /**
-   * This class implements CanvasRenderingContext2D interface as described by
-   * the WHATWG.
-   * @param {HTMLElement} canvasElement The element that the 2D context should
-   * be associated with
-   */
-  function CanvasRenderingContext2D_(canvasElement) {
-    this.m_ = createMatrixIdentity();
-
-    this.mStack_ = [];
-    this.aStack_ = [];
-    this.currentPath_ = [];
-
-    // Canvas context properties
-    this.strokeStyle = '#000';
-    this.fillStyle = '#000';
-
-    this.lineWidth = 1;
-    this.lineJoin = 'miter';
-    this.lineCap = 'butt';
-    this.miterLimit = Z * 1;
-    this.globalAlpha = 1;
-    this.font = '10px sans-serif';
-    this.textAlign = 'left';
-    this.textBaseline = 'alphabetic';
-    this.canvas = canvasElement;
-
-    var cssText = 'width:' + canvasElement.clientWidth + 'px;height:' +
-        canvasElement.clientHeight + 'px;overflow:hidden;position:absolute';
-    var el = canvasElement.ownerDocument.createElement('div');
-    el.style.cssText = cssText;
-    canvasElement.appendChild(el);
-
-    var overlayEl = el.cloneNode(false);
-    // Use a non transparent background.
-    overlayEl.style.backgroundColor = 'red';
-    overlayEl.style.filter = 'alpha(opacity=0)';
-    canvasElement.appendChild(overlayEl);
-
-    this.element_ = el;
-    this.arcScaleX_ = 1;
-    this.arcScaleY_ = 1;
-    this.lineScale_ = 1;
-  }
-
-  var contextPrototype = CanvasRenderingContext2D_.prototype;
-  contextPrototype.clearRect = function() {
-    if (this.textMeasureEl_) {
-      this.textMeasureEl_.removeNode(true);
-      this.textMeasureEl_ = null;
-    }
-    this.element_.innerHTML = '';
-  };
-
-  contextPrototype.beginPath = function() {
-    // TODO: Branch current matrix so that save/restore has no effect
-    //       as per safari docs.
-    this.currentPath_ = [];
-  };
-
-  contextPrototype.moveTo = function(aX, aY) {
-    var p = getCoords(this, aX, aY);
-    this.currentPath_.push({type: 'moveTo', x: p.x, y: p.y});
-    this.currentX_ = p.x;
-    this.currentY_ = p.y;
-  };
-
-  contextPrototype.lineTo = function(aX, aY) {
-    var p = getCoords(this, aX, aY);
-    this.currentPath_.push({type: 'lineTo', x: p.x, y: p.y});
-
-    this.currentX_ = p.x;
-    this.currentY_ = p.y;
-  };
-
-  contextPrototype.bezierCurveTo = function(aCP1x, aCP1y,
-                                            aCP2x, aCP2y,
-                                            aX, aY) {
-    var p = getCoords(this, aX, aY);
-    var cp1 = getCoords(this, aCP1x, aCP1y);
-    var cp2 = getCoords(this, aCP2x, aCP2y);
-    bezierCurveTo(this, cp1, cp2, p);
-  };
-
-  // Helper function that takes the already fixed cordinates.
-  function bezierCurveTo(self, cp1, cp2, p) {
-    self.currentPath_.push({
-      type: 'bezierCurveTo',
-      cp1x: cp1.x,
-      cp1y: cp1.y,
-      cp2x: cp2.x,
-      cp2y: cp2.y,
-      x: p.x,
-      y: p.y
-    });
-    self.currentX_ = p.x;
-    self.currentY_ = p.y;
-  }
-
-  contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) {
-    // the following is lifted almost directly from
-    // http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes
-
-    var cp = getCoords(this, aCPx, aCPy);
-    var p = getCoords(this, aX, aY);
-
-    var cp1 = {
-      x: this.currentX_ + 2.0 / 3.0 * (cp.x - this.currentX_),
-      y: this.currentY_ + 2.0 / 3.0 * (cp.y - this.currentY_)
-    };
-    var cp2 = {
-      x: cp1.x + (p.x - this.currentX_) / 3.0,
-      y: cp1.y + (p.y - this.currentY_) / 3.0
-    };
-
-    bezierCurveTo(this, cp1, cp2, p);
-  };
-
-  contextPrototype.arc = function(aX, aY, aRadius,
-                                  aStartAngle, aEndAngle, aClockwise) {
-    aRadius *= Z;
-    var arcType = aClockwise ? 'at' : 'wa';
-
-    var xStart = aX + mc(aStartAngle) * aRadius - Z2;
-    var yStart = aY + ms(aStartAngle) * aRadius - Z2;
-
-    var xEnd = aX + mc(aEndAngle) * aRadius - Z2;
-    var yEnd = aY + ms(aEndAngle) * aRadius - Z2;
-
-    // IE won't render arches drawn counter clockwise if xStart == xEnd.
-    if (xStart == xEnd && !aClockwise) {
-      xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something
-                       // that can be represented in binary
-    }
-
-    var p = getCoords(this, aX, aY);
-    var pStart = getCoords(this, xStart, yStart);
-    var pEnd = getCoords(this, xEnd, yEnd);
-
-    this.currentPath_.push({type: arcType,
-                           x: p.x,
-                           y: p.y,
-                           radius: aRadius,
-                           xStart: pStart.x,
-                           yStart: pStart.y,
-                           xEnd: pEnd.x,
-                           yEnd: pEnd.y});
-
-  };
-
-  contextPrototype.rect = function(aX, aY, aWidth, aHeight) {
-    this.moveTo(aX, aY);
-    this.lineTo(aX + aWidth, aY);
-    this.lineTo(aX + aWidth, aY + aHeight);
-    this.lineTo(aX, aY + aHeight);
-    this.closePath();
-  };
-
-  contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) {
-    var oldPath = this.currentPath_;
-    this.beginPath();
-
-    this.moveTo(aX, aY);
-    this.lineTo(aX + aWidth, aY);
-    this.lineTo(aX + aWidth, aY + aHeight);
-    this.lineTo(aX, aY + aHeight);
-    this.closePath();
-    this.stroke();
-
-    this.currentPath_ = oldPath;
-  };
-
-  contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) {
-    var oldPath = this.currentPath_;
-    this.beginPath();
-
-    this.moveTo(aX, aY);
-    this.lineTo(aX + aWidth, aY);
-    this.lineTo(aX + aWidth, aY + aHeight);
-    this.lineTo(aX, aY + aHeight);
-    this.closePath();
-    this.fill();
-
-    this.currentPath_ = oldPath;
-  };
-
-  contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) {
-    var gradient = new CanvasGradient_('gradient');
-    gradient.x0_ = aX0;
-    gradient.y0_ = aY0;
-    gradient.x1_ = aX1;
-    gradient.y1_ = aY1;
-    return gradient;
-  };
-
-  contextPrototype.createRadialGradient = function(aX0, aY0, aR0,
-                                                   aX1, aY1, aR1) {
-    var gradient = new CanvasGradient_('gradientradial');
-    gradient.x0_ = aX0;
-    gradient.y0_ = aY0;
-    gradient.r0_ = aR0;
-    gradient.x1_ = aX1;
-    gradient.y1_ = aY1;
-    gradient.r1_ = aR1;
-    return gradient;
-  };
-
-  contextPrototype.drawImage = function(image, var_args) {
-    var dx, dy, dw, dh, sx, sy, sw, sh;
-
-    // to find the original width we overide the width and height
-    var oldRuntimeWidth = image.runtimeStyle.width;
-    var oldRuntimeHeight = image.runtimeStyle.height;
-    image.runtimeStyle.width = 'auto';
-    image.runtimeStyle.height = 'auto';
-
-    // get the original size
-    var w = image.width;
-    var h = image.height;
-
-    // and remove overides
-    image.runtimeStyle.width = oldRuntimeWidth;
-    image.runtimeStyle.height = oldRuntimeHeight;
-
-    if (arguments.length == 3) {
-      dx = arguments[1];
-      dy = arguments[2];
-      sx = sy = 0;
-      sw = dw = w;
-      sh = dh = h;
-    } else if (arguments.length == 5) {
-      dx = arguments[1];
-      dy = arguments[2];
-      dw = arguments[3];
-      dh = arguments[4];
-      sx = sy = 0;
-      sw = w;
-      sh = h;
-    } else if (arguments.length == 9) {
-      sx = arguments[1];
-      sy = arguments[2];
-      sw = arguments[3];
-      sh = arguments[4];
-      dx = arguments[5];
-      dy = arguments[6];
-      dw = arguments[7];
-      dh = arguments[8];
-    } else {
-      throw Error('Invalid number of arguments');
-    }
-
-    var d = getCoords(this, dx, dy);
-
-    var w2 = sw / 2;
-    var h2 = sh / 2;
-
-    var vmlStr = [];
-
-    var W = 10;
-    var H = 10;
-
-    // For some reason that I've now forgotten, using divs didn't work
-    vmlStr.push(' <g_vml_:group',
-                ' coordsize="', Z * W, ',', Z * H, '"',
-                ' coordorigin="0,0"' ,
-                ' style="width:', W, 'px;height:', H, 'px;position:absolute;');
-
-    // If filters are necessary (rotation exists), create them
-    // filters are bog-slow, so only create them if abbsolutely necessary
-    // The following check doesn't account for skews (which don't exist
-    // in the canvas spec (yet) anyway.
-
-    if (this.m_[0][0] != 1 || this.m_[0][1] ||
-        this.m_[1][1] != 1 || this.m_[1][0]) {
-      var filter = [];
-
-      // Note the 12/21 reversal
-      filter.push('M11=', this.m_[0][0], ',',
-                  'M12=', this.m_[1][0], ',',
-                  'M21=', this.m_[0][1], ',',
-                  'M22=', this.m_[1][1], ',',
-                  'Dx=', mr(d.x / Z), ',',
-                  'Dy=', mr(d.y / Z), '');
-
-      // Bounding box calculation (need to minimize displayed area so that
-      // filters don't waste time on unused pixels.
-      var max = d;
-      var c2 = getCoords(this, dx + dw, dy);
-      var c3 = getCoords(this, dx, dy + dh);
-      var c4 = getCoords(this, dx + dw, dy + dh);
-
-      max.x = m.max(max.x, c2.x, c3.x, c4.x);
-      max.y = m.max(max.y, c2.y, c3.y, c4.y);
-
-      vmlStr.push('padding:0 ', mr(max.x / Z), 'px ', mr(max.y / Z),
-                  'px 0;filter:progid:DXImageTransform.Microsoft.Matrix(',
-                  filter.join(''), ", sizingmethod='clip');");
-
-    } else {
-      vmlStr.push('top:', mr(d.y / Z), 'px;left:', mr(d.x / Z), 'px;');
-    }
-
-    vmlStr.push(' ">' ,
-                '<g_vml_:image src="', image.src, '"',
-                ' style="width:', Z * dw, 'px;',
-                ' height:', Z * dh, 'px"',
-                ' cropleft="', sx / w, '"',
-                ' croptop="', sy / h, '"',
-                ' cropright="', (w - sx - sw) / w, '"',
-                ' cropbottom="', (h - sy - sh) / h, '"',
-                ' />',
-                '</g_vml_:group>');
-
-    this.element_.insertAdjacentHTML('BeforeEnd', vmlStr.join(''));
-  };
-
-  contextPrototype.stroke = function(aFill) {
-    var lineStr = [];
-    var lineOpen = false;
-
-    var W = 10;
-    var H = 10;
-
-    lineStr.push('<g_vml_:shape',
-                 ' filled="', !!aFill, '"',
-                 ' style="position:absolute;width:', W, 'px;height:', H, 'px;"',
-                 ' coordorigin="0,0"',
-                 ' coordsize="', Z * W, ',', Z * H, '"',
-                 ' stroked="', !aFill, '"',
-                 ' path="');
-
-    var newSeq = false;
-    var min = {x: null, y: null};
-    var max = {x: null, y: null};
-
-    for (var i = 0; i < this.currentPath_.length; i++) {
-      var p = this.currentPath_[i];
-      var c;
-
-      switch (p.type) {
-        case 'moveTo':
-          c = p;
-          lineStr.push(' m ', mr(p.x), ',', mr(p.y));
-          break;
-        case 'lineTo':
-          lineStr.push(' l ', mr(p.x), ',', mr(p.y));
-          break;
-        case 'close':
-          lineStr.push(' x ');
-          p = null;
-          break;
-        case 'bezierCurveTo':
-          lineStr.push(' c ',
-                       mr(p.cp1x), ',', mr(p.cp1y), ',',
-                       mr(p.cp2x), ',', mr(p.cp2y), ',',
-                       mr(p.x), ',', mr(p.y));
-          break;
-        case 'at':
-        case 'wa':
-          lineStr.push(' ', p.type, ' ',
-                       mr(p.x - this.arcScaleX_ * p.radius), ',',
-                       mr(p.y - this.arcScaleY_ * p.radius), ' ',
-                       mr(p.x + this.arcScaleX_ * p.radius), ',',
-                       mr(p.y + this.arcScaleY_ * p.radius), ' ',
-                       mr(p.xStart), ',', mr(p.yStart), ' ',
-                       mr(p.xEnd), ',', mr(p.yEnd));
-          break;
-      }
-
-
-      // TODO: Following is broken for curves due to
-      //       move to proper paths.
-
-      // Figure out dimensions so we can do gradient fills
-      // properly
-      if (p) {
-        if (min.x == null || p.x < min.x) {
-          min.x = p.x;
-        }
-        if (max.x == null || p.x > max.x) {
-          max.x = p.x;
-        }
-        if (min.y == null || p.y < min.y) {
-          min.y = p.y;
-        }
-        if (max.y == null || p.y > max.y) {
-          max.y = p.y;
-        }
-      }
-    }
-    lineStr.push(' ">');
-
-    if (!aFill) {
-      appendStroke(this, lineStr);
-    } else {
-      appendFill(this, lineStr, min, max);
-    }
-
-    lineStr.push('</g_vml_:shape>');
-
-    this.element_.insertAdjacentHTML('beforeEnd', lineStr.join(''));
-  };
-
-  function appendStroke(ctx, lineStr) {
-    var a = processStyle(ctx.strokeStyle);
-    var color = a.color;
-    var opacity = a.alpha * ctx.globalAlpha;
-    var lineWidth = ctx.lineScale_ * ctx.lineWidth;
-
-    // VML cannot correctly render a line if the width is less than 1px.
-    // In that case, we dilute the color to make the line look thinner.
-    if (lineWidth < 1) {
-      opacity *= lineWidth;
-    }
-
-    lineStr.push(
-      '<g_vml_:stroke',
-      ' opacity="', opacity, '"',
-      ' joinstyle="', ctx.lineJoin, '"',
-      ' miterlimit="', ctx.miterLimit, '"',
-      ' endcap="', processLineCap(ctx.lineCap), '"',
-      ' weight="', lineWidth, 'px"',
-      ' color="', color, '" />'
-    );
-  }
-
-  function appendFill(ctx, lineStr, min, max) {
-    var fillStyle = ctx.fillStyle;
-    var arcScaleX = ctx.arcScaleX_;
-    var arcScaleY = ctx.arcScaleY_;
-    var width = max.x - min.x;
-    var height = max.y - min.y;
-    if (fillStyle instanceof CanvasGradient_) {
-      // TODO: Gradients transformed with the transformation matrix.
-      var angle = 0;
-      var focus = {x: 0, y: 0};
-
-      // additional offset
-      var shift = 0;
-      // scale factor for offset
-      var expansion = 1;
-
-      if (fillStyle.type_ == 'gradient') {
-        var x0 = fillStyle.x0_ / arcScaleX;
-        var y0 = fillStyle.y0_ / arcScaleY;
-        var x1 = fillStyle.x1_ / arcScaleX;
-        var y1 = fillStyle.y1_ / arcScaleY;
-        var p0 = getCoords(ctx, x0, y0);
-        var p1 = getCoords(ctx, x1, y1);
-        var dx = p1.x - p0.x;
-        var dy = p1.y - p0.y;
-        angle = Math.atan2(dx, dy) * 180 / Math.PI;
-
-        // The angle should be a non-negative number.
-        if (angle < 0) {
-          angle += 360;
-        }
-
-        // Very small angles produce an unexpected result because they are
-        // converted to a scientific notation string.
-        if (angle < 1e-6) {
-          angle = 0;
-        }
-      } else {
-        var p0 = getCoords(ctx, fillStyle.x0_, fillStyle.y0_);
-        focus = {
-          x: (p0.x - min.x) / width,
-          y: (p0.y - min.y) / height
-        };
-
-        width  /= arcScaleX * Z;
-        height /= arcScaleY * Z;
-        var dimension = m.max(width, height);
-        shift = 2 * fillStyle.r0_ / dimension;
-        expansion = 2 * fillStyle.r1_ / dimension - shift;
-      }
-
-      // We need to sort the color stops in ascending order by offset,
-      // otherwise IE won't interpret it correctly.
-      var stops = fillStyle.colors_;
-      stops.sort(function(cs1, cs2) {
-        return cs1.offset - cs2.offset;
-      });
-
-      var length = stops.length;
-      var color1 = stops[0].color;
-      var color2 = stops[length - 1].color;
-      var opacity1 = stops[0].alpha * ctx.globalAlpha;
-      var opacity2 = stops[length - 1].alpha * ctx.globalAlpha;
-
-      var colors = [];
-      for (var i = 0; i < length; i++) {
-        var stop = stops[i];
-        colors.push(stop.offset * expansion + shift + ' ' + stop.color);
-      }
-
-      // When colors attribute is used, the meanings of opacity and o:opacity2
-      // are reversed.
-      lineStr.push('<g_vml_:fill type="', fillStyle.type_, '"',
-                   ' method="none" focus="100%"',
-                   ' color="', color1, '"',
-                   ' color2="', color2, '"',
-                   ' colors="', colors.join(','), '"',
-                   ' opacity="', opacity2, '"',
-                   ' g_o_:opacity2="', opacity1, '"',
-                   ' angle="', angle, '"',
-                   ' focusposition="', focus.x, ',', focus.y, '" />');
-    } else if (fillStyle instanceof CanvasPattern_) {
-      if (width && height) {
-        var deltaLeft = -min.x;
-        var deltaTop = -min.y;
-        lineStr.push('<g_vml_:fill',
-                     ' position="',
-                     deltaLeft / width * arcScaleX * arcScaleX, ',',
-                     deltaTop / height * arcScaleY * arcScaleY, '"',
-                     ' type="tile"',
-                     // TODO: Figure out the correct size to fit the scale.
-                     //' size="', w, 'px ', h, 'px"',
-                     ' src="', fillStyle.src_, '" />');
-       }
-    } else {
-      var a = processStyle(ctx.fillStyle);
-      var color = a.color;
-      var opacity = a.alpha * ctx.globalAlpha;
-      lineStr.push('<g_vml_:fill color="', color, '" opacity="', opacity,
-                   '" />');
-    }
-  }
-
-  contextPrototype.fill = function() {
-    this.stroke(true);
-  };
-
-  contextPrototype.closePath = function() {
-    this.currentPath_.push({type: 'close'});
-  };
-
-  function getCoords(ctx, aX, aY) {
-    var m = ctx.m_;
-    return {
-      x: Z * (aX * m[0][0] + aY * m[1][0] + m[2][0]) - Z2,
-      y: Z * (aX * m[0][1] + aY * m[1][1] + m[2][1]) - Z2
-    };
-  };
-
-  contextPrototype.save = function() {
-    var o = {};
-    copyState(this, o);
-    this.aStack_.push(o);
-    this.mStack_.push(this.m_);
-    this.m_ = matrixMultiply(createMatrixIdentity(), this.m_);
-  };
-
-  contextPrototype.restore = function() {
-    if (this.aStack_.length) {
-      copyState(this.aStack_.pop(), this);
-      this.m_ = this.mStack_.pop();
-    }
-  };
-
-  function matrixIsFinite(m) {
-    return isFinite(m[0][0]) && isFinite(m[0][1]) &&
-        isFinite(m[1][0]) && isFinite(m[1][1]) &&
-        isFinite(m[2][0]) && isFinite(m[2][1]);
-  }
-
-  function setM(ctx, m, updateLineScale) {
-    if (!matrixIsFinite(m)) {
-      return;
-    }
-    ctx.m_ = m;
-
-    if (updateLineScale) {
-      // Get the line scale.
-      // Determinant of this.m_ means how much the area is enlarged by the
-      // transformation. So its square root can be used as a scale factor
-      // for width.
-      var det = m[0][0] * m[1][1] - m[0][1] * m[1][0];
-      ctx.lineScale_ = sqrt(abs(det));
-    }
-  }
-
-  contextPrototype.translate = function(aX, aY) {
-    var m1 = [
-      [1,  0,  0],
-      [0,  1,  0],
-      [aX, aY, 1]
-    ];
-
-    setM(this, matrixMultiply(m1, this.m_), false);
-  };
-
-  contextPrototype.rotate = function(aRot) {
-    var c = mc(aRot);
-    var s = ms(aRot);
-
-    var m1 = [
-      [c,  s, 0],
-      [-s, c, 0],
-      [0,  0, 1]
-    ];
-
-    setM(this, matrixMultiply(m1, this.m_), false);
-  };
-
-  contextPrototype.scale = function(aX, aY) {
-    this.arcScaleX_ *= aX;
-    this.arcScaleY_ *= aY;
-    var m1 = [
-      [aX, 0,  0],
-      [0,  aY, 0],
-      [0,  0,  1]
-    ];
-
-    setM(this, matrixMultiply(m1, this.m_), true);
-  };
-
-  contextPrototype.transform = function(m11, m12, m21, m22, dx, dy) {
-    var m1 = [
-      [m11, m12, 0],
-      [m21, m22, 0],
-      [dx,  dy,  1]
-    ];
-
-    setM(this, matrixMultiply(m1, this.m_), true);
-  };
-
-  contextPrototype.setTransform = function(m11, m12, m21, m22, dx, dy) {
-    var m = [
-      [m11, m12, 0],
-      [m21, m22, 0],
-      [dx,  dy,  1]
-    ];
-
-    setM(this, m, true);
-  };
-
-  /**
-   * The text drawing function.
-   * The maxWidth argument isn't taken in account, since no browser supports
-   * it yet.
-   */
-  contextPrototype.drawText_ = function(text, x, y, maxWidth, stroke) {
-    var m = this.m_,
-        delta = 1000,
-        left = 0,
-        right = delta,
-        offset = {x: 0, y: 0},
-        lineStr = [];
-
-    var fontStyle = getComputedStyle(processFontStyle(this.font), this.element_);
-
-    var fontStyleString = buildStyle(fontStyle);
-
-    var elementStyle = this.element_.currentStyle;
-    var textAlign = this.textAlign.toLowerCase();
-    switch (textAlign) {
-      case 'left':
-      case 'center':
-      case 'right':
-        break;
-      case 'end':
-        textAlign = elementStyle.direction == 'ltr' ? 'right' : 'left';
-        break;
-      case 'start':
-        textAlign = elementStyle.direction == 'rtl' ? 'right' : 'left';
-        break;
-      default:
-        textAlign = 'left';
-    }
-
-    // 1.75 is an arbitrary number, as there is no info about the text baseline
-    switch (this.textBaseline) {
-      case 'hanging':
-      case 'top':
-        offset.y = fontStyle.size / 1.75;
-        break;
-      case 'middle':
-        break;
-      default:
-      case null:
-      case 'alphabetic':
-      case 'ideographic':
-      case 'bottom':
-        offset.y = -fontStyle.size / 2.25;
-        break;
-    }
-
-    switch(textAlign) {
-      case 'right':
-        left = delta;
-        right = 0.05;
-        break;
-      case 'center':
-        left = right = delta / 2;
-        break;
-    }
-
-    var d = getCoords(this, x + offset.x, y + offset.y);
-
-    lineStr.push('<g_vml_:line from="', -left ,' 0" to="', right ,' 0.05" ',
-                 ' coordsize="100 100" coordorigin="0 0"',
-                 ' filled="', !stroke, '" stroked="', !!stroke,
-                 '" style="position:absolute;width:1px;height:1px;">');
-
-    if (stroke) {
-      appendStroke(this, lineStr);
-    } else {
-      // TODO: Fix the min and max params.
-      appendFill(this, lineStr, {x: -left, y: 0},
-                 {x: right, y: fontStyle.size});
-    }
-
-    var skewM = m[0][0].toFixed(3) + ',' + m[1][0].toFixed(3) + ',' +
-                m[0][1].toFixed(3) + ',' + m[1][1].toFixed(3) + ',0,0';
-
-    var skewOffset = mr(d.x / Z + 1 - m[0][0]) + ',' + mr(d.y / Z - 2 * m[1][0]);
-
-
-    lineStr.push('<g_vml_:skew on="t" matrix="', skewM ,'" ',
-                 ' offset="', skewOffset, '" origin="', left ,' 0" />',
-                 '<g_vml_:path textpathok="true" />',
-                 '<g_vml_:textpath on="true" string="',
-                 encodeHtmlAttribute(text),
-                 '" style="v-text-align:', textAlign,
-                 ';font:', encodeHtmlAttribute(fontStyleString),
-                 '" /></g_vml_:line>');
-
-    this.element_.insertAdjacentHTML('beforeEnd', lineStr.join(''));
-  };
-
-  contextPrototype.fillText = function(text, x, y, maxWidth) {
-    this.drawText_(text, x, y, maxWidth, false);
-  };
-
-  contextPrototype.strokeText = function(text, x, y, maxWidth) {
-    this.drawText_(text, x, y, maxWidth, true);
-  };
-
-  contextPrototype.measureText = function(text) {
-    if (!this.textMeasureEl_) {
-      var s = '<span style="position:absolute;' +
-          'top:-20000px;left:0;padding:0;margin:0;border:none;' +
-          'white-space:pre;"></span>';
-      this.element_.insertAdjacentHTML('beforeEnd', s);
-      this.textMeasureEl_ = this.element_.lastChild;
-    }
-    var doc = this.element_.ownerDocument;
-    this.textMeasureEl_.innerHTML = '';
-    this.textMeasureEl_.style.font = this.font;
-    // Don't use innerHTML or innerText because they allow markup/whitespace.
-    this.textMeasureEl_.appendChild(doc.createTextNode(text));
-    return {width: this.textMeasureEl_.offsetWidth};
-  };
-
-  /******** STUBS ********/
-  contextPrototype.clip = function() {
-    // TODO: Implement
-  };
-
-  contextPrototype.arcTo = function() {
-    // TODO: Implement
-  };
-
-  contextPrototype.createPattern = function(image, repetition) {
-    return new CanvasPattern_(image, repetition);
-  };
-
-  // Gradient / Pattern Stubs
-  function CanvasGradient_(aType) {
-    this.type_ = aType;
-    this.x0_ = 0;
-    this.y0_ = 0;
-    this.r0_ = 0;
-    this.x1_ = 0;
-    this.y1_ = 0;
-    this.r1_ = 0;
-    this.colors_ = [];
-  }
-
-  CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) {
-    aColor = processStyle(aColor);
-    this.colors_.push({offset: aOffset,
-                       color: aColor.color,
-                       alpha: aColor.alpha});
-  };
-
-  function CanvasPattern_(image, repetition) {
-    assertImageIsValid(image);
-    switch (repetition) {
-      case 'repeat':
-      case null:
-      case '':
-        this.repetition_ = 'repeat';
-        break;
-      case 'repeat-x':
-      case 'repeat-y':
-      case 'no-repeat':
-        this.repetition_ = repetition;
-        break;
-      default:
-        throwException('SYNTAX_ERR');
-    }
-
-    this.src_ = image.src;
-    this.width_ = image.width;
-    this.height_ = image.height;
-  }
-
-  function throwException(s) {
-    throw new DOMException_(s);
-  }
-
-  function assertImageIsValid(img) {
-    if (!img || img.nodeType != 1 || img.tagName != 'IMG') {
-      throwException('TYPE_MISMATCH_ERR');
-    }
-    if (img.readyState != 'complete') {
-      throwException('INVALID_STATE_ERR');
-    }
-  }
-
-  function DOMException_(s) {
-    this.code = this[s];
-    this.message = s +': DOM Exception ' + this.code;
-  }
-  var p = DOMException_.prototype = new Error;
-  p.INDEX_SIZE_ERR = 1;
-  p.DOMSTRING_SIZE_ERR = 2;
-  p.HIERARCHY_REQUEST_ERR = 3;
-  p.WRONG_DOCUMENT_ERR = 4;
-  p.INVALID_CHARACTER_ERR = 5;
-  p.NO_DATA_ALLOWED_ERR = 6;
-  p.NO_MODIFICATION_ALLOWED_ERR = 7;
-  p.NOT_FOUND_ERR = 8;
-  p.NOT_SUPPORTED_ERR = 9;
-  p.INUSE_ATTRIBUTE_ERR = 10;
-  p.INVALID_STATE_ERR = 11;
-  p.SYNTAX_ERR = 12;
-  p.INVALID_MODIFICATION_ERR = 13;
-  p.NAMESPACE_ERR = 14;
-  p.INVALID_ACCESS_ERR = 15;
-  p.VALIDATION_ERR = 16;
-  p.TYPE_MISMATCH_ERR = 17;
-
-  // set up externs
-  G_vmlCanvasManager = G_vmlCanvasManager_;
-  CanvasRenderingContext2D = CanvasRenderingContext2D_;
-  CanvasGradient = CanvasGradient_;
-  CanvasPattern = CanvasPattern_;
-  DOMException = DOMException_;
-  G_vmlCanvasManager._version = 888;
-})();
-
-} // if
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/excanvas.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/excanvas.min.js
deleted file mode 100644
index 6452abf..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/excanvas.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: @VERSION
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-if(!document.createElement("canvas").getContext){(function(){var ab=Math;var n=ab.round;var l=ab.sin;var A=ab.cos;var H=ab.abs;var N=ab.sqrt;var d=10;var f=d/2;var z=+navigator.userAgent.match(/MSIE ([\d.]+)?/)[1];function y(){return this.context_||(this.context_=new D(this))}var t=Array.prototype.slice;function g(j,m,p){var i=t.call(arguments,2);return function(){return j.apply(m,i.concat(t.call(arguments)))}}function af(i){return String(i).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Y(m,j,i){if(!m.namespaces[j]){m.namespaces.add(j,i,"#default#VML")}}function R(j){Y(j,"g_vml_","urn:schemas-microsoft-com:vml");Y(j,"g_o_","urn:schemas-microsoft-com:office:office");if(!j.styleSheets.ex_canvas_){var i=j.createStyleSheet();i.owningElement.id="ex_canvas_";i.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}"}}R(document);var e={init:function(i){var j=i||document;j.createElement("canvas");j.attachEvent("onreadystatechange",g(this.init_,this,j))},init_:function(p){var m=p.getElementsByTagName("canvas");for(var j=0;j<m.length;j++){this.initElement(m[j])}},initElement:function(j){if(!j.getContext){j.getContext=y;R(j.ownerDocument);j.innerHTML="";j.attachEvent("onpropertychange",x);j.attachEvent("onresize",W);var i=j.attributes;if(i.width&&i.width.specified){j.style.width=i.width.nodeValue+"px"}else{j.width=j.clientWidth}if(i.height&&i.height.specified){j.style.height=i.height.nodeValue+"px"}else{j.height=j.clientHeight}}return j},uninitElement:function(j){if(j.getContext){var i=j.getContext();delete i.element_;delete i.canvas;j.innerHTML="";j.context_=null;j.getContext=null;j.detachEvent("onpropertychange",x);j.detachEvent("onresize",W)}}};function x(j){var i=j.srcElement;switch(j.propertyName){case"width":i.getContext().clearRect();i.style.width=i.attributes.width.nodeValue+"px";i.firstChild.style.width=i.clientWidth+"px";break;case"height":i.getContext().clearRect();i.style.height=i.attributes.height.nodeValue+"px";i.firstChild.style.height=i.clientHeight+"px";break}}function W(j){var i=j.srcElement;if(i.firstChild){i.firstChild.style.width=i.clientWidth+"px";i.firstChild.style.height=i.clientHeight+"px"}}e.init();var k=[];for(var ae=0;ae<16;ae++){for(var ad=0;ad<16;ad++){k[ae*16+ad]=ae.toString(16)+ad.toString(16)}}function B(){return[[1,0,0],[0,1,0],[0,0,1]]}function J(p,m){var j=B();for(var i=0;i<3;i++){for(var ah=0;ah<3;ah++){var Z=0;for(var ag=0;ag<3;ag++){Z+=p[i][ag]*m[ag][ah]}j[i][ah]=Z}}return j}function v(j,i){i.fillStyle=j.fillStyle;i.lineCap=j.lineCap;i.lineJoin=j.lineJoin;i.lineWidth=j.lineWidth;i.miterLimit=j.miterLimit;i.shadowBlur=j.shadowBlur;i.shadowColor=j.shadowColor;i.shadowOffsetX=j.shadowOffsetX;i.shadowOffsetY=j.shadowOffsetY;i.strokeStyle=j.strokeStyle;i.globalAlpha=j.globalAlpha;i.font=j.font;i.textAlign=j.textAlign;i.textBaseline=j.textBaseline;i.arcScaleX_=j.arcScaleX_;i.arcScaleY_=j.arcScaleY_;i.lineScale_=j.lineScale_}var b={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",grey:"#808080",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",oldlace:"#FDF5E6",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",whitesmoke:"#F5F5F5",yellowgreen:"#9ACD32"};function M(j){var p=j.indexOf("(",3);var i=j.indexOf(")",p+1);var m=j.substring(p+1,i).split(",");if(m.length!=4||j.charAt(3)!="a"){m[3]=1}return m}function c(i){return parseFloat(i)/100}function r(j,m,i){return Math.min(i,Math.max(m,j))}function I(ag){var i,ai,aj,ah,ak,Z;ah=parseFloat(ag[0])/360%360;if(ah<0){ah++}ak=r(c(ag[1]),0,1);Z=r(c(ag[2]),0,1);if(ak==0){i=ai=aj=Z}else{var j=Z<0.5?Z*(1+ak):Z+ak-Z*ak;var m=2*Z-j;i=a(m,j,ah+1/3);ai=a(m,j,ah);aj=a(m,j,ah-1/3)}return"#"+k[Math.floor(i*255)]+k[Math.floor(ai*255)]+k[Math.floor(aj*255)]}function a(j,i,m){if(m<0){m++}if(m>1){m--}if(6*m<1){return j+(i-j)*6*m}else{if(2*m<1){return i}else{if(3*m<2){return j+(i-j)*(2/3-m)*6}else{return j}}}}var C={};function F(j){if(j in C){return C[j]}var ag,Z=1;j=String(j);if(j.charAt(0)=="#"){ag=j}else{if(/^rgb/.test(j)){var p=M(j);var ag="#",ah;for(var m=0;m<3;m++){if(p[m].indexOf("%")!=-1){ah=Math.floor(c(p[m])*255)}else{ah=+p[m]}ag+=k[r(ah,0,255)]}Z=+p[3]}else{if(/^hsl/.test(j)){var p=M(j);ag=I(p);Z=p[3]}else{ag=b[j]||j}}}return C[j]={color:ag,alpha:Z}}var o={style:"normal",variant:"normal",weight:"normal",size:10,family:"sans-serif"};var L={};function E(i){if(L[i]){return L[i]}var p=document.createElement("div");var m=p.style;try{m.font=i}catch(j){}return L[i]={style:m.fontStyle||o.style,variant:m.fontVariant||o.variant,weight:m.fontWeight||o.weight,size:m.fontSize||o.size,family:m.fontFamily||o.family}}function u(m,j){var i={};for(var ah in m){i[ah]=m[ah]}var ag=parseFloat(j.currentStyle.fontSize),Z=parseFloat(m.size);if(typeof m.size=="number"){i.size=m.size}else{if(m.size.indexOf("px")!=-1){i.size=Z}else{if(m.size.indexOf("em")!=-1){i.size=ag*Z}else{if(m.size.indexOf("%")!=-1){i.size=(ag/100)*Z}else{if(m.size.indexOf("pt")!=-1){i.size=Z/0.75}else{i.size=ag}}}}}i.size*=0.981;i.family="'"+i.family.replace(/(\'|\")/g,"").replace(/\s*,\s*/g,"', '")+"'";return i}function ac(i){return i.style+" "+i.variant+" "+i.weight+" "+i.size+"px "+i.family}var s={butt:"flat",round:"round"};function S(i){return s[i]||"square"}function D(i){this.m_=B();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.strokeStyle="#000";this.fillStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=d*1;this.globalAlpha=1;this.font="10px sans-serif";this.textAlign="left";this.textBaseline="alphabetic";this.canvas=i;var m="width:"+i.clientWidth+"px;height:"+i.clientHeight+"px;overflow:hidden;position:absolute";var j=i.ownerDocument.createElement("div");j.style.cssText=m;i.appendChild(j);var p=j.cloneNode(false);p.style.backgroundColor="red";p.style.filter="alpha(opacity=0)";i.appendChild(p);this.element_=j;this.arcScaleX_=1;this.arcScaleY_=1;this.lineScale_=1}var q=D.prototype;q.clearRect=function(){if(this.textMeasureEl_){this.textMeasureEl_.removeNode(true);this.textMeasureEl_=null}this.element_.innerHTML=""};q.beginPath=function(){this.currentPath_=[]};q.moveTo=function(j,i){var m=V(this,j,i);this.currentPath_.push({type:"moveTo",x:m.x,y:m.y});this.currentX_=m.x;this.currentY_=m.y};q.lineTo=function(j,i){var m=V(this,j,i);this.currentPath_.push({type:"lineTo",x:m.x,y:m.y});this.currentX_=m.x;this.currentY_=m.y};q.bezierCurveTo=function(m,j,ak,aj,ai,ag){var i=V(this,ai,ag);var ah=V(this,m,j);var Z=V(this,ak,aj);K(this,ah,Z,i)};function K(i,Z,m,j){i.currentPath_.push({type:"bezierCurveTo",cp1x:Z.x,cp1y:Z.y,cp2x:m.x,cp2y:m.y,x:j.x,y:j.y});i.currentX_=j.x;i.currentY_=j.y}q.quadraticCurveTo=function(ai,m,j,i){var ah=V(this,ai,m);var ag=V(this,j,i);var aj={x:this.currentX_+2/3*(ah.x-this.currentX_),y:this.currentY_+2/3*(ah.y-this.currentY_)};var Z={x:aj.x+(ag.x-this.currentX_)/3,y:aj.y+(ag.y-this.currentY_)/3};K(this,aj,Z,ag)};q.arc=function(al,aj,ak,ag,j,m){ak*=d;var ap=m?"at":"wa";var am=al+A(ag)*ak-f;var ao=aj+l(ag)*ak-f;var i=al+A(j)*ak-f;var an=aj+l(j)*ak-f;if(am==i&&!m){am+=0.125}var Z=V(this,al,aj);var ai=V(this,am,ao);var ah=V(this,i,an);this.currentPath_.push({type:ap,x:Z.x,y:Z.y,radius:ak,xStart:ai.x,yStart:ai.y,xEnd:ah.x,yEnd:ah.y})};q.rect=function(m,j,i,p){this.moveTo(m,j);this.lineTo(m+i,j);this.lineTo(m+i,j+p);this.lineTo(m,j+p);this.closePath()};q.strokeRect=function(m,j,i,p){var Z=this.currentPath_;this.beginPath();this.moveTo(m,j);this.lineTo(m+i,j);this.lineTo(m+i,j+p);this.lineTo(m,j+p);this.closePath();this.stroke();this.currentPath_=Z};q.fillRect=function(m,j,i,p){var Z=this.currentPath_;this.beginPath();this.moveTo(m,j);this.lineTo(m+i,j);this.lineTo(m+i,j+p);this.lineTo(m,j+p);this.closePath();this.fill();this.currentPath_=Z};q.createLinearGradient=function(j,p,i,m){var Z=new U("gradient");Z.x0_=j;Z.y0_=p;Z.x1_=i;Z.y1_=m;return Z};q.createRadialGradient=function(p,ag,m,j,Z,i){var ah=new U("gradientradial");ah.x0_=p;ah.y0_=ag;ah.r0_=m;ah.x1_=j;ah.y1_=Z;ah.r1_=i;return ah};q.drawImage=function(aq,m){var aj,ah,al,ay,ao,am,at,aA;var ak=aq.runtimeStyle.width;var ap=aq.runtimeStyle.height;aq.runtimeStyle.width="auto";aq.runtimeStyle.height="auto";var ai=aq.width;var aw=aq.height;aq.runtimeStyle.width=ak;aq.runtimeStyle.height=ap;if(arguments.length==3){aj=arguments[1];ah=arguments[2];ao=am=0;at=al=ai;aA=ay=aw}else{if(arguments.length==5){aj=arguments[1];ah=arguments[2];al=arguments[3];ay=arguments[4];ao=am=0;at=ai;aA=aw}else{if(arguments.length==9){ao=arguments[1];am=arguments[2];at=arguments[3];aA=arguments[4];aj=arguments[5];ah=arguments[6];al=arguments[7];ay=arguments[8]}else{throw Error("Invalid number of arguments")}}}var az=V(this,aj,ah);var p=at/2;var j=aA/2;var ax=[];var i=10;var ag=10;ax.push(" <g_vml_:group",' coordsize="',d*i,",",d*ag,'"',' coordorigin="0,0"',' style="width:',i,"px;height:",ag,"px;position:absolute;");if(this.m_[0][0]!=1||this.m_[0][1]||this.m_[1][1]!=1||this.m_[1][0]){var Z=[];Z.push("M11=",this.m_[0][0],",","M12=",this.m_[1][0],",","M21=",this.m_[0][1],",","M22=",this.m_[1][1],",","Dx=",n(az.x/d),",","Dy=",n(az.y/d),"");var av=az;var au=V(this,aj+al,ah);var ar=V(this,aj,ah+ay);var an=V(this,aj+al,ah+ay);av.x=ab.max(av.x,au.x,ar.x,an.x);av.y=ab.max(av.y,au.y,ar.y,an.y);ax.push("padding:0 ",n(av.x/d),"px ",n(av.y/d),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",Z.join(""),", sizingmethod='clip');")}else{ax.push("top:",n(az.y/d),"px;left:",n(az.x/d),"px;")}ax.push(' ">','<g_vml_:image src="',aq.src,'"',' style="width:',d*al,"px;"," height:",d*ay,'px"',' cropleft="',ao/ai,'"',' croptop="',am/aw,'"',' cropright="',(ai-ao-at)/ai,'"',' cropbottom="',(aw-am-aA)/aw,'"'," />","</g_vml_:group>");this.element_.insertAdjacentHTML("BeforeEnd",ax.join(""))};q.stroke=function(al){var aj=[];var Z=false;var m=10;var am=10;aj.push("<g_vml_:shape",' filled="',!!al,'"',' style="position:absolute;width:',m,"px;height:",am,'px;"',' coordorigin="0,0"',' coordsize="',d*m,",",d*am,'"',' stroked="',!al,'"',' path="');var an=false;var ag={x:null,y:null};var ak={x:null,y:null};for(var ah=0;ah<this.currentPath_.length;ah++){var j=this.currentPath_[ah];var ai;switch(j.type){case"moveTo":ai=j;aj.push(" m ",n(j.x),",",n(j.y));break;case"lineTo":aj.push(" l ",n(j.x),",",n(j.y));break;case"close":aj.push(" x ");j=null;break;case"bezierCurveTo":aj.push(" c ",n(j.cp1x),",",n(j.cp1y),",",n(j.cp2x),",",n(j.cp2y),",",n(j.x),",",n(j.y));break;case"at":case"wa":aj.push(" ",j.type," ",n(j.x-this.arcScaleX_*j.radius),",",n(j.y-this.arcScaleY_*j.radius)," ",n(j.x+this.arcScaleX_*j.radius),",",n(j.y+this.arcScaleY_*j.radius)," ",n(j.xStart),",",n(j.yStart)," ",n(j.xEnd),",",n(j.yEnd));break}if(j){if(ag.x==null||j.x<ag.x){ag.x=j.x}if(ak.x==null||j.x>ak.x){ak.x=j.x}if(ag.y==null||j.y<ag.y){ag.y=j.y}if(ak.y==null||j.y>ak.y){ak.y=j.y}}}aj.push(' ">');if(!al){w(this,aj)}else{G(this,aj,ag,ak)}aj.push("</g_vml_:shape>");this.element_.insertAdjacentHTML("beforeEnd",aj.join(""))};function w(m,ag){var j=F(m.strokeStyle);var p=j.color;var Z=j.alpha*m.globalAlpha;var i=m.lineScale_*m.lineWidth;if(i<1){Z*=i}ag.push("<g_vml_:stroke",' opacity="',Z,'"',' joinstyle="',m.lineJoin,'"',' miterlimit="',m.miterLimit,'"',' endcap="',S(m.lineCap),'"',' weight="',i,'px"',' color="',p,'" />')}function G(aq,ai,aK,ar){var aj=aq.fillStyle;var aB=aq.arcScaleX_;var aA=aq.arcScaleY_;var j=ar.x-aK.x;var p=ar.y-aK.y;if(aj instanceof U){var an=0;var aF={x:0,y:0};var ax=0;var am=1;if(aj.type_=="gradient"){var al=aj.x0_/aB;var m=aj.y0_/aA;var ak=aj.x1_/aB;var aM=aj.y1_/aA;var aJ=V(aq,al,m);var aI=V(aq,ak,aM);var ag=aI.x-aJ.x;var Z=aI.y-aJ.y;an=Math.atan2(ag,Z)*180/Math.PI;if(an<0){an+=360}if(an<0.000001){an=0}}else{var aJ=V(aq,aj.x0_,aj.y0_);aF={x:(aJ.x-aK.x)/j,y:(aJ.y-aK.y)/p};j/=aB*d;p/=aA*d;var aD=ab.max(j,p);ax=2*aj.r0_/aD;am=2*aj.r1_/aD-ax}var av=aj.colors_;av.sort(function(aN,i){return aN.offset-i.offset});var ap=av.length;var au=av[0].color;var at=av[ap-1].color;var az=av[0].alpha*aq.globalAlpha;var ay=av[ap-1].alpha*aq.globalAlpha;var aE=[];for(var aH=0;aH<ap;aH++){var ao=av[aH];aE.push(ao.offset*am+ax+" "+ao.color)}ai.push('<g_vml_:fill type="',aj.type_,'"',' method="none" focus="100%"',' color="',au,'"',' color2="',at,'"',' colors="',aE.join(","),'"',' opacity="',ay,'"',' g_o_:opacity2="',az,'"',' angle="',an,'"',' focusposition="',aF.x,",",aF.y,'" />')}else{if(aj instanceof T){if(j&&p){var ah=-aK.x;var aC=-aK.y;ai.push("<g_vml_:fill",' position="',ah/j*aB*aB,",",aC/p*aA*aA,'"',' type="tile"',' src="',aj.src_,'" />')}}else{var aL=F(aq.fillStyle);var aw=aL.color;var aG=aL.alpha*aq.globalAlpha;ai.push('<g_vml_:fill color="',aw,'" opacity="',aG,'" />')}}}q.fill=function(){this.stroke(true)};q.closePath=function(){this.currentPath_.push({type:"close"})};function V(j,Z,p){var i=j.m_;return{x:d*(Z*i[0][0]+p*i[1][0]+i[2][0])-f,y:d*(Z*i[0][1]+p*i[1][1]+i[2][1])-f}}q.save=function(){var i={};v(this,i);this.aStack_.push(i);this.mStack_.push(this.m_);this.m_=J(B(),this.m_)};q.restore=function(){if(this.aStack_.length){v(this.aStack_.pop(),this);this.m_=this.mStack_.pop()}};function h(i){return isFinite(i[0][0])&&isFinite(i[0][1])&&isFinite(i[1][0])&&isFinite(i[1][1])&&isFinite(i[2][0])&&isFinite(i[2][1])}function aa(j,i,p){if(!h(i)){return}j.m_=i;if(p){var Z=i[0][0]*i[1][1]-i[0][1]*i[1][0];j.lineScale_=N(H(Z))}}q.translate=function(m,j){var i=[[1,0,0],[0,1,0],[m,j,1]];aa(this,J(i,this.m_),false)};q.rotate=function(j){var p=A(j);var m=l(j);var i=[[p,m,0],[-m,p,0],[0,0,1]];aa(this,J(i,this.m_),false)};q.scale=function(m,j){this.arcScaleX_*=m;this.arcScaleY_*=j;var i=[[m,0,0],[0,j,0],[0,0,1]];aa(this,J(i,this.m_),true)};q.transform=function(Z,p,ah,ag,j,i){var m=[[Z,p,0],[ah,ag,0],[j,i,1]];aa(this,J(m,this.m_),true)};q.setTransform=function(ag,Z,ai,ah,p,j){var i=[[ag,Z,0],[ai,ah,0],[p,j,1]];aa(this,i,true)};q.drawText_=function(am,ak,aj,ap,ai){var ao=this.m_,at=1000,j=0,ar=at,ah={x:0,y:0},ag=[];var i=u(E(this.font),this.element_);var p=ac(i);var au=this.element_.currentStyle;var Z=this.textAlign.toLowerCase();switch(Z){case"left":case"center":case"right":break;case"end":Z=au.direction=="ltr"?"right":"left";break;case"start":Z=au.direction=="rtl"?"right":"left";break;default:Z="left"}switch(this.textBaseline){case"hanging":case"top":ah.y=i.size/1.75;break;case"middle":break;default:case null:case"alphabetic":case"ideographic":case"bottom":ah.y=-i.size/2.25;break}switch(Z){case"right":j=at;ar=0.05;break;case"center":j=ar=at/2;break}var aq=V(this,ak+ah.x,aj+ah.y);ag.push('<g_vml_:line from="',-j,' 0" to="',ar,' 0.05" ',' coordsize="100 100" coordorigin="0 0"',' filled="',!ai,'" stroked="',!!ai,'" style="position:absolute;width:1px;height:1px;">');if(ai){w(this,ag)}else{G(this,ag,{x:-j,y:0},{x:ar,y:i.size})}var an=ao[0][0].toFixed(3)+","+ao[1][0].toFixed(3)+","+ao[0][1].toFixed(3)+","+ao[1][1].toFixed(3)+",0,0";var al=n(aq.x/d+1-ao[0][0])+","+n(aq.y/d-2*ao[1][0]);ag.push('<g_vml_:skew on="t" matrix="',an,'" ',' offset="',al,'" origin="',j,' 0" />','<g_vml_:path textpathok="true" />','<g_vml_:textpath on="true" string="',af(am),'" style="v-text-align:',Z,";font:",af(p),'" /></g_vml_:line>');this.element_.insertAdjacentHTML("beforeEnd",ag.join(""))};q.fillText=function(m,i,p,j){this.drawText_(m,i,p,j,false)};q.strokeText=function(m,i,p,j){this.drawText_(m,i,p,j,true)};q.measureText=function(m){if(!this.textMeasureEl_){var i='<span style="position:absolute;top:-20000px;left:0;padding:0;margin:0;border:none;white-space:pre;"></span>';this.element_.insertAdjacentHTML("beforeEnd",i);this.textMeasureEl_=this.element_.lastChild}var j=this.element_.ownerDocument;this.textMeasureEl_.innerHTML="";this.textMeasureEl_.style.font=this.font;this.textMeasureEl_.appendChild(j.createTextNode(m));return{width:this.textMeasureEl_.offsetWidth}};q.clip=function(){};q.arcTo=function(){};q.createPattern=function(j,i){return new T(j,i)};function U(i){this.type_=i;this.x0_=0;this.y0_=0;this.r0_=0;this.x1_=0;this.y1_=0;this.r1_=0;this.colors_=[]}U.prototype.addColorStop=function(j,i){i=F(i);this.colors_.push({offset:j,color:i.color,alpha:i.alpha})};function T(j,i){Q(j);switch(i){case"repeat":case null:case"":this.repetition_="repeat";break;case"repeat-x":case"repeat-y":case"no-repeat":this.repetition_=i;break;default:O("SYNTAX_ERR")}this.src_=j.src;this.width_=j.width;this.height_=j.height}function O(i){throw new P(i)}function Q(i){if(!i||i.nodeType!=1||i.tagName!="IMG"){O("TYPE_MISMATCH_ERR")}if(i.readyState!="complete"){O("INVALID_STATE_ERR")}}function P(i){this.code=this[i];this.message=i+": DOM Exception "+this.code}var X=P.prototype=new Error;X.INDEX_SIZE_ERR=1;X.DOMSTRING_SIZE_ERR=2;X.HIERARCHY_REQUEST_ERR=3;X.WRONG_DOCUMENT_ERR=4;X.INVALID_CHARACTER_ERR=5;X.NO_DATA_ALLOWED_ERR=6;X.NO_MODIFICATION_ALLOWED_ERR=7;X.NOT_FOUND_ERR=8;X.NOT_SUPPORTED_ERR=9;X.INUSE_ATTRIBUTE_ERR=10;X.INVALID_STATE_ERR=11;X.SYNTAX_ERR=12;X.INVALID_MODIFICATION_ERR=13;X.NAMESPACE_ERR=14;X.INVALID_ACCESS_ERR=15;X.VALIDATION_ERR=16;X.TYPE_MISMATCH_ERR=17;G_vmlCanvasManager=e;CanvasRenderingContext2D=D;CanvasGradient=U;CanvasPattern=T;DOMException=P;G_vmlCanvasManager._version=888})()};
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.css b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.css
deleted file mode 100644
index 2ed901b..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.css
+++ /dev/null
@@ -1,258 +0,0 @@
-/*rules for the plot target div.  These will be cascaded down to all plot elements according to css rules*/
-.jqplot-target {
-    position: relative;
-    color: #666666;
-    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
-    font-size: 1em;
-/*    height: 300px;
-    width: 400px;*/
-}
-
-/*rules applied to all axes*/
-.jqplot-axis {
-    font-size: 0.75em;
-}
-
-.jqplot-xaxis {
-    margin-top: 10px;
-}
-
-.jqplot-x2axis {
-    margin-bottom: 10px;
-}
-
-.jqplot-yaxis {
-    margin-right: 10px;
-}
-
-.jqplot-y2axis, .jqplot-y3axis, .jqplot-y4axis, .jqplot-y5axis, .jqplot-y6axis, .jqplot-y7axis, .jqplot-y8axis, .jqplot-y9axis, .jqplot-yMidAxis {
-    margin-left: 10px;
-    margin-right: 10px;
-}
-
-/*rules applied to all axis tick divs*/
-.jqplot-axis-tick, .jqplot-xaxis-tick, .jqplot-yaxis-tick, .jqplot-x2axis-tick, .jqplot-y2axis-tick, .jqplot-y3axis-tick, .jqplot-y4axis-tick, .jqplot-y5axis-tick, .jqplot-y6axis-tick, .jqplot-y7axis-tick, .jqplot-y8axis-tick, .jqplot-y9axis-tick, .jqplot-yMidAxis-tick {
-    position: absolute;
-}
-
-
-.jqplot-xaxis-tick {
-    top: 0px;
-    /* initial position untill tick is drawn in proper place */
-    left: 15px;
-/*    padding-top: 10px;*/
-    vertical-align: top;
-}
-
-.jqplot-x2axis-tick {
-    bottom: 0px;
-    /* initial position untill tick is drawn in proper place */
-    left: 15px;
-/*    padding-bottom: 10px;*/
-    vertical-align: bottom;
-}
-
-.jqplot-yaxis-tick {
-    right: 0px;
-    /* initial position untill tick is drawn in proper place */
-    top: 15px;
-/*    padding-right: 10px;*/
-    text-align: right;
-}
-
-.jqplot-yaxis-tick.jqplot-breakTick {
-	right: -20px;
-	margin-right: 0px;
-	padding:1px 5px 1px 5px;
-/*	background-color: white;*/
-	z-index: 2;
-	font-size: 1.5em;
-}
-
-.jqplot-y2axis-tick, .jqplot-y3axis-tick, .jqplot-y4axis-tick, .jqplot-y5axis-tick, .jqplot-y6axis-tick, .jqplot-y7axis-tick, .jqplot-y8axis-tick, .jqplot-y9axis-tick {
-    left: 0px;
-    /* initial position untill tick is drawn in proper place */
-    top: 15px;
-/*    padding-left: 10px;*/
-/*    padding-right: 15px;*/
-    text-align: left;
-}
-
-.jqplot-yMidAxis-tick {
-    text-align: center;
-    white-space: nowrap;
-}
-
-.jqplot-xaxis-label {
-    margin-top: 10px;
-    font-size: 11pt;
-    position: absolute;
-}
-
-.jqplot-x2axis-label {
-    margin-bottom: 10px;
-    font-size: 11pt;
-    position: absolute;
-}
-
-.jqplot-yaxis-label {
-    margin-right: 10px;
-/*    text-align: center;*/
-    font-size: 11pt;
-    position: absolute;
-}
-
-.jqplot-yMidAxis-label {
-    font-size: 11pt;
-    position: absolute;
-}
-
-.jqplot-y2axis-label, .jqplot-y3axis-label, .jqplot-y4axis-label, .jqplot-y5axis-label, .jqplot-y6axis-label, .jqplot-y7axis-label, .jqplot-y8axis-label, .jqplot-y9axis-label {
-/*    text-align: center;*/
-    font-size: 11pt;
-    margin-left: 10px;
-    position: absolute;
-}
-
-.jqplot-meterGauge-tick {
-    font-size: 0.75em;
-    color: #999999;
-}
-
-.jqplot-meterGauge-label {
-    font-size: 1em;
-    color: #999999;
-}
-
-table.jqplot-table-legend {
-    margin-top: 12px;
-    margin-bottom: 12px;
-    margin-left: 12px;
-    margin-right: 12px;
-}
-
-table.jqplot-table-legend, table.jqplot-cursor-legend {
-    background-color: rgba(255,255,255,0.6);
-    border: 1px solid #cccccc;
-    position: absolute;
-    font-size: 0.75em;
-}
-
-td.jqplot-table-legend {
-    vertical-align:middle;
-}
-
-/*
-These rules could be used instead of assigning
-element styles and relying on js object properties.
-*/
-
-/*
-td.jqplot-table-legend-swatch {
-    padding-top: 0.5em;
-    text-align: center;
-}
-
-tr.jqplot-table-legend:first td.jqplot-table-legend-swatch {
-    padding-top: 0px;
-}
-*/
-
-td.jqplot-seriesToggle:hover, td.jqplot-seriesToggle:active {
-    cursor: pointer;
-}
-
-.jqplot-table-legend .jqplot-series-hidden {
-    text-decoration: line-through;
-}
-
-div.jqplot-table-legend-swatch-outline {
-    border: 1px solid #cccccc;
-    padding:1px;
-}
-
-div.jqplot-table-legend-swatch {
-    width:0px;
-    height:0px;
-    border-top-width: 5px;
-    border-bottom-width: 5px;
-    border-left-width: 6px;
-    border-right-width: 6px;
-    border-top-style: solid;
-    border-bottom-style: solid;
-    border-left-style: solid;
-    border-right-style: solid;
-}
-
-.jqplot-title {
-    top: 0px;
-    left: 0px;
-    padding-bottom: 0.5em;
-    font-size: 1.2em;
-}
-
-table.jqplot-cursor-tooltip {
-    border: 1px solid #cccccc;
-    font-size: 0.75em;
-}
-
-
-.jqplot-cursor-tooltip {
-    border: 1px solid #cccccc;
-    font-size: 0.75em;
-    white-space: nowrap;
-    background: rgba(208,208,208,0.5);
-    padding: 1px;
-}
-
-.jqplot-highlighter-tooltip, .jqplot-canvasOverlay-tooltip {
-    border: 1px solid #cccccc;
-    font-size: 0.75em;
-    white-space: nowrap;
-    background: rgba(208,208,208,0.5);
-    padding: 1px;
-}
-
-.jqplot-point-label {
-    font-size: 0.75em;
-    z-index: 2;
-}
-      
-td.jqplot-cursor-legend-swatch {
-    vertical-align: middle;
-    text-align: center;
-}
-
-div.jqplot-cursor-legend-swatch {
-    width: 1.2em;
-    height: 0.7em;
-}
-
-.jqplot-error {
-/*   Styles added to the plot target container when there is an error go here.*/
-    text-align: center;
-}
-
-.jqplot-error-message {
-/*    Styling of the custom error message div goes here.*/
-    position: relative;
-    top: 46%;
-    display: inline-block;
-}
-
-div.jqplot-bubble-label {
-    font-size: 0.8em;
-/*    background: rgba(90%, 90%, 90%, 0.15);*/
-    padding-left: 2px;
-    padding-right: 2px;
-    color: rgb(20%, 20%, 20%);
-}
-
-div.jqplot-bubble-label.jqplot-bubble-label-highlight {
-    background: rgba(90%, 90%, 90%, 0.7);
-}
-
-div.jqplot-noData-container {
-	text-align: center;
-	background-color: rgba(96%, 96%, 96%, 0.3);
-}
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.js
deleted file mode 100644
index 48dd8ab..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.js
+++ /dev/null
@@ -1,10422 +0,0 @@
-/**
- * Title: jqPlot Charts
- * 
- * Pure JavaScript plotting plugin for jQuery.
- * 
- * About: Version
- * 
- * 1.0.0b2_r947 
- * 
- * About: Copyright & License
- * 
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- * 
- * See <GPL Version 2> and <MIT License> contained within this distribution for further information. 
- *
- * The author would appreciate an email letting him know of any substantial
- * use of jqPlot.  You can reach the author at: chris at jqplot dot com 
- * or see http://www.jqplot.com/info.php.  This is, of course, not required.
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php.
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- * 
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- * 
- * About: Introduction
- * 
- * jqPlot requires jQuery (1.4+ required for certain features). jQuery 1.4.2 is included in the distribution.  
- * To use jqPlot include jQuery, the jqPlot jQuery plugin, the jqPlot css file and optionally 
- * the excanvas script for IE support in your web page:
- * 
- * > <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="excanvas.js"></script><![endif]-->
- * > <script language="javascript" type="text/javascript" src="jquery-1.4.4.min.js"></script>
- * > <script language="javascript" type="text/javascript" src="jquery.jqplot.min.js"></script>
- * > <link rel="stylesheet" type="text/css" href="jquery.jqplot.css" />
- * 
- * jqPlot can be customized by overriding the defaults of any of the objects which make
- * up the plot. The general usage of jqplot is:
- * 
- * > chart = $.jqplot('targetElemId', [dataArray,...], {optionsObject});
- * 
- * The options available to jqplot are detailed in <jqPlot Options> in the jqPlotOptions.txt file.
- * 
- * An actual call to $.jqplot() may look like the 
- * examples below:
- * 
- * > chart = $.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]);
- * 
- * or
- * 
- * > dataArray = [34,12,43,55,77];
- * > chart = $.jqplot('targetElemId', [dataArray, ...], {title:'My Plot', axes:{yaxis:{min:20, max:100}}});
- * 
- * For more inforrmation, see <jqPlot Usage>.
- * 
- * About: Usage
- * 
- * See <jqPlot Usage>
- * 
- * About: Available Options 
- * 
- * See <jqPlot Options> for a list of options available thorugh the options object (not complete yet!)
- * 
- * About: Options Usage
- * 
- * See <Options Tutorial>
- * 
- * About: Changes
- * 
- * See <Change Log>
- * 
- */
-
-(function($) {
-    // make sure undefined is undefined
-    var undefined;
-    
-    $.fn.emptyForce = function() {
-      for ( var i = 0, elem; (elem = $(this)[i]) != null; i++ ) {
-        // Remove element nodes and prevent memory leaks
-        if ( elem.nodeType === 1 ) {
-          jQuery.cleanData( elem.getElementsByTagName("*") );
-        }
-  
-        // Remove any remaining nodes
-        if ($.jqplot_use_excanvas) {
-          elem.outerHTML = "";
-        }
-        else {
-          while ( elem.firstChild ) {
-            elem.removeChild( elem.firstChild );
-          }
-        }
-
-        elem = null;
-      }
-  
-      return $(this);
-    };
-  
-    $.fn.removeChildForce = function(parent) {
-      while ( parent.firstChild ) {
-        this.removeChildForce( parent.firstChild );
-        parent.removeChild( parent.firstChild );
-      }
-    };
-
-
-    /**
-     * Namespace: $.jqplot
-     * jQuery function called by the user to create a plot.
-     *  
-     * Parameters:
-     * target - ID of target element to render the plot into.
-     * data - an array of data series.
-     * options - user defined options object.  See the individual classes for available options.
-     * 
-     * Properties:
-     * config - object to hold configuration information for jqPlot plot object.
-     * 
-     * attributes:
-     * enablePlugins - False to disable plugins by default.  Plugins must then be explicitly 
-     *   enabled in the individual plot options.  Default: false.
-     *   This property sets the "show" property of certain plugins to true or false.
-     *   Only plugins that can be immediately active upon loading are affected.  This includes
-     *   non-renderer plugins like cursor, dragable, highlighter, and trendline.
-     * defaultHeight - Default height for plots where no css height specification exists.  This
-     *   is a jqplot wide default.
-     * defaultWidth - Default height for plots where no css height specification exists.  This
-     *   is a jqplot wide default.
-     */
-
-    $.jqplot = function(target, data, options) {
-        var _data, _options;
-        
-        if (options == null) {
-            if (jQuery.isArray(data)) {
-                _data = data;
-                _options = null;   
-            }
-            
-            else if (typeof(data) === 'object') {
-                _data = null;
-                _options = data;
-            }
-        }
-        else {
-            _data = data;
-            _options = options;
-        }
-        var plot = new jqPlot();
-        // remove any error class that may be stuck on target.
-        $('#'+target).removeClass('jqplot-error');
-        
-        if ($.jqplot.config.catchErrors) {
-            try {
-                plot.init(target, _data, _options);
-                plot.draw();
-                plot.themeEngine.init.call(plot);
-                return plot;
-            }
-            catch(e) {
-                var msg = $.jqplot.config.errorMessage || e.message;
-                $('#'+target).append('<div class="jqplot-error-message">'+msg+'</div>');
-                $('#'+target).addClass('jqplot-error');
-                document.getElementById(target).style.background = $.jqplot.config.errorBackground;
-                document.getElementById(target).style.border = $.jqplot.config.errorBorder;
-                document.getElementById(target).style.fontFamily = $.jqplot.config.errorFontFamily;
-                document.getElementById(target).style.fontSize = $.jqplot.config.errorFontSize;
-                document.getElementById(target).style.fontStyle = $.jqplot.config.errorFontStyle;
-                document.getElementById(target).style.fontWeight = $.jqplot.config.errorFontWeight;
-            }
-        }
-        else {        
-            plot.init(target, _data, _options);
-            plot.draw();
-            plot.themeEngine.init.call(plot);
-            return plot;
-        }
-    };
-
-    $.jqplot.version = "1.0.0b2_r947";
-
-    // canvas manager to reuse canvases on the plot.
-    // Should help solve problem of canvases not being freed and
-    // problem of waiting forever for firefox to decide to free memory.
-    $.jqplot.CanvasManager = function() {
-        // canvases are managed globally so that they can be reused
-        // across plots after they have been freed
-        if (typeof $.jqplot.CanvasManager.canvases == 'undefined') {
-            $.jqplot.CanvasManager.canvases = [];
-            $.jqplot.CanvasManager.free = [];
-        }
-        
-        var myCanvases = [];
-        
-        this.getCanvas = function() {
-            var canvas;
-            var makeNew = true;
-            
-            if (!$.jqplot.use_excanvas) {
-                for (var i = 0, l = $.jqplot.CanvasManager.canvases.length; i < l; i++) {
-                    if ($.jqplot.CanvasManager.free[i] === true) {
-                        makeNew = false;
-                        canvas = $.jqplot.CanvasManager.canvases[i];
-                        // $(canvas).removeClass('jqplot-canvasManager-free').addClass('jqplot-canvasManager-inuse');
-                        $.jqplot.CanvasManager.free[i] = false;
-                        myCanvases.push(i);
-                        break;
-                    }
-                }
-            }
-
-            if (makeNew) {
-                canvas = document.createElement('canvas');
-                myCanvases.push($.jqplot.CanvasManager.canvases.length);
-                $.jqplot.CanvasManager.canvases.push(canvas);
-                $.jqplot.CanvasManager.free.push(false);
-            }   
-            
-            return canvas;
-        };
-        
-        // this method has to be used after settings the dimesions
-        // on the element returned by getCanvas()
-        this.initCanvas = function(canvas) {
-            if ($.jqplot.use_excanvas) {
-                return window.G_vmlCanvasManager.initElement(canvas);
-            }
-            return canvas;
-        };
-
-        this.freeAllCanvases = function() {
-            for (var i = 0, l=myCanvases.length; i < l; i++) {
-                this.freeCanvas(myCanvases[i]);
-            }
-            myCanvases = [];
-        };
-
-        this.freeCanvas = function(idx) {
-            if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
-                // excanvas can't be reused, but properly unset
-                window.G_vmlCanvasManager.uninitElement($.jqplot.CanvasManager.canvases[idx]);
-                $.jqplot.CanvasManager.canvases[idx] = null;
-            } 
-            else {
-                var canvas = $.jqplot.CanvasManager.canvases[idx];
-                canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);
-                $(canvas).unbind().removeAttr('class').removeAttr('style');
-                // Style attributes seemed to be still hanging around.  wierd.  Some ticks
-                // still retained a left: 0px attribute after reusing a canvas.
-                $(canvas).css({left: '', top: '', position: ''});
-                // setting size to 0 may save memory of unused canvases?
-                canvas.width = 0;
-                canvas.height = 0;
-                $.jqplot.CanvasManager.free[idx] = true;
-            }
-        };
-        
-    };
-
-            
-    // Convienence function that won't hang IE or FF without FireBug.
-    $.jqplot.log = function() {
-        if (window.console) {
-            window.console.log.apply(window.console, arguments);
-        }
-    };
-        
-    $.jqplot.config = {
-        enablePlugins:false,
-        defaultHeight:300,
-        defaultWidth:400,
-        UTCAdjust:false,
-        timezoneOffset: new Date(new Date().getTimezoneOffset() * 60000),
-        errorMessage: '',
-        errorBackground: '',
-        errorBorder: '',
-        errorFontFamily: '',
-        errorFontSize: '',
-        errorFontStyle: '',
-        errorFontWeight: '',
-        catchErrors: false,
-        defaultTickFormatString: "%.1f",
-        defaultColors: [ "#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"],
-        defaultNegativeColors: [ "#498991", "#C08840", "#9F9274", "#546D61", "#646C4A", "#6F6621", "#6E3F5F", "#4F64B0", "#A89050", "#C45923", "#187399", "#945381", "#959E5C", "#C7AF7B", "#478396", "#907294"],
-        dashLength: 4,
-        gapLength: 4,
-        dotGapLength: 2.5,
-        srcLocation: 'jqplot/src/',
-        pluginLocation: 'jqplot/src/plugins/'
-    };
-    
-    
-    $.jqplot.arrayMax = function( array ){
-        return Math.max.apply( Math, array );
-    };
-    
-    $.jqplot.arrayMin = function( array ){
-        return Math.min.apply( Math, array );
-    };
-    
-    $.jqplot.enablePlugins = $.jqplot.config.enablePlugins;
-    
-    // canvas related tests taken from modernizer:
-    // Copyright (c) 2009 - 2010 Faruk Ates.
-    // http://www.modernizr.com
-    
-    $.jqplot.support_canvas = function() {
-        if (typeof $.jqplot.support_canvas.result == 'undefined') {
-            $.jqplot.support_canvas.result = !!document.createElement('canvas').getContext; 
-        }
-        return $.jqplot.support_canvas.result;
-    };
-            
-    $.jqplot.support_canvas_text = function() {
-        if (typeof $.jqplot.support_canvas_text.result == 'undefined') {
-            if (window.G_vmlCanvasManager !== undefined && window.G_vmlCanvasManager._version > 887) {
-                $.jqplot.support_canvas_text.result = true;
-            }
-            else {
-                $.jqplot.support_canvas_text.result = !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function');
-            }
-             
-        }
-        return $.jqplot.support_canvas_text.result;
-    };
-    
-    $.jqplot.use_excanvas = ($.browser.msie && !$.jqplot.support_canvas()) ? true : false;
-    
-    /**
-     * 
-     * Hooks: jqPlot Pugin Hooks
-     * 
-     * $.jqplot.preInitHooks - called before initialization.
-     * $.jqplot.postInitHooks - called after initialization.
-     * $.jqplot.preParseOptionsHooks - called before user options are parsed.
-     * $.jqplot.postParseOptionsHooks - called after user options are parsed.
-     * $.jqplot.preDrawHooks - called before plot draw.
-     * $.jqplot.postDrawHooks - called after plot draw.
-     * $.jqplot.preDrawSeriesHooks - called before each series is drawn.
-     * $.jqplot.postDrawSeriesHooks - called after each series is drawn.
-     * $.jqplot.preDrawLegendHooks - called before the legend is drawn.
-     * $.jqplot.addLegendRowHooks - called at the end of legend draw, so plugins
-     *     can add rows to the legend table.
-     * $.jqplot.preSeriesInitHooks - called before series is initialized.
-     * $.jqplot.postSeriesInitHooks - called after series is initialized.
-     * $.jqplot.preParseSeriesOptionsHooks - called before series related options
-     *     are parsed.
-     * $.jqplot.postParseSeriesOptionsHooks - called after series related options
-     *     are parsed.
-     * $.jqplot.eventListenerHooks - called at the end of plot drawing, binds
-     *     listeners to the event canvas which lays on top of the grid area.
-     * $.jqplot.preDrawSeriesShadowHooks - called before series shadows are drawn.
-     * $.jqplot.postDrawSeriesShadowHooks - called after series shadows are drawn.
-     * 
-     */
-    
-    $.jqplot.preInitHooks = [];
-    $.jqplot.postInitHooks = [];
-    $.jqplot.preParseOptionsHooks = [];
-    $.jqplot.postParseOptionsHooks = [];
-    $.jqplot.preDrawHooks = [];
-    $.jqplot.postDrawHooks = [];
-    $.jqplot.preDrawSeriesHooks = [];
-    $.jqplot.postDrawSeriesHooks = [];
-    $.jqplot.preDrawLegendHooks = [];
-    $.jqplot.addLegendRowHooks = [];
-    $.jqplot.preSeriesInitHooks = [];
-    $.jqplot.postSeriesInitHooks = [];
-    $.jqplot.preParseSeriesOptionsHooks = [];
-    $.jqplot.postParseSeriesOptionsHooks = [];
-    $.jqplot.eventListenerHooks = [];
-    $.jqplot.preDrawSeriesShadowHooks = [];
-    $.jqplot.postDrawSeriesShadowHooks = [];
-
-    // A superclass holding some common properties and methods.
-    $.jqplot.ElemContainer = function() {
-        this._elem;
-        this._plotWidth;
-        this._plotHeight;
-        this._plotDimensions = {height:null, width:null};
-    };
-    
-    $.jqplot.ElemContainer.prototype.createElement = function(el, offsets, clss, cssopts, attrib) {
-        this._offsets = offsets;
-        var klass = clss || 'jqplot';
-        var elem = document.createElement(el);
-        this._elem = $(elem);
-        this._elem.addClass(klass);
-        this._elem.css(cssopts);
-        this._elem.attr(attrib);
-        // avoid memory leak;
-        elem = null;
-        return this._elem;
-    };
-    
-    $.jqplot.ElemContainer.prototype.getWidth = function() {
-        if (this._elem) {
-            return this._elem.outerWidth(true);
-        }
-        else {
-            return null;
-        }
-    };
-    
-    $.jqplot.ElemContainer.prototype.getHeight = function() {
-        if (this._elem) {
-            return this._elem.outerHeight(true);
-        }
-        else {
-            return null;
-        }
-    };
-    
-    $.jqplot.ElemContainer.prototype.getPosition = function() {
-        if (this._elem) {
-            return this._elem.position();
-        }
-        else {
-            return {top:null, left:null, bottom:null, right:null};
-        }
-    };
-    
-    $.jqplot.ElemContainer.prototype.getTop = function() {
-        return this.getPosition().top;
-    };
-    
-    $.jqplot.ElemContainer.prototype.getLeft = function() {
-        return this.getPosition().left;
-    };
-    
-    $.jqplot.ElemContainer.prototype.getBottom = function() {
-        return this._elem.css('bottom');
-    };
-    
-    $.jqplot.ElemContainer.prototype.getRight = function() {
-        return this._elem.css('right');
-    };
-    
-
-    /**
-     * Class: Axis
-     * An individual axis object.  Cannot be instantiated directly, but created
-     * by the Plot oject.  Axis properties can be set or overriden by the 
-     * options passed in from the user.
-     * 
-     */
-    function Axis(name) {
-        $.jqplot.ElemContainer.call(this);
-        // Group: Properties
-        //
-        // Axes options are specified within an axes object at the top level of the 
-        // plot options like so:
-        // > {
-        // >    axes: {
-        // >        xaxis: {min: 5},
-        // >        yaxis: {min: 2, max: 8, numberTicks:4},
-        // >        x2axis: {pad: 1.5},
-        // >        y2axis: {ticks:[22, 44, 66, 88]}
-        // >        }
-        // > }
-        // There are 2 x axes, 'xaxis' and 'x2axis', and 
-        // 9 yaxes, 'yaxis', 'y2axis'. 'y3axis', ...  Any or all of which may be specified.
-        this.name = name;
-        this._series = [];
-        // prop: show
-        // Wether to display the axis on the graph.
-        this.show = false;
-        // prop: tickRenderer
-        // A class of a rendering engine for creating the ticks labels displayed on the plot, 
-        // See <$.jqplot.AxisTickRenderer>.
-        this.tickRenderer = $.jqplot.AxisTickRenderer;
-        // prop: tickOptions
-        // Options that will be passed to the tickRenderer, see <$.jqplot.AxisTickRenderer> options.
-        this.tickOptions = {};
-        // prop: labelRenderer
-        // A class of a rendering engine for creating an axis label.
-        this.labelRenderer = $.jqplot.AxisLabelRenderer;
-        // prop: labelOptions
-        // Options passed to the label renderer.
-        this.labelOptions = {};
-        // prop: label
-        // Label for the axis
-        this.label = null;
-        // prop: showLabel
-        // true to show the axis label.
-        this.showLabel = true;
-        // prop: min
-        // minimum value of the axis (in data units, not pixels).
-        this.min = null;
-        // prop: max
-        // maximum value of the axis (in data units, not pixels).
-        this.max = null;
-        // prop: autoscale
-        // DEPRECATED
-        // the default scaling algorithm produces superior results.
-        this.autoscale = false;
-        // prop: pad
-        // Padding to extend the range above and below the data bounds.
-        // The data range is multiplied by this factor to determine minimum and maximum axis bounds.
-        // A value of 0 will be interpreted to mean no padding, and pad will be set to 1.0.
-        this.pad = 1.2;
-        // prop: padMax
-        // Padding to extend the range above data bounds.
-        // The top of the data range is multiplied by this factor to determine maximum axis bounds.
-        // A value of 0 will be interpreted to mean no padding, and padMax will be set to 1.0.
-        this.padMax = null;
-        // prop: padMin
-        // Padding to extend the range below data bounds.
-        // The bottom of the data range is multiplied by this factor to determine minimum axis bounds.
-        // A value of 0 will be interpreted to mean no padding, and padMin will be set to 1.0.
-        this.padMin = null;
-        // prop: ticks
-        // 1D [val, val, ...] or 2D [[val, label], [val, label], ...] array of ticks for the axis.
-        // If no label is specified, the value is formatted into an appropriate label.
-        this.ticks = [];
-        // prop: numberTicks
-        // Desired number of ticks.  Default is to compute automatically.
-        this.numberTicks;
-        // prop: tickInterval
-        // number of units between ticks.  Mutually exclusive with numberTicks.
-        this.tickInterval;
-        // prop: renderer
-        // A class of a rendering engine that handles tick generation, 
-        // scaling input data to pixel grid units and drawing the axis element.
-        this.renderer = $.jqplot.LinearAxisRenderer;
-        // prop: rendererOptions
-        // renderer specific options.  See <$.jqplot.LinearAxisRenderer> for options.
-        this.rendererOptions = {};
-        // prop: showTicks
-        // Wether to show the ticks (both marks and labels) or not.
-        // Will not override showMark and showLabel options if specified on the ticks themselves.
-        this.showTicks = true;
-        // prop: showTickMarks
-        // Wether to show the tick marks (line crossing grid) or not.
-        // Overridden by showTicks and showMark option of tick itself.
-        this.showTickMarks = true;
-        // prop: showMinorTicks
-        // Wether or not to show minor ticks.  This is renderer dependent.
-        this.showMinorTicks = true;
-        // prop: drawMajorGridlines
-        // True to draw gridlines for major axis ticks.
-        this.drawMajorGridlines = true;
-        // prop: drawMinorGridlines
-        // True to draw gridlines for minor ticks.
-        this.drawMinorGridlines = false;
-        // prop: drawMajorTickMarks
-        // True to draw tick marks for major axis ticks.
-        this.drawMajorTickMarks = true;
-        // prop: drawMinorTickMarks
-        // True to draw tick marks for minor ticks.  This is renderer dependent.
-        this.drawMinorTickMarks = true;
-        // prop: useSeriesColor
-        // Use the color of the first series associated with this axis for the
-        // tick marks and line bordering this axis.
-        this.useSeriesColor = false;
-        // prop: borderWidth
-        // width of line stroked at the border of the axis.  Defaults
-        // to the width of the grid boarder.
-        this.borderWidth = null;
-        // prop: borderColor
-        // color of the border adjacent to the axis.  Defaults to grid border color.
-        this.borderColor = null;
-        // minimum and maximum values on the axis.
-        this._dataBounds = {min:null, max:null};
-        // statistics (min, max, mean) as well as actual data intervals for each series attached to axis.
-        // holds collection of {intervals:[], min:, max:, mean: } objects for each series on axis.
-        this._intervalStats = [];
-        // pixel position from the top left of the min value and max value on the axis.
-        this._offsets = {min:null, max:null};
-        this._ticks=[];
-        this._label = null;
-        // prop: syncTicks
-        // true to try and synchronize tick spacing across multiple axes so that ticks and
-        // grid lines line up.  This has an impact on autoscaling algorithm, however.
-        // In general, autoscaling an individual axis will work better if it does not
-        // have to sync ticks.
-        this.syncTicks = null;
-        // prop: tickSpacing
-        // Approximate pixel spacing between ticks on graph.  Used during autoscaling.
-        // This number will be an upper bound, actual spacing will be less.
-        this.tickSpacing = 75;
-        // Properties to hold the original values for min, max, ticks, tickInterval and numberTicks
-        // so they can be restored if altered by plugins.
-        this._min = null;
-        this._max = null;
-        this._tickInterval = null;
-        this._numberTicks = null;
-        this.__ticks = null;
-        // hold original user options.
-        this._options = {};
-    }
-    
-    Axis.prototype = new $.jqplot.ElemContainer();
-    Axis.prototype.constructor = Axis;
-    
-    Axis.prototype.init = function() {
-        this.renderer = new this.renderer();
-        // set the axis name
-        this.tickOptions.axis = this.name;
-        // if showMark or showLabel tick options not specified, use value of axis option.
-        // showTicks overrides showTickMarks.
-        if (this.tickOptions.showMark == null) {
-            this.tickOptions.showMark = this.showTicks;
-        }
-        if (this.tickOptions.showMark == null) {
-            this.tickOptions.showMark = this.showTickMarks;
-        }
-        if (this.tickOptions.showLabel == null) {
-            this.tickOptions.showLabel = this.showTicks;
-        }
-        
-        if (this.label == null || this.label == '') {
-            this.showLabel = false;
-        }
-        else {
-            this.labelOptions.label = this.label;
-        }
-        if (this.showLabel == false) {
-            this.labelOptions.show = false;
-        }
-        // set the default padMax, padMin if not specified
-        // special check, if no padding desired, padding
-        // should be set to 1.0
-        if (this.pad == 0) {
-            this.pad = 1.0;
-        }
-        if (this.padMax == 0) {
-            this.padMax = 1.0;
-        }
-        if (this.padMin == 0) {
-            this.padMin = 1.0;
-        }
-        if (this.padMax == null) {
-            this.padMax = (this.pad-1)/2 + 1;
-        }
-        if (this.padMin == null) {
-            this.padMin = (this.pad-1)/2 + 1;
-        }
-        // now that padMin and padMax are correctly set, reset pad in case user has supplied 
-        // padMin and/or padMax
-        this.pad = this.padMax + this.padMin - 1;
-        if (this.min != null || this.max != null) {
-            this.autoscale = false;
-        }
-        // if not set, sync ticks for y axes but not x by default.
-        if (this.syncTicks == null && this.name.indexOf('y') > -1) {
-            this.syncTicks = true;
-        }
-        else if (this.syncTicks == null){
-            this.syncTicks = false;
-        }
-        this.renderer.init.call(this, this.rendererOptions);
-        
-    };
-    
-    Axis.prototype.draw = function(ctx, plot) {
-        // Memory Leaks patch
-        if (this.__ticks) {
-          this.__ticks = null;
-        }
-
-        return this.renderer.draw.call(this, ctx, plot);
-        
-    };
-    
-    Axis.prototype.set = function() {
-        this.renderer.set.call(this);
-    };
-    
-    Axis.prototype.pack = function(pos, offsets) {
-        if (this.show) {
-            this.renderer.pack.call(this, pos, offsets);
-        }
-        // these properties should all be available now.
-        if (this._min == null) {
-            this._min = this.min;
-            this._max = this.max;
-            this._tickInterval = this.tickInterval;
-            this._numberTicks = this.numberTicks;
-            this.__ticks = this._ticks;
-        }
-    };
-    
-    // reset the axis back to original values if it has been scaled, zoomed, etc.
-    Axis.prototype.reset = function() {
-        this.renderer.reset.call(this);
-    };
-    
-    Axis.prototype.resetScale = function(opts) {
-        $.extend(true, this, {min: null, max: null, numberTicks: null, tickInterval: null, _ticks: [], ticks: []}, opts);
-        this.resetDataBounds();
-    };
-    
-    Axis.prototype.resetDataBounds = function() {
-        // Go through all the series attached to this axis and find
-        // the min/max bounds for this axis.
-        var db = this._dataBounds;
-        db.min = null;
-        db.max = null;
-        var l, s, d;
-        // check for when to force min 0 on bar series plots.
-        var doforce = (this.show) ? true : false;
-        for (var i=0; i<this._series.length; i++) {
-            s = this._series[i];
-            d = s._plotData;
-            if (s._type === 'line' && s.renderer.bands.show && this.name.charAt(0) !== 'x') {
-                d = [[0, s.renderer.bands._min], [1, s.renderer.bands._max]];
-            }
-
-            var minyidx = 1, maxyidx = 1;
-
-            if (s._type != null && s._type == 'ohlc') {
-                minyidx = 3;
-                maxyidx = 2;
-            }
-            
-            for (var j=0, l=d.length; j<l; j++) { 
-                if (this.name == 'xaxis' || this.name == 'x2axis') {
-                    if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) {
-                        db.min = d[j][0];
-                    }
-                    if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) {
-                        db.max = d[j][0];
-                    }
-                }              
-                else {
-                    if ((d[j][minyidx] != null && d[j][minyidx] < db.min) || db.min == null) {
-                        db.min = d[j][minyidx];
-                    }
-                    if ((d[j][maxyidx] != null && d[j][maxyidx] > db.max) || db.max == null) {
-                        db.max = d[j][maxyidx];
-                    }
-                }              
-            }
-
-            // Hack to not pad out bottom of bar plots unless user has specified a padding.
-            // every series will have a chance to set doforce to false.  once it is set to 
-            // false, it cannot be reset to true.
-            // If any series attached to axis is not a bar, wont force 0.
-            if (doforce && s.renderer.constructor !== $.jqplot.BarRenderer) {
-                doforce = false;
-            }
-
-            else if (doforce && this._options.hasOwnProperty('forceTickAt0') && this._options.forceTickAt0 == false) {
-                doforce = false;
-            }
-
-            else if (doforce && s.renderer.constructor === $.jqplot.BarRenderer) {
-                if (s.barDirection == 'vertical' && this.name != 'xaxis' && this.name != 'x2axis') { 
-                    if (this._options.pad != null || this._options.padMin != null) {
-                        doforce = false;
-                    }
-                }
-
-                else if (s.barDirection == 'horizontal' && (this.name == 'xaxis' || this.name == 'x2axis')) {
-                    if (this._options.pad != null || this._options.padMin != null) {
-                        doforce = false;
-                    }
-                }
-
-            }
-        }
-
-        if (doforce && this.renderer.constructor === $.jqplot.LinearAxisRenderer && db.min >= 0) {
-            this.padMin = 1.0;
-            this.forceTickAt0 = true;
-        }
-    };
-
-    /**
-     * Class: Legend
-     * Legend object.  Cannot be instantiated directly, but created
-     * by the Plot oject.  Legend properties can be set or overriden by the 
-     * options passed in from the user.
-     */
-    function Legend(options) {
-        $.jqplot.ElemContainer.call(this);
-        // Group: Properties
-        
-        // prop: show
-        // Wether to display the legend on the graph.
-        this.show = false;
-        // prop: location
-        // Placement of the legend.  one of the compass directions: nw, n, ne, e, se, s, sw, w
-        this.location = 'ne';
-        // prop: labels
-        // Array of labels to use.  By default the renderer will look for labels on the series.
-        // Labels specified in this array will override labels specified on the series.
-        this.labels = [];
-        // prop: showLabels
-        // true to show the label text on the  legend.
-        this.showLabels = true;
-        // prop: showSwatch
-        // true to show the color swatches on the legend.
-        this.showSwatches = true;
-        // prop: placement
-        // "insideGrid" places legend inside the grid area of the plot.
-        // "outsideGrid" places the legend outside the grid but inside the plot container, 
-        // shrinking the grid to accomodate the legend.
-        // "inside" synonym for "insideGrid", 
-        // "outside" places the legend ouside the grid area, but does not shrink the grid which
-        // can cause the legend to overflow the plot container.
-        this.placement = "insideGrid";
-        // prop: xoffset
-        // DEPRECATED.  Set the margins on the legend using the marginTop, marginLeft, etc. 
-        // properties or via CSS margin styling of the .jqplot-table-legend class.
-        this.xoffset = 0;
-        // prop: yoffset
-        // DEPRECATED.  Set the margins on the legend using the marginTop, marginLeft, etc. 
-        // properties or via CSS margin styling of the .jqplot-table-legend class.
-        this.yoffset = 0;
-        // prop: border
-        // css spec for the border around the legend box.
-        this.border;
-        // prop: background
-        // css spec for the background of the legend box.
-        this.background;
-        // prop: textColor
-        // css color spec for the legend text.
-        this.textColor;
-        // prop: fontFamily
-        // css font-family spec for the legend text.
-        this.fontFamily; 
-        // prop: fontSize
-        // css font-size spec for the legend text.
-        this.fontSize ;
-        // prop: rowSpacing
-        // css padding-top spec for the rows in the legend.
-        this.rowSpacing = '0.5em';
-        // renderer
-        // A class that will create a DOM object for the legend,
-        // see <$.jqplot.TableLegendRenderer>.
-        this.renderer = $.jqplot.TableLegendRenderer;
-        // prop: rendererOptions
-        // renderer specific options passed to the renderer.
-        this.rendererOptions = {};
-        // prop: predraw
-        // Wether to draw the legend before the series or not.
-        // Used with series specific legend renderers for pie, donut, mekko charts, etc.
-        this.preDraw = false;
-        // prop: marginTop
-        // CSS margin for the legend DOM element. This will set an element 
-        // CSS style for the margin which will override any style sheet setting.
-        // The default will be taken from the stylesheet.
-        this.marginTop = null;
-        // prop: marginRight
-        // CSS margin for the legend DOM element. This will set an element 
-        // CSS style for the margin which will override any style sheet setting.
-        // The default will be taken from the stylesheet.
-        this.marginRight = null;
-        // prop: marginBottom
-        // CSS margin for the legend DOM element. This will set an element 
-        // CSS style for the margin which will override any style sheet setting.
-        // The default will be taken from the stylesheet.
-        this.marginBottom = null;
-        // prop: marginLeft
-        // CSS margin for the legend DOM element. This will set an element 
-        // CSS style for the margin which will override any style sheet setting.
-        // The default will be taken from the stylesheet.
-        this.marginLeft = null;
-        // prop: escapeHtml
-        // True to escape special characters with their html entity equivalents
-        // in legend text.  "<" becomes &lt; and so on, so html tags are not rendered.
-        this.escapeHtml = false;
-        this._series = [];
-        
-        $.extend(true, this, options);
-    }
-    
-    Legend.prototype = new $.jqplot.ElemContainer();
-    Legend.prototype.constructor = Legend;
-    
-    Legend.prototype.setOptions = function(options) {
-        $.extend(true, this, options);
-        
-        // Try to emulate deprecated behaviour
-        // if user has specified xoffset or yoffset, copy these to
-        // the margin properties.
-        
-        if (this.placement ==  'inside') {
-            this.placement = 'insideGrid';
-        }
-        
-        if (this.xoffset >0) {
-            if (this.placement == 'insideGrid') {
-                switch (this.location) {
-                    case 'nw':
-                    case 'w':
-                    case 'sw':
-                        if (this.marginLeft == null) {
-                            this.marginLeft = this.xoffset + 'px';
-                        }
-                        this.marginRight = '0px';
-                        break;
-                    case 'ne':
-                    case 'e':
-                    case 'se':
-                    default:
-                        if (this.marginRight == null) {
-                            this.marginRight = this.xoffset + 'px';
-                        }
-                        this.marginLeft = '0px';
-                        break;
-                }
-            }
-            else if (this.placement == 'outside') {
-                switch (this.location) {
-                    case 'nw':
-                    case 'w':
-                    case 'sw':
-                        if (this.marginRight == null) {
-                            this.marginRight = this.xoffset + 'px';
-                        }
-                        this.marginLeft = '0px';
-                        break;
-                    case 'ne':
-                    case 'e':
-                    case 'se':
-                    default:
-                        if (this.marginLeft == null) {
-                            this.marginLeft = this.xoffset + 'px';
-                        }
-                        this.marginRight = '0px';
-                        break;
-                }
-            }
-            this.xoffset = 0;
-        }
-        
-        if (this.yoffset >0) {
-            if (this.placement == 'outside') {
-                switch (this.location) {
-                    case 'sw':
-                    case 's':
-                    case 'se':
-                        if (this.marginTop == null) {
-                            this.marginTop = this.yoffset + 'px';
-                        }
-                        this.marginBottom = '0px';
-                        break;
-                    case 'ne':
-                    case 'n':
-                    case 'nw':
-                    default:
-                        if (this.marginBottom == null) {
-                            this.marginBottom = this.yoffset + 'px';
-                        }
-                        this.marginTop = '0px';
-                        break;
-                }
-            }
-            else if (this.placement == 'insideGrid') {
-                switch (this.location) {
-                    case 'sw':
-                    case 's':
-                    case 'se':
-                        if (this.marginBottom == null) {
-                            this.marginBottom = this.yoffset + 'px';
-                        }
-                        this.marginTop = '0px';
-                        break;
-                    case 'ne':
-                    case 'n':
-                    case 'nw':
-                    default:
-                        if (this.marginTop == null) {
-                            this.marginTop = this.yoffset + 'px';
-                        }
-                        this.marginBottom = '0px';
-                        break;
-                }
-            }
-            this.yoffset = 0;
-        }
-        
-        // TO-DO:
-        // Handle case where offsets are < 0.
-        //
-    };
-    
-    Legend.prototype.init = function() {
-        this.renderer = new this.renderer();
-        this.renderer.init.call(this, this.rendererOptions);
-    };
-    
-    Legend.prototype.draw = function(offsets) {
-        for (var i=0; i<$.jqplot.preDrawLegendHooks.length; i++){
-            $.jqplot.preDrawLegendHooks[i].call(this, offsets);
-        }
-        return this.renderer.draw.call(this, offsets);
-    };
-    
-    Legend.prototype.pack = function(offsets) {
-        this.renderer.pack.call(this, offsets);
-    };
-
-    /**
-     * Class: Title
-     * Plot Title object.  Cannot be instantiated directly, but created
-     * by the Plot oject.  Title properties can be set or overriden by the 
-     * options passed in from the user.
-     * 
-     * Parameters:
-     * text - text of the title.
-     */
-    function Title(text) {
-        $.jqplot.ElemContainer.call(this);
-        // Group: Properties
-        
-        // prop: text
-        // text of the title;
-        this.text = text;
-        // prop: show
-        // wether or not to show the title
-        this.show = true;
-        // prop: fontFamily
-        // css font-family spec for the text.
-        this.fontFamily;
-        // prop: fontSize
-        // css font-size spec for the text.
-        this.fontSize ;
-        // prop: textAlign
-        // css text-align spec for the text.
-        this.textAlign;
-        // prop: textColor
-        // css color spec for the text.
-        this.textColor;
-        // prop: renderer
-        // A class for creating a DOM element for the title,
-        // see <$.jqplot.DivTitleRenderer>.
-        this.renderer = $.jqplot.DivTitleRenderer;
-        // prop: rendererOptions
-        // renderer specific options passed to the renderer.
-        this.rendererOptions = {};   
-        // prop: escapeHtml
-        // True to escape special characters with their html entity equivalents
-        // in title text.  "<" becomes &lt; and so on, so html tags are not rendered.
-        this.escapeHtml = false;
-    }
-    
-    Title.prototype = new $.jqplot.ElemContainer();
-    Title.prototype.constructor = Title;
-    
-    Title.prototype.init = function() {
-        this.renderer = new this.renderer();
-        this.renderer.init.call(this, this.rendererOptions);
-    };
-    
-    Title.prototype.draw = function(width) {
-        return this.renderer.draw.call(this, width);
-    };
-    
-    Title.prototype.pack = function() {
-        this.renderer.pack.call(this);
-    };
-
-
-    /**
-     * Class: Series
-     * An individual data series object.  Cannot be instantiated directly, but created
-     * by the Plot oject.  Series properties can be set or overriden by the 
-     * options passed in from the user.
-     */
-    function Series() {
-        $.jqplot.ElemContainer.call(this);
-        // Group: Properties
-        // Properties will be assigned from a series array at the top level of the
-        // options.  If you had two series and wanted to change the color and line
-        // width of the first and set the second to use the secondary y axis with
-        // no shadow and supply custom labels for each:
-        // > {
-        // >    series:[
-        // >        {color: '#ff4466', lineWidth: 5, label:'good line'},
-        // >        {yaxis: 'y2axis', shadow: false, label:'bad line'}
-        // >    ]
-        // > }
-        
-        // prop: show
-        // wether or not to draw the series.
-        this.show = true;
-        // prop: xaxis
-        // which x axis to use with this series, either 'xaxis' or 'x2axis'.
-        this.xaxis = 'xaxis';
-        this._xaxis;
-        // prop: yaxis
-        // which y axis to use with this series, either 'yaxis' or 'y2axis'.
-        this.yaxis = 'yaxis';
-        this._yaxis;
-        this.gridBorderWidth = 2.0;
-        // prop: renderer
-        // A class of a renderer which will draw the series, 
-        // see <$.jqplot.LineRenderer>.
-        this.renderer = $.jqplot.LineRenderer;
-        // prop: rendererOptions
-        // Options to pass on to the renderer.
-        this.rendererOptions = {};
-        this.data = [];
-        this.gridData = [];
-        // prop: label
-        // Line label to use in the legend.
-        this.label = '';
-        // prop: showLabel
-        // true to show label for this series in the legend.
-        this.showLabel = true;
-        // prop: color
-        // css color spec for the series
-        this.color;
-        // prop: negativeColor
-        // css color spec used for filled (area) plots that are filled to zero and
-        // the "useNegativeColors" option is true.
-        this.negativeColor;
-        // prop: lineWidth
-        // width of the line in pixels.  May have different meanings depending on renderer.
-        this.lineWidth = 2.5;
-        // prop: lineJoin
-        // Canvas lineJoin style between segments of series.
-        this.lineJoin = 'round';
-        // prop: lineCap
-        // Canvas lineCap style at ends of line.
-        this.lineCap = 'round';
-        // prop: linePattern
-        // line pattern 'dashed', 'dotted', 'solid', some combination
-        // of '-' and '.' characters such as '.-.' or a numerical array like 
-        // [draw, skip, draw, skip, ...] such as [1, 10] to draw a dotted line, 
-        // [1, 10, 20, 10] to draw a dot-dash line, and so on.
-        this.linePattern = 'solid';
-        this.shadow = true;
-        // prop: shadowAngle
-        // Shadow angle in degrees
-        this.shadowAngle = 45;
-        // prop: shadowOffset
-        // Shadow offset from line in pixels
-        this.shadowOffset = 1.25;
-        // prop: shadowDepth
-        // Number of times shadow is stroked, each stroke offset shadowOffset from the last.
-        this.shadowDepth = 3;
-        // prop: shadowAlpha
-        // Alpha channel transparency of shadow.  0 = transparent.
-        this.shadowAlpha = '0.1';
-        // prop: breakOnNull
-        // Wether line segments should be be broken at null value.
-        // False will join point on either side of line.
-        this.breakOnNull = false;
-        // prop: markerRenderer
-        // A class of a renderer which will draw marker (e.g. circle, square, ...) at the data points,
-        // see <$.jqplot.MarkerRenderer>.
-        this.markerRenderer = $.jqplot.MarkerRenderer;
-        // prop: markerOptions
-        // renderer specific options to pass to the markerRenderer,
-        // see <$.jqplot.MarkerRenderer>.
-        this.markerOptions = {};
-        // prop: showLine
-        // wether to actually draw the line or not.  Series will still be renderered, even if no line is drawn.
-        this.showLine = true;
-        // prop: showMarker
-        // wether or not to show the markers at the data points.
-        this.showMarker = true;
-        // prop: index
-        // 0 based index of this series in the plot series array.
-        this.index;
-        // prop: fill
-        // true or false, wether to fill under lines or in bars.
-        // May not be implemented in all renderers.
-        this.fill = false;
-        // prop: fillColor
-        // CSS color spec to use for fill under line.  Defaults to line color.
-        this.fillColor;
-        // prop: fillAlpha
-        // Alpha transparency to apply to the fill under the line.
-        // Use this to adjust alpha separate from fill color.
-        this.fillAlpha;
-        // prop: fillAndStroke
-        // If true will stroke the line (with color this.color) as well as fill under it.
-        // Applies only when fill is true.
-        this.fillAndStroke = false;
-        // prop: disableStack
-        // true to not stack this series with other series in the plot.
-        // To render properly, non-stacked series must come after any stacked series
-        // in the plot's data series array.  So, the plot's data series array would look like:
-        // > [stackedSeries1, stackedSeries2, ..., nonStackedSeries1, nonStackedSeries2, ...]
-        // disableStack will put a gap in the stacking order of series, and subsequent
-        // stacked series will not fill down through the non-stacked series and will
-        // most likely not stack properly on top of the non-stacked series.
-        this.disableStack = false;
-        // _stack is set by the Plot if the plot is a stacked chart.
-        // will stack lines or bars on top of one another to build a "mountain" style chart.
-        // May not be implemented in all renderers.
-        this._stack = false;
-        // prop: neighborThreshold
-        // how close or far (in pixels) the cursor must be from a point marker to detect the point.
-        this.neighborThreshold = 4;
-        // prop: fillToZero
-        // true will force bar and filled series to fill toward zero on the fill Axis.
-        this.fillToZero = false;
-        // prop: fillToValue
-        // fill a filled series to this value on the fill axis.
-        // Works in conjunction with fillToZero, so that must be true.
-        this.fillToValue = 0;
-        // prop: fillAxis
-        // Either 'x' or 'y'.  Which axis to fill the line toward if fillToZero is true.
-        // 'y' means fill up/down to 0 on the y axis for this series.
-        this.fillAxis = 'y';
-        // prop: useNegativeColors
-        // true to color negative values differently in filled and bar charts.
-        this.useNegativeColors = true;
-        this._stackData = [];
-        // _plotData accounts for stacking.  If plots not stacked, _plotData and data are same.  If
-        // stacked, _plotData is accumulation of stacking data.
-        this._plotData = [];
-        // _plotValues hold the individual x and y values that will be plotted for this series.
-        this._plotValues = {x:[], y:[]};
-        // statistics about the intervals between data points.  Used for auto scaling.
-        this._intervals = {x:{}, y:{}};
-        // data from the previous series, for stacked charts.
-        this._prevPlotData = [];
-        this._prevGridData = [];
-        this._stackAxis = 'y';
-        this._primaryAxis = '_xaxis';
-        // give each series a canvas to draw on.  This should allow for redrawing speedups.
-        this.canvas = new $.jqplot.GenericCanvas();
-        this.shadowCanvas = new $.jqplot.GenericCanvas();
-        this.plugins = {};
-        // sum of y values in this series.
-        this._sumy = 0;
-        this._sumx = 0;
-        this._type = '';
-    }
-    
-    Series.prototype = new $.jqplot.ElemContainer();
-    Series.prototype.constructor = Series;
-    
-    Series.prototype.init = function(index, gridbw, plot) {
-        // weed out any null values in the data.
-        this.index = index;
-        this.gridBorderWidth = gridbw;
-        var d = this.data;
-        var temp = [], i;
-        for (i=0; i<d.length; i++) {
-            if (! this.breakOnNull) {
-                if (d[i] == null || d[i][0] == null || d[i][1] == null) {
-                    continue;
-                }
-                else {
-                    temp.push(d[i]);
-                }
-            }
-            else {
-                // TODO: figure out what to do with null values
-                // probably involve keeping nulls in data array
-                // and then updating renderers to break line
-                // when it hits null value.
-                // For now, just keep value.
-                temp.push(d[i]);
-            }
-        }
-        this.data = temp;
-
-        // parse the renderer options and apply default colors if not provided
-        if (!this.color && this.show) {
-            this.color = plot.colorGenerator.get(this.index);
-        }
-        if (!this.negativeColor && this.show) {
-            this.negativeColor = plot.negativeColorGenerator.get(this.index);
-        }
-
-
-        if (!this.fillColor) {
-            this.fillColor = this.color;
-        }
-        if (this.fillAlpha) {
-            var comp = $.jqplot.normalize2rgb(this.fillColor);
-            var comp = $.jqplot.getColorComponents(comp);
-            this.fillColor = 'rgba('+comp[0]+','+comp[1]+','+comp[2]+','+this.fillAlpha+')';
-        }
-        this.renderer = new this.renderer();
-        this.renderer.init.call(this, this.rendererOptions, plot);
-        this.markerRenderer = new this.markerRenderer();
-        if (!this.markerOptions.color) {
-            this.markerOptions.color = this.color;
-        }
-        if (this.markerOptions.show == null) {
-            this.markerOptions.show = this.showMarker;
-        }
-        this.showMarker = this.markerOptions.show;
-        // the markerRenderer is called within it's own scaope, don't want to overwrite series options!!
-        this.markerRenderer.init(this.markerOptions);
-    };
-    
-    // data - optional data point array to draw using this series renderer
-    // gridData - optional grid data point array to draw using this series renderer
-    // stackData - array of cumulative data for stacked plots.
-    Series.prototype.draw = function(sctx, opts, plot) {
-        var options = (opts == undefined) ? {} : opts;
-        sctx = (sctx == undefined) ? this.canvas._ctx : sctx;
-        
-        var j, data, gridData;
-        
-        // hooks get called even if series not shown
-        // we don't clear canvas here, it would wipe out all other series as well.
-        for (j=0; j<$.jqplot.preDrawSeriesHooks.length; j++) {
-            $.jqplot.preDrawSeriesHooks[j].call(this, sctx, options);
-        }
-        if (this.show) {
-            this.renderer.setGridData.call(this, plot);
-            if (!options.preventJqPlotSeriesDrawTrigger) {
-                $(sctx.canvas).trigger('jqplotSeriesDraw', [this.data, this.gridData]);
-            }
-            data = [];
-            if (options.data) {
-                data = options.data;
-            }
-            else if (!this._stack) {
-                data = this.data;
-            }
-            else {
-                data = this._plotData;
-            }
-            gridData = options.gridData || this.renderer.makeGridData.call(this, data, plot);
-
-            if (this._type === 'line' && this.renderer.smooth && this.renderer._smoothedData.length) {
-                gridData = this.renderer._smoothedData;
-            }
-
-            this.renderer.draw.call(this, sctx, gridData, options, plot);
-        }
-        
-        for (j=0; j<$.jqplot.postDrawSeriesHooks.length; j++) {
-            $.jqplot.postDrawSeriesHooks[j].call(this, sctx, options);
-        }
-        
-        sctx = opts = plot = j = data = gridData = null;
-    };
-    
-    Series.prototype.drawShadow = function(sctx, opts, plot) {
-        var options = (opts == undefined) ? {} : opts;
-        sctx = (sctx == undefined) ? this.shadowCanvas._ctx : sctx;
-        
-        var j, data, gridData;
-        
-        // hooks get called even if series not shown
-        // we don't clear canvas here, it would wipe out all other series as well.
-        for (j=0; j<$.jqplot.preDrawSeriesShadowHooks.length; j++) {
-            $.jqplot.preDrawSeriesShadowHooks[j].call(this, sctx, options);
-        }
-        if (this.shadow) {
-            this.renderer.setGridData.call(this, plot);
-
-            data = [];
-            if (options.data) {
-                data = options.data;
-            }
-            else if (!this._stack) {
-                data = this.data;
-            }
-            else {
-                data = this._plotData;
-            }
-            gridData = options.gridData || this.renderer.makeGridData.call(this, data, plot);
-        
-            this.renderer.drawShadow.call(this, sctx, gridData, options);
-        }
-        
-        for (j=0; j<$.jqplot.postDrawSeriesShadowHooks.length; j++) {
-            $.jqplot.postDrawSeriesShadowHooks[j].call(this, sctx, options);
-        }
-        
-        sctx = opts = plot = j = data = gridData = null;
-        
-    };
-    
-    // toggles series display on plot, e.g. show/hide series
-    Series.prototype.toggleDisplay = function(ev) {
-        var s, speed;
-        if (ev.data.series) {
-            s = ev.data.series;
-        }
-        else {
-            s = this;
-        }
-        if (ev.data.speed) {
-            speed = ev.data.speed;
-        }
-        if (speed) {
-            if (s.canvas._elem.is(':hidden')) {
-                s.canvas._elem.removeClass('jqplot-series-hidden');
-                if (s.shadowCanvas._elem) {
-                    s.shadowCanvas._elem.fadeIn(speed);
-                }
-                s.canvas._elem.fadeIn(speed);
-                s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).fadeIn(speed);
-            }
-            else {
-                s.canvas._elem.addClass('jqplot-series-hidden');
-                if (s.shadowCanvas._elem) {
-                    s.shadowCanvas._elem.fadeOut(speed);
-                }
-                s.canvas._elem.fadeOut(speed);
-                s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).fadeOut(speed);
-            }
-        }
-        else {
-            if (s.canvas._elem.is(':hidden')) {
-                s.canvas._elem.removeClass('jqplot-series-hidden');
-                if (s.shadowCanvas._elem) {
-                    s.shadowCanvas._elem.show();
-                }
-                s.canvas._elem.show();
-                s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).show();
-            }
-            else {
-                s.canvas._elem.addClass('jqplot-series-hidden');
-                if (s.shadowCanvas._elem) {
-                    s.shadowCanvas._elem.hide();
-                }
-                s.canvas._elem.hide();
-                s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).hide();
-            }
-        }
-    };
-    
-
-
-    /**
-     * Class: Grid
-     * 
-     * Object representing the grid on which the plot is drawn.  The grid in this
-     * context is the area bounded by the axes, the area which will contain the series.
-     * Note, the series are drawn on their own canvas.
-     * The Grid object cannot be instantiated directly, but is created by the Plot oject.  
-     * Grid properties can be set or overriden by the options passed in from the user.
-     */
-    function Grid() {
-        $.jqplot.ElemContainer.call(this);
-        // Group: Properties
-        
-        // prop: drawGridlines
-        // wether to draw the gridlines on the plot.
-        this.drawGridlines = true;
-        // prop: gridLineColor
-        // color of the grid lines.
-        this.gridLineColor = '#cccccc';
-        // prop: gridLineWidth
-        // width of the grid lines.
-        this.gridLineWidth = 1.0;
-        // prop: background
-        // css spec for the background color.
-        this.background = '#fffdf6';
-        // prop: borderColor
-        // css spec for the color of the grid border.
-        this.borderColor = '#999999';
-        // prop: borderWidth
-        // width of the border in pixels.
-        this.borderWidth = 2.0;
-        // prop: drawBorder
-        // True to draw border around grid.
-        this.drawBorder = true;
-        // prop: shadow
-        // wether to show a shadow behind the grid.
-        this.shadow = true;
-        // prop: shadowAngle
-        // shadow angle in degrees
-        this.shadowAngle = 45;
-        // prop: shadowOffset
-        // Offset of each shadow stroke from the border in pixels
-        this.shadowOffset = 1.5;
-        // prop: shadowWidth
-        // width of the stoke for the shadow
-        this.shadowWidth = 3;
-        // prop: shadowDepth
-        // Number of times shadow is stroked, each stroke offset shadowOffset from the last.
-        this.shadowDepth = 3;
-        // prop: shadowColor
-        // an optional css color spec for the shadow in 'rgba(n, n, n, n)' form
-        this.shadowColor = null;
-        // prop: shadowAlpha
-        // Alpha channel transparency of shadow.  0 = transparent.
-        this.shadowAlpha = '0.07';
-        this._left;
-        this._top;
-        this._right;
-        this._bottom;
-        this._width;
-        this._height;
-        this._axes = [];
-        // prop: renderer
-        // Instance of a renderer which will actually render the grid,
-        // see <$.jqplot.CanvasGridRenderer>.
-        this.renderer = $.jqplot.CanvasGridRenderer;
-        // prop: rendererOptions
-        // Options to pass on to the renderer,
-        // see <$.jqplot.CanvasGridRenderer>.
-        this.rendererOptions = {};
-        this._offsets = {top:null, bottom:null, left:null, right:null};
-    }
-    
-    Grid.prototype = new $.jqplot.ElemContainer();
-    Grid.prototype.constructor = Grid;
-    
-    Grid.prototype.init = function() {
-        this.renderer = new this.renderer();
-        this.renderer.init.call(this, this.rendererOptions);
-    };
-    
-    Grid.prototype.createElement = function(offsets,plot) {
-        this._offsets = offsets;
-        return this.renderer.createElement.call(this, plot);
-    };
-    
-    Grid.prototype.draw = function() {
-        this.renderer.draw.call(this);
-    };
-    
-    $.jqplot.GenericCanvas = function() {
-        $.jqplot.ElemContainer.call(this);
-        this._ctx;  
-    };
-    
-    $.jqplot.GenericCanvas.prototype = new $.jqplot.ElemContainer();
-    $.jqplot.GenericCanvas.prototype.constructor = $.jqplot.GenericCanvas;
-    
-    $.jqplot.GenericCanvas.prototype.createElement = function(offsets, clss, plotDimensions, plot) {
-        this._offsets = offsets;
-        var klass = 'jqplot';
-        if (clss != undefined) {
-            klass = clss;
-        }
-        var elem;
-
-        elem = plot.canvasManager.getCanvas();
-        
-        // if new plotDimensions supplied, use them.
-        if (plotDimensions != null) {
-            this._plotDimensions = plotDimensions;
-        }
-        
-        elem.width = this._plotDimensions.width - this._offsets.left - this._offsets.right;
-        elem.height = this._plotDimensions.height - this._offsets.top - this._offsets.bottom;
-        this._elem = $(elem);
-        this._elem.css({ position: 'absolute', left: this._offsets.left, top: this._offsets.top });
-        
-        this._elem.addClass(klass);
-        
-        elem = plot.canvasManager.initCanvas(elem);
-        
-        elem = null;
-        return this._elem;
-    };
-    
-    $.jqplot.GenericCanvas.prototype.setContext = function() {
-        this._ctx = this._elem.get(0).getContext("2d");
-        return this._ctx;
-    };
-    
-    // Memory Leaks patch
-    $.jqplot.GenericCanvas.prototype.resetCanvas = function() {
-      if (this._elem) {
-        if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
-           window.G_vmlCanvasManager.uninitElement(this._elem.get(0));
-        }
-        
-        //this._elem.remove();
-        this._elem.emptyForce();
-      }
-      
-      this._ctx = null;
-    };
-    
-    $.jqplot.HooksManager = function () {
-        this.hooks =[];
-    };
-    
-    $.jqplot.HooksManager.prototype.addOnce = function(fn) {
-        var havehook = false, i;
-        for (i=0; i<this.hooks.length; i++) {
-            if (this.hooks[i][0] == fn) {
-                havehook = true;
-            }
-        }
-        if (!havehook) {
-            this.hooks.push(fn);
-        }
-    };
-    
-    $.jqplot.HooksManager.prototype.add = function(fn) {
-        this.hooks.push(fn);
-    };
-    
-    $.jqplot.EventListenerManager = function () {
-        this.hooks =[];
-    };
-    
-    $.jqplot.EventListenerManager.prototype.addOnce = function(ev, fn) {
-        var havehook = false, h, i;
-        for (i=0; i<this.hooks.length; i++) {
-            h = this.hooks[i];
-            if (h[0] == ev && h[1] == fn) {
-                havehook = true;
-            }
-        }
-        if (!havehook) {
-            this.hooks.push([ev, fn]);
-        }
-    };
-    
-    $.jqplot.EventListenerManager.prototype.add = function(ev, fn) {
-        this.hooks.push([ev, fn]);
-    };
-
-
-    var _axisNames = ['yMidAxis', 'xaxis', 'yaxis', 'x2axis', 'y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis'];
-
-    /**
-     * Class: jqPlot
-     * Plot object returned by call to $.jqplot.  Handles parsing user options,
-     * creating sub objects (Axes, legend, title, series) and rendering the plot.
-     */
-    function jqPlot() {
-        // Group: Properties
-        // These properties are specified at the top of the options object
-        // like so:
-        // > {
-        // >     axesDefaults:{min:0},
-        // >     series:[{color:'#6633dd'}],
-        // >     title: 'A Plot'
-        // > }
-        //
-        // prop: data
-        // user's data.  Data should *NOT* be specified in the options object,
-        // but be passed in as the second argument to the $.jqplot() function.
-        // The data property is described here soley for reference. 
-        // The data should be in the form of an array of 2D or 1D arrays like
-        // > [ [[x1, y1], [x2, y2],...], [y1, y2, ...] ].
-        this.data = [];
-        // prop: dataRenderer
-        // A callable which can be used to preprocess data passed into the plot.
-        // Will be called with 2 arguments, the plot data and a reference to the plot.
-        this.dataRenderer;
-        // prop: dataRendererOptions
-        // Options that will be passed to the dataRenderer.
-        // Can be of any type.
-        this.dataRendererOptions;
-        // prop: noDataIndicator
-        // Options to set up a mock plot with a data loading indicator if no data is specified.
-        this.noDataIndicator = {    
-            show: false,
-            indicator: 'Loading Data...',
-            axes: {
-                xaxis: {
-                    min: 0,
-                    max: 10,
-                    tickInterval: 2,
-                    show: true
-                },
-                yaxis: {
-                    min: 0,
-                    max: 12,
-                    tickInterval: 3,
-                    show: true
-                }
-            }
-        };
-        // The id of the dom element to render the plot into
-        this.targetId = null;
-        // the jquery object for the dom target.
-        this.target = null; 
-        this.defaults = {
-            // prop: axesDefaults
-            // default options that will be applied to all axes.
-            // see <Axis> for axes options.
-            axesDefaults: {},
-            axes: {xaxis:{}, yaxis:{}, x2axis:{}, y2axis:{}, y3axis:{}, y4axis:{}, y5axis:{}, y6axis:{}, y7axis:{}, y8axis:{}, y9axis:{}, yMidAxis:{}},
-            // prop: seriesDefaults
-            // default options that will be applied to all series.
-            // see <Series> for series options.
-            seriesDefaults: {},
-            series:[]
-        };
-        // prop: series
-        // Array of series object options.
-        // see <Series> for series specific options.
-        this.series = [];
-        // prop: axes
-        // up to 4 axes are supported, each with it's own options, 
-        // See <Axis> for axis specific options.
-        this.axes = {xaxis: new Axis('xaxis'), yaxis: new Axis('yaxis'), x2axis: new Axis('x2axis'), y2axis: new Axis('y2axis'), y3axis: new Axis('y3axis'), y4axis: new Axis('y4axis'), y5axis: new Axis('y5axis'), y6axis: new Axis('y6axis'), y7axis: new Axis('y7axis'), y8axis: new Axis('y8axis'), y9axis: new Axis('y9axis'), yMidAxis: new Axis('yMidAxis')};
-        // prop: grid
-        // See <Grid> for grid specific options.
-        this.grid = new Grid();
-        // prop: legend
-        // see <$.jqplot.TableLegendRenderer>
-        this.legend = new Legend();
-        this.baseCanvas = new $.jqplot.GenericCanvas();
-        // array of series indicies. Keep track of order
-        // which series canvases are displayed, lowest
-        // to highest, back to front.
-        this.seriesStack = [];
-        this.previousSeriesStack = [];
-        this.eventCanvas = new $.jqplot.GenericCanvas();
-        this._width = null;
-        this._height = null; 
-        this._plotDimensions = {height:null, width:null};
-        this._gridPadding = {top:null, right:null, bottom:null, left:null};
-        this._defaultGridPadding = {top:10, right:10, bottom:23, left:10};
-        // a shortcut for axis syncTicks options.  Not implemented yet.
-        this.syncXTicks = true;
-        // a shortcut for axis syncTicks options.  Not implemented yet.
-        this.syncYTicks = true;
-        // prop: seriesColors
-        // Ann array of CSS color specifications that will be applied, in order,
-        // to the series in the plot.  Colors will wrap around so, if their
-        // are more series than colors, colors will be reused starting at the
-        // beginning.  For pie charts, this specifies the colors of the slices.
-        this.seriesColors = $.jqplot.config.defaultColors;
-        this.negativeSeriesColors = $.jqplot.config.defaultNegativeColors;
-        // prop: sortData
-        // false to not sort the data passed in by the user.
-        // Many bar, stakced and other graphs as well as many plugins depend on
-        // having sorted data.
-        this.sortData = true;
-        var seriesColorsIndex = 0;
-        // prop textColor
-        // css spec for the css color attribute.  Default for the entire plot.
-        this.textColor;
-        // prop; fontFamily
-        // css spec for the font-family attribute.  Default for the entire plot.
-        this.fontFamily;
-        // prop: fontSize
-        // css spec for the font-size attribute.  Default for the entire plot.
-        this.fontSize;
-        // prop: title
-        // Title object.  See <Title> for specific options.  As a shortcut, you
-        // can specify the title option as just a string like: title: 'My Plot'
-        // and this will create a new title object with the specified text.
-        this.title = new Title();
-        // container to hold all of the merged options.  Convienence for plugins.
-        this.options = {};
-        // prop: stackSeries
-        // true or false, creates a stack or "mountain" plot.
-        // Not all series renderers may implement this option.
-        this.stackSeries = false;
-        // prop: defaultAxisStart
-        // 1-D data series are internally converted into 2-D [x,y] data point arrays
-        // by jqPlot.  This is the default starting value for the missing x or y value.
-        // The added data will be a monotonically increasing series (e.g. [1, 2, 3, ...])
-        // starting at this value.
-        this.defaultAxisStart = 1;
-        // array to hold the cumulative stacked series data.
-        // used to ajust the individual series data, which won't have access to other
-        // series data.
-        this._stackData = [];
-        // array that holds the data to be plotted. This will be the series data
-        // merged with the the appropriate data from _stackData according to the stackAxis.
-        this._plotData = [];
-        // Namespece to hold plugins.  Generally non-renderer plugins add themselves to here.
-        this.plugins = {};
-        // Count how many times the draw method has been called while the plot is visible.
-        // Mostly used to test if plot has never been dran (=0), has been successfully drawn
-        // into a visible container once (=1) or draw more than once into a visible container.
-        // Can use this in tests to see if plot has been visibly drawn at least one time.
-        // After plot has been visibly drawn once, it generally doesn't need redrawn if its
-        // container is hidden and shown.
-        this._drawCount = 0;
-        // this.doCustomEventBinding = true;
-        // prop: drawIfHidden
-        // True to execute the draw method even if the plot target is hidden.
-        // Generally, this should be false.  Most plot elements will not be sized/
-        // positioned correclty if renderered into a hidden container.  To render into
-        // a hidden container, call the replot method when the container is shown.
-        this.drawIfHidden = false;
-        // true to intercept right click events and fire a 'jqplotRightClick' event.
-        // this will also block the context menu.
-        this.captureRightClick = false;
-        this.themeEngine = new $.jqplot.ThemeEngine();
-        // sum of y values for all series in plot.
-        // used in mekko chart.
-        this._sumy = 0;
-        this._sumx = 0;
-        this.preInitHooks = new $.jqplot.HooksManager();
-        this.postInitHooks = new $.jqplot.HooksManager();
-        this.preParseOptionsHooks = new $.jqplot.HooksManager();
-        this.postParseOptionsHooks = new $.jqplot.HooksManager();
-        this.preDrawHooks = new $.jqplot.HooksManager();
-        this.postDrawHooks = new $.jqplot.HooksManager();
-        this.preDrawSeriesHooks = new $.jqplot.HooksManager();
-        this.postDrawSeriesHooks = new $.jqplot.HooksManager();
-        this.preDrawLegendHooks = new $.jqplot.HooksManager();
-        this.addLegendRowHooks = new $.jqplot.HooksManager();
-        this.preSeriesInitHooks = new $.jqplot.HooksManager();
-        this.postSeriesInitHooks = new $.jqplot.HooksManager();
-        this.preParseSeriesOptionsHooks = new $.jqplot.HooksManager();
-        this.postParseSeriesOptionsHooks = new $.jqplot.HooksManager();
-        this.eventListenerHooks = new $.jqplot.EventListenerManager();
-        this.preDrawSeriesShadowHooks = new $.jqplot.HooksManager();
-        this.postDrawSeriesShadowHooks = new $.jqplot.HooksManager();
-        
-        this.colorGenerator = new $.jqplot.ColorGenerator();
-        this.negativeColorGenerator = new $.jqplot.ColorGenerator();
-
-        this.canvasManager = new $.jqplot.CanvasManager();
-        
-        // Group: methods
-        //
-        // method: init
-        // sets the plot target, checks data and applies user
-        // options to plot.
-        this.init = function(target, data, options) {
-            options = options || {};
-            for (var i=0; i<$.jqplot.preInitHooks.length; i++) {
-                $.jqplot.preInitHooks[i].call(this, target, data, options);
-            }
-
-            for (var i=0; i<this.preInitHooks.hooks.length; i++) {
-                this.preInitHooks.hooks[i].call(this, target, data, options);
-            }
-            
-            this.targetId = '#'+target;
-            this.target = $('#'+target);
-            // remove any error class that may be stuck on target.
-            this.target.removeClass('jqplot-error');
-            if (!this.target.get(0)) {
-                throw "No plot target specified";
-            }
-            
-            // make sure the target is positioned by some means and set css
-            if (this.target.css('position') == 'static') {
-                this.target.css('position', 'relative');
-            }
-            if (!this.target.hasClass('jqplot-target')) {
-                this.target.addClass('jqplot-target');
-            }
-            
-            // if no height or width specified, use a default.
-            if (!this.target.height()) {
-                var h;
-                if (options && options.height) {
-                    h = parseInt(options.height, 10);
-                }
-                else if (this.target.attr('data-height')) {
-                    h = parseInt(this.target.attr('data-height'), 10);
-                }
-                else {
-                    h = parseInt($.jqplot.config.defaultHeight, 10);
-                }
-                this._height = h;
-                this.target.css('height', h+'px');
-            }
-            else {
-                this._height = h = this.target.height();
-            }
-            if (!this.target.width()) {
-                var w;
-                if (options && options.width) {
-                    w = parseInt(options.width, 10);
-                }
-                else if (this.target.attr('data-width')) {
-                    w = parseInt(this.target.attr('data-width'), 10);
-                }
-                else {
-                    w = parseInt($.jqplot.config.defaultWidth, 10);
-                }
-                this._width = w;
-                this.target.css('width', w+'px');
-            }
-            else {
-                this._width = w = this.target.width();
-            }
-            
-            this._plotDimensions.height = this._height;
-            this._plotDimensions.width = this._width;
-            this.grid._plotDimensions = this._plotDimensions;
-            this.title._plotDimensions = this._plotDimensions;
-            this.baseCanvas._plotDimensions = this._plotDimensions;
-            this.eventCanvas._plotDimensions = this._plotDimensions;
-            this.legend._plotDimensions = this._plotDimensions;
-            if (this._height <=0 || this._width <=0 || !this._height || !this._width) {
-                throw "Canvas dimension not set";
-            }
-            
-            if (options.dataRenderer && jQuery.isFunction(options.dataRenderer)) {
-                if (options.dataRendererOptions) {
-                    this.dataRendererOptions = options.dataRendererOptions;
-                }
-                this.dataRenderer = options.dataRenderer;
-                data = this.dataRenderer(data, this, this.dataRendererOptions);
-            }
-            
-            if (options.noDataIndicator && jQuery.isPlainObject(options.noDataIndicator)) {
-                $.extend(true, this.noDataIndicator, options.noDataIndicator);
-            }
-            
-            if (data == null || jQuery.isArray(data) == false || data.length == 0 || jQuery.isArray(data[0]) == false || data[0].length == 0) {
-                
-                if (this.noDataIndicator.show == false) {
-                    throw{
-                        name: "DataError",
-                        message: "No data to plot."
-                    };
-                }
-                
-                else {
-                    // have to be descructive here in order for plot to not try and render series.
-                    // This means that $.jqplot() will have to be called again when there is data.
-                    //delete options.series;
-                    
-                    for (var ax in this.noDataIndicator.axes) {
-                        for (var prop in this.noDataIndicator.axes[ax]) {
-                            this.axes[ax][prop] = this.noDataIndicator.axes[ax][prop];
-                        }
-                    }
-                    
-                    this.postDrawHooks.add(function() {
-                        var eh = this.eventCanvas.getHeight();
-                        var ew = this.eventCanvas.getWidth();
-                        var temp = $('<div class="jqplot-noData-container" style="position:absolute;"></div>');
-                        this.target.append(temp);
-                        temp.height(eh);
-                        temp.width(ew);
-                        temp.css('top', this.eventCanvas._offsets.top);
-                        temp.css('left', this.eventCanvas._offsets.left);
-                        
-                        var temp2 = $('<div class="jqplot-noData-contents" style="text-align:center; position:relative; margin-left:auto; margin-right:auto;"></div>');
-                        temp.append(temp2);
-                        temp2.html(this.noDataIndicator.indicator);
-                        var th = temp2.height();
-                        var tw = temp2.width();
-                        temp2.height(th);
-                        temp2.width(tw);
-                        temp2.css('top', (eh - th)/2 + 'px');
-                    });
-
-                }
-            }
-            
-            this.data = data;
-            
-            this.parseOptions(options);
-            
-            if (this.textColor) {
-                this.target.css('color', this.textColor);
-            }
-            if (this.fontFamily) {
-                this.target.css('font-family', this.fontFamily);
-            }
-            if (this.fontSize) {
-                this.target.css('font-size', this.fontSize);
-            }
-            
-            this.title.init();
-            this.legend.init();
-            this._sumy = 0;
-            this._sumx = 0;
-            for (var i=0; i<this.series.length; i++) {
-                // set default stacking order for series canvases
-                this.seriesStack.push(i);
-                this.previousSeriesStack.push(i);
-                this.series[i].shadowCanvas._plotDimensions = this._plotDimensions;
-                this.series[i].canvas._plotDimensions = this._plotDimensions;
-                for (var j=0; j<$.jqplot.preSeriesInitHooks.length; j++) {
-                    $.jqplot.preSeriesInitHooks[j].call(this.series[i], target, data, this.options.seriesDefaults, this.options.series[i], this);
-                }
-                for (var j=0; j<this.preSeriesInitHooks.hooks.length; j++) {
-                    this.preSeriesInitHooks.hooks[j].call(this.series[i], target, data, this.options.seriesDefaults, this.options.series[i], this);
-                }
-                this.populatePlotData(this.series[i], i);
-                this.series[i]._plotDimensions = this._plotDimensions;
-                this.series[i].init(i, this.grid.borderWidth, this);
-                for (var j=0; j<$.jqplot.postSeriesInitHooks.length; j++) {
-                    $.jqplot.postSeriesInitHooks[j].call(this.series[i], target, data, this.options.seriesDefaults, this.options.series[i], this);
-                }
-                for (var j=0; j<this.postSeriesInitHooks.hooks.length; j++) {
-                    this.postSeriesInitHooks.hooks[j].call(this.series[i], target, data, this.options.seriesDefaults, this.options.series[i], this);
-                }
-                this._sumy += this.series[i]._sumy;
-                this._sumx += this.series[i]._sumx;
-            }
-
-            for (var i=0; i<12; i++) {
-                name = _axisNames[i];
-                this.axes[name]._plotDimensions = this._plotDimensions;
-                this.axes[name].init();
-                if (this.axes[name].borderColor == null) {
-                    if (name.charAt(0) !== 'x' && this.axes[name].useSeriesColor === true && this.axes[name].show) {
-                        this.axes[name].borderColor = this.axes[name]._series[0].color;
-                    }
-                    else {
-                        this.axes[name].borderColor = this.grid.borderColor;
-                    }
-                }
-            }
-            
-            if (this.sortData) {
-                sortData(this.series);
-            }
-            this.grid.init();
-            this.grid._axes = this.axes;
-            
-            this.legend._series = this.series;
-
-            for (var i=0; i<$.jqplot.postInitHooks.length; i++) {
-                $.jqplot.postInitHooks[i].call(this, target, data, options);
-            }
-
-            for (var i=0; i<this.postInitHooks.hooks.length; i++) {
-                this.postInitHooks.hooks[i].call(this, target, data, options);
-            }
-        };  
-        
-        // method: resetAxesScale
-        // Reset the specified axes min, max, numberTicks and tickInterval properties to null
-        // or reset these properties on all axes if no list of axes is provided.
-        //
-        // Parameters:
-        // axes - Boolean to reset or not reset all axes or an array or object of axis names to reset.
-        this.resetAxesScale = function(axes, options) {
-            var opts = options || {};
-            var ax = axes || this.axes;
-            if (ax === true) {
-                ax = this.axes;
-            }
-            if (jQuery.isArray(ax)) {
-                for (var i = 0; i < ax.length; i++) {
-                    this.axes[ax[i]].resetScale(opts[ax[i]]);
-                }
-            }
-            else if (typeof(ax) === 'object') {
-                for (var name in ax) {
-                    this.axes[name].resetScale(opts[name]);
-                }
-            }
-        };
-        // method: reInitialize
-        // reinitialize plot for replotting.
-        // not called directly.
-        this.reInitialize = function () {
-            // Plot should be visible and have a height and width.
-            // If plot doesn't have height and width for some
-            // reason, set it by other means.  Plot must not have
-            // a display:none attribute, however.
-            
-            //
-            // Wont have options here
-            /*
-            if (!this.target.height()) {
-                var h;
-                if (options && options.height) {
-                    h = parseInt(options.height, 10);
-                }
-                else if (this.target.attr('data-height')) {
-                    h = parseInt(this.target.attr('data-height'), 10);
-                }
-                else {
-                    h = parseInt($.jqplot.config.defaultHeight, 10);
-                }
-                this._height = h;
-                this.target.css('height', h+'px');
-            }
-            else {
-                this._height = this.target.height();
-            }
-            if (!this.target.width()) {
-                var w;
-                if (options && options.width) {
-                    w = parseInt(options.width, 10);
-                }
-                else if (this.target.attr('data-width')) {
-                    w = parseInt(this.target.attr('data-width'), 10);
-                }
-                else {
-                    w = parseInt($.jqplot.config.defaultWidth, 10);
-                }
-                this._width = w;
-                this.target.css('width', w+'px');
-            }
-            else {
-                this._width = this.target.width();
-            }
-            */
-            
-            this._height = this.target.height();
-            this._width = this.target.width();
-            
-            if (this._height <=0 || this._width <=0 || !this._height || !this._width) {
-                throw "Target dimension not set";
-            }
-            
-            this._plotDimensions.height = this._height;
-            this._plotDimensions.width = this._width;
-            this.grid._plotDimensions = this._plotDimensions;
-            this.title._plotDimensions = this._plotDimensions;
-            this.baseCanvas._plotDimensions = this._plotDimensions;
-            this.eventCanvas._plotDimensions = this._plotDimensions;
-            this.legend._plotDimensions = this._plotDimensions;
-            
-            for (var n in this.axes) {
-                this.axes[n]._plotWidth = this._width;
-                this.axes[n]._plotHeight = this._height;
-            }
-            
-            this.title._plotWidth = this._width;
-            
-            if (this.textColor) {
-                this.target.css('color', this.textColor);
-            }
-            if (this.fontFamily) {
-                this.target.css('font-family', this.fontFamily);
-            }
-            if (this.fontSize) {
-                this.target.css('font-size', this.fontSize);
-            }
-            
-            this._sumy = 0;
-            this._sumx = 0;
-            for (var i=0; i<this.series.length; i++) {
-                this.populatePlotData(this.series[i], i);
-                if (this.series[i]._type === 'line' && this.series[i].renderer.bands.show) {
-                    this.series[i].renderer.initBands.call(this.series[i], this.series[i].renderer.options, this);
-                }
-                this.series[i]._plotDimensions = this._plotDimensions;
-                this.series[i].canvas._plotDimensions = this._plotDimensions;
-                //this.series[i].init(i, this.grid.borderWidth);
-                this._sumy += this.series[i]._sumy;
-                this._sumx += this.series[i]._sumx;
-            }
-            
-            for (var j=0; j<12; j++) {
-                name = _axisNames[j];
-                // Memory Leaks patch : clear ticks elements
-                var t = this.axes[name]._ticks;
-                for (var i = 0; i < t.length; i++) {
-                  var el = t[i]._elem;
-                  if (el) {
-                    // if canvas renderer
-                    if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
-                      window.G_vmlCanvasManager.uninitElement(el.get(0));
-                    }
-                    el.emptyForce();
-                    el = null;
-                    t._elem = null;
-                  }
-                }
-                t = null;
-                
-                this.axes[name]._plotDimensions = this._plotDimensions;
-                this.axes[name]._ticks = [];
-                // this.axes[name].renderer.init.call(this.axes[name], {});
-            }
-            
-            if (this.sortData) {
-                sortData(this.series);
-            }
-            
-            this.grid._axes = this.axes;
-            
-            this.legend._series = this.series;
-        };
-        
-        // sort the series data in increasing order.
-        function sortData(series) {
-            var d, sd, pd, ppd, ret;
-            for (var i=0; i<series.length; i++) {
-                // d = series[i].data;
-                // sd = series[i]._stackData;
-                // pd = series[i]._plotData;
-                // ppd = series[i]._prevPlotData;
-                var check;
-                var bat = [series[i].data, series[i]._stackData, series[i]._plotData, series[i]._prevPlotData];
-                for (var n=0; n<4; n++) {
-                    check = true;
-                    d = bat[n];
-                    if (series[i]._stackAxis == 'x') {
-                        for (var j = 0; j < d.length; j++) {
-                            if (typeof(d[j][1]) != "number") {
-                                check = false;
-                                break;
-                            }
-                        }
-                        if (check) {
-                            d.sort(function(a,b) { return a[1] - b[1]; });
-                            // sd.sort(function(a,b) { return a[1] - b[1]; });
-                            // pd.sort(function(a,b) { return a[1] - b[1]; });
-                            // ppd.sort(function(a,b) { return a[1] - b[1]; });
-                        }
-                    }
-                    else {
-                        for (var j = 0; j < d.length; j++) {
-                            if (typeof(d[j][0]) != "number") {
-                                check = false;
-                                break;
-                            }
-                        }
-                        if (check) {
-                            d.sort(function(a,b) { return a[0] - b[0]; });
-                            // sd.sort(function(a,b) { return a[0] - b[0]; });
-                            // pd.sort(function(a,b) { return a[0] - b[0]; });
-                            // ppd.sort(function(a,b) { return a[0] - b[0]; });
-                        }
-                    }
-                }
-               
-            }
-        }
-        
-        // populate the _stackData and _plotData arrays for the plot and the series.
-        this.populatePlotData = function(series, index) {
-            // if a stacked chart, compute the stacked data
-            this._plotData = [];
-            this._stackData = [];
-            series._stackData = [];
-            series._plotData = [];
-            var plotValues = {x:[], y:[]};
-            if (this.stackSeries && !series.disableStack) {
-                series._stack = true;
-                var sidx = series._stackAxis == 'x' ? 0 : 1;
-                var idx = sidx ? 0 : 1;
-                // push the current data into stackData
-                //this._stackData.push(this.series[i].data);
-                var temp = $.extend(true, [], series.data);
-                // create the data that will be plotted for this series
-                var plotdata = $.extend(true, [], series.data);
-                // for first series, nothing to add to stackData.
-                for (var j=0; j<index; j++) {
-                    var cd = this.series[j].data;
-                    for (var k=0; k<cd.length; k++) {
-                        temp[k][0] += cd[k][0];
-                        temp[k][1] += cd[k][1];
-                        // only need to sum up the stack axis column of data
-                        plotdata[k][sidx] += cd[k][sidx];
-                    }
-                }
-                for (var i=0; i<plotdata.length; i++) {
-                    plotValues.x.push(plotdata[i][0]);
-                    plotValues.y.push(plotdata[i][1]);
-                }
-                this._plotData.push(plotdata);
-                this._stackData.push(temp);
-                series._stackData = temp;
-                series._plotData = plotdata;
-                series._plotValues = plotValues;
-            }
-            else {
-                for (var i=0; i<series.data.length; i++) {
-                    plotValues.x.push(series.data[i][0]);
-                    plotValues.y.push(series.data[i][1]);
-                }
-                this._stackData.push(series.data);
-                this.series[index]._stackData = series.data;
-                this._plotData.push(series.data);
-                series._plotData = series.data;
-                series._plotValues = plotValues;
-            }
-            if (index>0) {
-                series._prevPlotData = this.series[index-1]._plotData;
-            }
-            series._sumy = 0;
-            series._sumx = 0;
-            for (i=series.data.length-1; i>-1; i--) {
-                series._sumy += series.data[i][1];
-                series._sumx += series.data[i][0];
-            }
-        };
-
-        // this.setData = function(seriesIndex, newdata) {
-        //     // if newdata is null, assume all data is passed in as first argument
-        //     if (newdata == null) {
-                
-        //     }
-        // };
-        
-        // function to safely return colors from the color array and wrap around at the end.
-        this.getNextSeriesColor = (function(t) {
-            var idx = 0;
-            var sc = t.seriesColors;
-            
-            return function () { 
-                if (idx < sc.length) {
-                    return sc[idx++];
-                }
-                else {
-                    idx = 0;
-                    return sc[idx++];
-                }
-            };
-        })(this);
-    
-        this.parseOptions = function(options){
-            for (var i=0; i<this.preParseOptionsHooks.hooks.length; i++) {
-                this.preParseOptionsHooks.hooks[i].call(this, options);
-            }
-            for (var i=0; i<$.jqplot.preParseOptionsHooks.length; i++) {
-                $.jqplot.preParseOptionsHooks[i].call(this, options);
-            }
-            this.options = $.extend(true, {}, this.defaults, options);
-            this.stackSeries = this.options.stackSeries;
-            if (this.options.seriesColors) {
-                this.seriesColors = this.options.seriesColors;
-            }
-            if (this.options.negativeSeriesColors) {
-                this.negativeSeriesColors = this.options.negativeSeriesColors;
-            }
-            if (this.options.captureRightClick) {
-                this.captureRightClick = this.options.captureRightClick;
-            }
-            this.defaultAxisStart = (options && options.defaultAxisStart != null) ? options.defaultAxisStart : this.defaultAxisStart;
-            this.colorGenerator.setColors(this.seriesColors);
-            this.negativeColorGenerator.setColors(this.negativeSeriesColors);
-            // var cg = new this.colorGenerator(this.seriesColors);
-            // var ncg = new this.colorGenerator(this.negativeSeriesColors);
-            // this._gridPadding = this.options.gridPadding;
-            $.extend(true, this._gridPadding, this.options.gridPadding);
-            this.sortData = (this.options.sortData != null) ? this.options.sortData : this.sortData;
-            for (var i=0; i<12; i++) {
-                var n = _axisNames[i];
-                var axis = this.axes[n];
-                axis._options = $.extend(true, {}, this.options.axesDefaults, this.options.axes[n]);
-                $.extend(true, axis, this.options.axesDefaults, this.options.axes[n]);
-                axis._plotWidth = this._width;
-                axis._plotHeight = this._height;
-            }
-            // if (this.data.length == 0) {
-            //     this.data = [];
-            //     for (var i=0; i<this.options.series.length; i++) {
-            //         this.data.push(this.options.series.data);
-            //     }    
-            // }
-                
-            var normalizeData = function(data, dir, start) {
-                // return data as an array of point arrays,
-                // in form [[x1,y1...], [x2,y2...], ...]
-                var temp = [];
-                var i;
-                dir = dir || 'vertical';
-                if (!jQuery.isArray(data[0])) {
-                    // we have a series of scalars.  One line with just y values.
-                    // turn the scalar list of data into a data array of form:
-                    // [[1, data[0]], [2, data[1]], ...]
-                    for (i=0; i<data.length; i++) {
-                        if (dir == 'vertical') {
-                            temp.push([start + i, data[i]]);   
-                        }
-                        else {
-                            temp.push([data[i], start+i]);
-                        }
-                    }
-                }            
-                else {
-                    // we have a properly formatted data series, copy it.
-                    $.extend(true, temp, data);
-                }
-                return temp;
-            };
-
-            var colorIndex = 0;
-            for (var i=0; i<this.data.length; i++) {
-                var temp = new Series();
-                for (var j=0; j<$.jqplot.preParseSeriesOptionsHooks.length; j++) {
-                    $.jqplot.preParseSeriesOptionsHooks[j].call(temp, this.options.seriesDefaults, this.options.series[i]);
-                }
-                for (var j=0; j<this.preParseSeriesOptionsHooks.hooks.length; j++) {
-                    this.preParseSeriesOptionsHooks.hooks[j].call(temp, this.options.seriesDefaults, this.options.series[i]);
-                }
-                $.extend(true, temp, {seriesColors:this.seriesColors, negativeSeriesColors:this.negativeSeriesColors}, this.options.seriesDefaults, this.options.series[i]);
-                var dir = 'vertical';
-                if (temp.renderer === $.jqplot.BarRenderer && temp.rendererOptions && temp.rendererOptions.barDirection == 'horizontal' && temp.transposeData === true) {
-                    dir = 'horizontal';
-                }
-                temp.data = normalizeData(this.data[i], dir, this.defaultAxisStart);
-                switch (temp.xaxis) {
-                    case 'xaxis':
-                        temp._xaxis = this.axes.xaxis;
-                        break;
-                    case 'x2axis':
-                        temp._xaxis = this.axes.x2axis;
-                        break;
-                    default:
-                        break;
-                }
-                temp._yaxis = this.axes[temp.yaxis];
-                temp._xaxis._series.push(temp);
-                temp._yaxis._series.push(temp);
-                if (temp.show) {
-                    temp._xaxis.show = true;
-                    temp._yaxis.show = true;
-                }
-
-                // // parse the renderer options and apply default colors if not provided
-                // if (!temp.color && temp.show != false) {
-                //     temp.color = cg.next();
-                //     colorIndex = cg.getIndex() - 1;;
-                // }
-                // if (!temp.negativeColor && temp.show != false) {
-                //     temp.negativeColor = ncg.get(colorIndex);
-                //     ncg.setIndex(colorIndex);
-                // }
-                if (!temp.label) {
-                    temp.label = 'Series '+ (i+1).toString();
-                }
-                // temp.rendererOptions.show = temp.show;
-                // $.extend(true, temp.renderer, {color:this.seriesColors[i]}, this.rendererOptions);
-                this.series.push(temp);  
-                for (var j=0; j<$.jqplot.postParseSeriesOptionsHooks.length; j++) {
-                    $.jqplot.postParseSeriesOptionsHooks[j].call(this.series[i], this.options.seriesDefaults, this.options.series[i]);
-                }
-                for (var j=0; j<this.postParseSeriesOptionsHooks.hooks.length; j++) {
-                    this.postParseSeriesOptionsHooks.hooks[j].call(this.series[i], this.options.seriesDefaults, this.options.series[i]);
-                }
-            }
-            
-            // copy the grid and title options into this object.
-            $.extend(true, this.grid, this.options.grid);
-            // if axis border properties aren't set, set default.
-            for (var i=0; i<12; i++) {
-                var n = _axisNames[i];
-                var axis = this.axes[n];
-                if (axis.borderWidth == null) {
-                    axis.borderWidth =this.grid.borderWidth;
-                }
-            }
-            
-            if (typeof this.options.title == 'string') {
-                this.title.text = this.options.title;
-            }
-            else if (typeof this.options.title == 'object') {
-                $.extend(true, this.title, this.options.title);
-            }
-            this.title._plotWidth = this._width;
-            this.legend.setOptions(this.options.legend);
-            
-            for (var i=0; i<$.jqplot.postParseOptionsHooks.length; i++) {
-                $.jqplot.postParseOptionsHooks[i].call(this, options);
-            }
-            for (var i=0; i<this.postParseOptionsHooks.hooks.length; i++) {
-                this.postParseOptionsHooks.hooks[i].call(this, options);
-            }
-        };
-        
-        // method: destroy
-        // Releases all resources occupied by the plot
-        this.destroy = function() {
-            this.canvasManager.freeAllCanvases();
-            if (this.eventCanvas && this.eventCanvas._elem) {
-                this.eventCanvas._elem.unbind();
-            }
-            // Couple of posts on Stack Overflow indicate that empty() doesn't
-            // always cear up the dom and release memory.  Sometimes setting
-            // innerHTML property to null is needed.  Particularly on IE, may 
-            // have to directly set it to null, bypassing jQuery.
-            this.target.empty();
-
-            this.target[0].innerHTML = '';
-        };
-        
-        // method: replot
-        // Does a reinitialization of the plot followed by
-        // a redraw.  Method could be used to interactively
-        // change plot characteristics and then replot.
-        //
-        // Parameters:
-        // options - Options used for replotting.
-        //
-        // Properties:
-        // clear - false to not clear (empty) the plot container before replotting (default: true).
-        // resetAxes - true to reset all axes min, max, numberTicks and tickInterval setting so axes will rescale themselves.
-        //             optionally pass in list of axes to reset (e.g. ['xaxis', 'y2axis']) (default: false).
-        this.replot = function(options) {
-            var opts =  options || {};
-            var clear = opts.clear || true;
-            var resetAxes = opts.resetAxes || false;
-            this.target.trigger('jqplotPreReplot');
-            
-            if (clear) {
-                this.destroy();
-            }
-            this.reInitialize();
-            if (resetAxes) {
-                this.resetAxesScale(resetAxes, opts.axes);
-            }
-            this.draw();
-            this.target.trigger('jqplotPostReplot');
-        };
-        
-        // method: redraw
-        // Empties the plot target div and redraws the plot.
-        // This enables plot data and properties to be changed
-        // and then to comletely clear the plot and redraw.
-        // redraw *will not* reinitialize any plot elements.
-        // That is, axes will not be autoscaled and defaults
-        // will not be reapplied to any plot elements.  redraw
-        // is used primarily with zooming. 
-        //
-        // Parameters:
-        // clear - false to not clear (empty) the plot container before redrawing (default: true).
-        this.redraw = function(clear) {
-            clear = (clear != null) ? clear : true;
-            this.target.trigger('jqplotPreRedraw');
-            if (clear) {
-                this.canvasManager.freeAllCanvases();
-                this.eventCanvas._elem.unbind();
-                // Dont think I bind any events to the target, this shouldn't be necessary.
-                // It will remove user's events.
-                // this.target.unbind();
-                this.target.empty();
-            }
-             for (var ax in this.axes) {
-                this.axes[ax]._ticks = [];
-            }
-            for (var i=0; i<this.series.length; i++) {
-                this.populatePlotData(this.series[i], i);
-            }
-            this._sumy = 0;
-            this._sumx = 0;
-            for (i=0; i<this.series.length; i++) {
-                this._sumy += this.series[i]._sumy;
-                this._sumx += this.series[i]._sumx;
-            }
-            this.draw();
-            this.target.trigger('jqplotPostRedraw');
-        };
-        
-        // method: draw
-        // Draws all elements of the plot into the container.
-        // Does not clear the container before drawing.
-        this.draw = function(){
-            if (this.drawIfHidden || this.target.is(':visible')) {
-                this.target.trigger('jqplotPreDraw');
-                var i, j;
-                for (i=0; i<$.jqplot.preDrawHooks.length; i++) {
-                    $.jqplot.preDrawHooks[i].call(this);
-                }
-                for (i=0; i<this.preDrawHooks.hooks.length; i++) {
-                    this.preDrawHooks.hooks[i].call(this);
-                }
-                // create an underlying canvas to be used for special features.
-                this.target.append(this.baseCanvas.createElement({left:0, right:0, top:0, bottom:0}, 'jqplot-base-canvas', null, this));
-                this.baseCanvas.setContext();
-                this.target.append(this.title.draw());
-                this.title.pack({top:0, left:0});
-                
-                // make room  for the legend between the grid and the edge.
-                var legendElem = this.legend.draw();
-                
-                var gridPadding = {top:0, left:0, bottom:0, right:0};
-                
-                if (this.legend.placement == "outsideGrid") {
-                    // temporarily append the legend to get dimensions
-                    this.target.append(legendElem);
-                    switch (this.legend.location) {
-                        case 'n':
-                            gridPadding.top += this.legend.getHeight();
-                            break;
-                        case 's':
-                            gridPadding.bottom += this.legend.getHeight();
-                            break;
-                        case 'ne':
-                        case 'e':
-                        case 'se':
-                            gridPadding.right += this.legend.getWidth();
-                            break;
-                        case 'nw':
-                        case 'w':
-                        case 'sw':
-                            gridPadding.left += this.legend.getWidth();
-                            break;
-                        default:  // same as 'ne'
-                            gridPadding.right += this.legend.getWidth();
-                            break;
-                    }
-                    legendElem = legendElem.detach();
-                }
-                
-                var ax = this.axes;
-                // draw the yMidAxis first, so xaxis of pyramid chart can adjust itself if needed.
-                for (i=0; i<12; i++) {
-                    name = _axisNames[i];
-                    this.target.append(ax[name].draw(this.baseCanvas._ctx, this));
-                    ax[name].set();
-                }
-                if (ax.yaxis.show) {
-                    gridPadding.left += ax.yaxis.getWidth();
-                }
-                var ra = ['y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis'];
-                var rapad = [0, 0, 0, 0, 0, 0, 0, 0];
-                var gpr = 0;
-                var n;
-                for (n=0; n<8; n++) {
-                    if (ax[ra[n]].show) {
-                        gpr += ax[ra[n]].getWidth();
-                        rapad[n] = gpr;
-                    }
-                }
-                gridPadding.right += gpr;
-                if (ax.x2axis.show) {
-                    gridPadding.top += ax.x2axis.getHeight();
-                }
-                if (this.title.show) {
-                    gridPadding.top += this.title.getHeight();
-                }
-                if (ax.xaxis.show) {
-                    gridPadding.bottom += ax.xaxis.getHeight();
-                }
-                
-                // end of gridPadding adjustments.
-
-                // if user passed in gridDimensions option, check against calculated gridPadding
-                if (this.options.gridDimensions && $.isPlainObject(this.options.gridDimensions)) {
-                    var gdw = parseInt(this.options.gridDimensions.width, 10) || 0;
-                    var gdh = parseInt(this.options.gridDimensions.height, 10) || 0;
-                    var widthAdj = (this._width - gridPadding.left - gridPadding.right - gdw)/2;
-                    var heightAdj = (this._height - gridPadding.top - gridPadding.bottom - gdh)/2;
-
-                    if (heightAdj >= 0 && widthAdj >= 0) {
-                        gridPadding.top += heightAdj;
-                        gridPadding.bottom += heightAdj;
-                        gridPadding.left += widthAdj;
-                        gridPadding.right += widthAdj;
-                    }
-                }
-                var arr = ['top', 'bottom', 'left', 'right'];
-                for (var n in arr) {
-                    if (this._gridPadding[arr[n]] == null && gridPadding[arr[n]] > 0) {
-                        this._gridPadding[arr[n]] = gridPadding[arr[n]];
-                    }
-                    else if (this._gridPadding[arr[n]] == null) {
-                        this._gridPadding[arr[n]] = this._defaultGridPadding[arr[n]];
-                    }
-                }
-                
-                var legendPadding = (this.legend.placement == 'outsideGrid') ? {top:this.title.getHeight(), left: 0, right: 0, bottom: 0} : this._gridPadding;
-            
-                ax.xaxis.pack({position:'absolute', bottom:this._gridPadding.bottom - ax.xaxis.getHeight(), left:0, width:this._width}, {min:this._gridPadding.left, max:this._width - this._gridPadding.right});
-                ax.yaxis.pack({position:'absolute', top:0, left:this._gridPadding.left - ax.yaxis.getWidth(), height:this._height}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top});
-                ax.x2axis.pack({position:'absolute', top:this._gridPadding.top - ax.x2axis.getHeight(), left:0, width:this._width}, {min:this._gridPadding.left, max:this._width - this._gridPadding.right});
-                for (i=8; i>0; i--) {
-                    ax[ra[i-1]].pack({position:'absolute', top:0, right:this._gridPadding.right - rapad[i-1]}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top});
-                }
-                var ltemp = (this._width - this._gridPadding.left - this._gridPadding.right)/2.0 + this._gridPadding.left - ax.yMidAxis.getWidth()/2.0;
-                ax.yMidAxis.pack({position:'absolute', top:0, left:ltemp, zIndex:9, textAlign: 'center'}, {min:this._height - this._gridPadding.bottom, max: this._gridPadding.top});
-            
-                this.target.append(this.grid.createElement(this._gridPadding, this));
-                this.grid.draw();
-                
-                // put the shadow canvases behind the series canvases so shadows don't overlap on stacked bars.
-                for (i=0; i<this.series.length; i++) {
-                    // draw series in order of stacking.  This affects only
-                    // order in which canvases are added to dom.
-                    j = this.seriesStack[i];
-                    this.target.append(this.series[j].shadowCanvas.createElement(this._gridPadding, 'jqplot-series-shadowCanvas', null, this));
-                    this.series[j].shadowCanvas.setContext();
-                    this.series[j].shadowCanvas._elem.data('seriesIndex', j);
-                }
-                
-                for (i=0; i<this.series.length; i++) {
-                    // draw series in order of stacking.  This affects only
-                    // order in which canvases are added to dom.
-                    j = this.seriesStack[i];
-                    this.target.append(this.series[j].canvas.createElement(this._gridPadding, 'jqplot-series-canvas', null, this));
-                    this.series[j].canvas.setContext();
-                    this.series[j].canvas._elem.data('seriesIndex', j);
-                }
-                // Need to use filled canvas to capture events in IE.
-                // Also, canvas seems to block selection of other elements in document on FF.
-                this.target.append(this.eventCanvas.createElement(this._gridPadding, 'jqplot-event-canvas', null, this));
-                this.eventCanvas.setContext();
-                this.eventCanvas._ctx.fillStyle = 'rgba(0,0,0,0)';
-                this.eventCanvas._ctx.fillRect(0,0,this.eventCanvas._ctx.canvas.width, this.eventCanvas._ctx.canvas.height);
-            
-                // bind custom event handlers to regular events.
-                this.bindCustomEvents();
-            
-                // draw legend before series if the series needs to know the legend dimensions.
-                if (this.legend.preDraw) {  
-                    this.eventCanvas._elem.before(legendElem);
-                    this.legend.pack(legendPadding);
-                    if (this.legend._elem) {
-                        this.drawSeries({legendInfo:{location:this.legend.location, placement:this.legend.placement, width:this.legend.getWidth(), height:this.legend.getHeight(), xoffset:this.legend.xoffset, yoffset:this.legend.yoffset}});
-                    }
-                    else {
-                        this.drawSeries();
-                    }
-                }
-                else {  // draw series before legend
-                    this.drawSeries();
-                    if (this.series.length) {
-                        $(this.series[this.series.length-1].canvas._elem).after(legendElem);
-                    }
-                    this.legend.pack(legendPadding);                
-                }
-            
-                // register event listeners on the overlay canvas
-                for (var i=0; i<$.jqplot.eventListenerHooks.length; i++) {
-                    // in the handler, this will refer to the eventCanvas dom element.
-                    // make sure there are references back into plot objects.
-                    this.eventCanvas._elem.bind($.jqplot.eventListenerHooks[i][0], {plot:this}, $.jqplot.eventListenerHooks[i][1]);
-                }
-            
-                // register event listeners on the overlay canvas
-                for (var i=0; i<this.eventListenerHooks.hooks.length; i++) {
-                    // in the handler, this will refer to the eventCanvas dom element.
-                    // make sure there are references back into plot objects.
-                    this.eventCanvas._elem.bind(this.eventListenerHooks.hooks[i][0], {plot:this}, this.eventListenerHooks.hooks[i][1]);
-                }
-
-                for (var i=0; i<$.jqplot.postDrawHooks.length; i++) {
-                    $.jqplot.postDrawHooks[i].call(this);
-                }
-
-                for (var i=0; i<this.postDrawHooks.hooks.length; i++) {
-                    this.postDrawHooks.hooks[i].call(this);
-                }
-            
-                if (this.target.is(':visible')) {
-                    this._drawCount += 1;
-                }
-            
-                this.target.trigger('jqplotPostDraw', [this]);
-            }
-        };
-        
-        this.bindCustomEvents = function() {
-            this.eventCanvas._elem.bind('click', {plot:this}, this.onClick);
-            this.eventCanvas._elem.bind('dblclick', {plot:this}, this.onDblClick);
-            this.eventCanvas._elem.bind('mousedown', {plot:this}, this.onMouseDown);
-            this.eventCanvas._elem.bind('mousemove', {plot:this}, this.onMouseMove);
-            this.eventCanvas._elem.bind('mouseenter', {plot:this}, this.onMouseEnter);
-            this.eventCanvas._elem.bind('mouseleave', {plot:this}, this.onMouseLeave);
-            if (this.captureRightClick) {
-                this.eventCanvas._elem.bind('mouseup', {plot:this}, this.onRightClick);
-                this.eventCanvas._elem.get(0).oncontextmenu = function() {
-                    return false;
-                };
-            }
-            else {
-                this.eventCanvas._elem.bind('mouseup', {plot:this}, this.onMouseUp);
-            }
-        };
-        
-        function getEventPosition(ev) {
-            var plot = ev.data.plot;
-            var go = plot.eventCanvas._elem.offset();
-            var gridPos = {x:ev.pageX - go.left, y:ev.pageY - go.top};
-            var dataPos = {xaxis:null, yaxis:null, x2axis:null, y2axis:null, y3axis:null, y4axis:null, y5axis:null, y6axis:null, y7axis:null, y8axis:null, y9axis:null, yMidAxis:null};
-            var an = ['xaxis', 'yaxis', 'x2axis', 'y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis', 'yMidAxis'];
-            var ax = plot.axes;
-            var n, axis;
-            for (n=11; n>0; n--) {
-                axis = an[n-1];
-                if (ax[axis].show) {
-                    dataPos[axis] = ax[axis].series_p2u(gridPos[axis.charAt(0)]);
-                }
-            }
-
-            return {offsets:go, gridPos:gridPos, dataPos:dataPos};
-        }
-        
-        
-        // function to check if event location is over a area area
-        function checkIntersection(gridpos, plot) {
-            var series = plot.series;
-            var i, j, k, s, r, x, y, theta, sm, sa, minang, maxang;
-            var d0, d, p, pp, points, bw;
-            var threshold, t;
-            for (k=plot.seriesStack.length-1; k>=0; k--) {
-                i = plot.seriesStack[k];
-                s = series[i];
-                switch (s.renderer.constructor) {
-                    case $.jqplot.BarRenderer:
-                    case $.jqplot.PyramidRenderer:
-                        x = gridpos.x;
-                        y = gridpos.y;
-                        for (j=0; j<s._barPoints.length; j++) {
-                            points = s._barPoints[j];
-                            p = s.gridData[j];
-                            if (x>points[0][0] && x<points[2][0] && y>points[2][1] && y<points[0][1]) {
-                                return {seriesIndex:s.index, pointIndex:j, gridData:p, data:s.data[j], points:s._barPoints[j]};
-                            }
-                        }
-                        break;
-                    
-                    case $.jqplot.DonutRenderer:
-                        sa = s.startAngle/180*Math.PI;
-                        x = gridpos.x - s._center[0];
-                        y = gridpos.y - s._center[1];
-                        r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
-                        if (x > 0 && -y >= 0) {
-                            theta = 2*Math.PI - Math.atan(-y/x);
-                        }
-                        else if (x > 0 && -y < 0) {
-                            theta = -Math.atan(-y/x);
-                        }
-                        else if (x < 0) {
-                            theta = Math.PI - Math.atan(-y/x);
-                        }
-                        else if (x == 0 && -y > 0) {
-                            theta = 3*Math.PI/2;
-                        }
-                        else if (x == 0 && -y < 0) {
-                            theta = Math.PI/2;
-                        }
-                        else if (x == 0 && y == 0) {
-                            theta = 0;
-                        }
-                        if (sa) {
-                            theta -= sa;
-                            if (theta < 0) {
-                                theta += 2*Math.PI;
-                            }
-                            else if (theta > 2*Math.PI) {
-                                theta -= 2*Math.PI;
-                            }
-                        }
-            
-                        sm = s.sliceMargin/180*Math.PI;
-                        if (r < s._radius && r > s._innerRadius) {
-                            for (j=0; j<s.gridData.length; j++) {
-                                minang = (j>0) ? s.gridData[j-1][1]+sm : sm;
-                                maxang = s.gridData[j][1];
-                                if (theta > minang && theta < maxang) {
-                                    return {seriesIndex:s.index, pointIndex:j, gridData:s.gridData[j], data:s.data[j]};
-                                }
-                            }
-                        }
-                        break;
-                        
-                    case $.jqplot.PieRenderer:
-                        sa = s.startAngle/180*Math.PI;
-                        x = gridpos.x - s._center[0];
-                        y = gridpos.y - s._center[1];
-                        r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
-                        if (x > 0 && -y >= 0) {
-                            theta = 2*Math.PI - Math.atan(-y/x);
-                        }
-                        else if (x > 0 && -y < 0) {
-                            theta = -Math.atan(-y/x);
-                        }
-                        else if (x < 0) {
-                            theta = Math.PI - Math.atan(-y/x);
-                        }
-                        else if (x == 0 && -y > 0) {
-                            theta = 3*Math.PI/2;
-                        }
-                        else if (x == 0 && -y < 0) {
-                            theta = Math.PI/2;
-                        }
-                        else if (x == 0 && y == 0) {
-                            theta = 0;
-                        }
-                        if (sa) {
-                            theta -= sa;
-                            if (theta < 0) {
-                                theta += 2*Math.PI;
-                            }
-                            else if (theta > 2*Math.PI) {
-                                theta -= 2*Math.PI;
-                            }
-                        }
-            
-                        sm = s.sliceMargin/180*Math.PI;
-                        if (r < s._radius) {
-                            for (j=0; j<s.gridData.length; j++) {
-                                minang = (j>0) ? s.gridData[j-1][1]+sm : sm;
-                                maxang = s.gridData[j][1];
-                                if (theta > minang && theta < maxang) {
-                                    return {seriesIndex:s.index, pointIndex:j, gridData:s.gridData[j], data:s.data[j]};
-                                }
-                            }
-                        }
-                        break;
-                        
-                    case $.jqplot.BubbleRenderer:
-                        x = gridpos.x;
-                        y = gridpos.y;
-                        var ret = null;
-                        
-                        if (s.show) {
-                            for (var j=0; j<s.gridData.length; j++) {
-                                p = s.gridData[j];
-                                d = Math.sqrt( (x-p[0]) * (x-p[0]) + (y-p[1]) * (y-p[1]) );
-                                if (d <= p[2] && (d <= d0 || d0 == null)) {
-                                   d0 = d;
-                                   ret = {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-                                }
-                            }
-                            if (ret != null) {
-                                return ret;
-                            }
-                        }
-                        break;
-                        
-                    case $.jqplot.FunnelRenderer:
-                        x = gridpos.x;
-                        y = gridpos.y;
-                        var v = s._vertices,
-                            vfirst = v[0],
-                            vlast = v[v.length-1],
-                            lex,
-                            rex,
-                            cv;
-    
-                        // equations of right and left sides, returns x, y values given height of section (y value and 2 points)
-    
-                        function findedge (l, p1 , p2) {
-                            var m = (p1[1] - p2[1])/(p1[0] - p2[0]);
-                            var b = p1[1] - m*p1[0];
-                            var y = l + p1[1];
-        
-                            return [(y - b)/m, y];
-                        }
-    
-                        // check each section
-                        lex = findedge(y, vfirst[0], vlast[3]);
-                        rex = findedge(y, vfirst[1], vlast[2]);
-                        for (j=0; j<v.length; j++) {
-                            cv = v[j];
-                            if (y >= cv[0][1] && y <= cv[3][1] && x >= lex[0] && x <= rex[0]) {
-                                return {seriesIndex:s.index, pointIndex:j, gridData:null, data:s.data[j]};
-                            }
-                        }         
-                        break;           
-                    
-                    case $.jqplot.LineRenderer:
-                        x = gridpos.x;
-                        y = gridpos.y;
-                        r = s.renderer;
-                        if (s.show) {
-                            if ((s.fill || (s.renderer.bands.show && s.renderer.bands.fill)) && (!plot.plugins.highlighter || !plot.plugins.highlighter.show)) {
-                                // first check if it is in bounding box
-                                var inside = false;
-                                if (x>s._boundingBox[0][0] && x<s._boundingBox[1][0] && y>s._boundingBox[1][1] && y<s._boundingBox[0][1]) { 
-                                    // now check the crossing number   
-                                    
-                                    var numPoints = s._areaPoints.length;
-                                    var ii;
-                                    var j = numPoints-1;
-
-                                    for(var ii=0; ii < numPoints; ii++) { 
-                                        var vertex1 = [s._areaPoints[ii][0], s._areaPoints[ii][1]];
-                                        var vertex2 = [s._areaPoints[j][0], s._areaPoints[j][1]];
-
-                                        if (vertex1[1] < y && vertex2[1] >= y || vertex2[1] < y && vertex1[1] >= y)     {
-                                            if (vertex1[0] + (y - vertex1[1]) / (vertex2[1] - vertex1[1]) * (vertex2[0] - vertex1[0]) < x) {
-                                                inside = !inside;
-                                            }
-                                        }
-
-                                        j = ii;
-                                    }        
-                                }
-                                if (inside) {
-                                    return {seriesIndex:i, pointIndex:null, gridData:s.gridData, data:s.data, points:s._areaPoints};
-                                }
-                                break;
-                                
-                            }
-
-                            else {
-                                t = s.markerRenderer.size/2+s.neighborThreshold;
-                                threshold = (t > 0) ? t : 0;
-                                for (var j=0; j<s.gridData.length; j++) {
-                                    p = s.gridData[j];
-                                    // neighbor looks different to OHLC chart.
-                                    if (r.constructor == $.jqplot.OHLCRenderer) {
-                                        if (r.candleStick) {
-                                            var yp = s._yaxis.series_u2p;
-                                            if (x >= p[0]-r._bodyWidth/2 && x <= p[0]+r._bodyWidth/2 && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3])) {
-                                                return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-                                            }
-                                        }
-                                        // if an open hi low close chart
-                                        else if (!r.hlc){
-                                            var yp = s._yaxis.series_u2p;
-                                            if (x >= p[0]-r._tickLength && x <= p[0]+r._tickLength && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3])) {
-                                                return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-                                            }
-                                        }
-                                        // a hi low close chart
-                                        else {
-                                            var yp = s._yaxis.series_u2p;
-                                            if (x >= p[0]-r._tickLength && x <= p[0]+r._tickLength && y >= yp(s.data[j][1]) && y <= yp(s.data[j][2])) {
-                                                return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-                                            }
-                                        }
-                            
-                                    }
-                                    else if (p[0] != null && p[1] != null){
-                                        d = Math.sqrt( (x-p[0]) * (x-p[0]) + (y-p[1]) * (y-p[1]) );
-                                        if (d <= threshold && (d <= d0 || d0 == null)) {
-                                           d0 = d;
-                                           return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-                                        }
-                                    }
-                                } 
-                            }
-                        }
-                        break;
-                        
-                    default:
-                        x = gridpos.x;
-                        y = gridpos.y;
-                        r = s.renderer;
-                        if (s.show) {
-                            t = s.markerRenderer.size/2+s.neighborThreshold;
-                            threshold = (t > 0) ? t : 0;
-                            for (var j=0; j<s.gridData.length; j++) {
-                                p = s.gridData[j];
-                                // neighbor looks different to OHLC chart.
-                                if (r.constructor == $.jqplot.OHLCRenderer) {
-                                    if (r.candleStick) {
-                                        var yp = s._yaxis.series_u2p;
-                                        if (x >= p[0]-r._bodyWidth/2 && x <= p[0]+r._bodyWidth/2 && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3])) {
-                                            return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-                                        }
-                                    }
-                                    // if an open hi low close chart
-                                    else if (!r.hlc){
-                                        var yp = s._yaxis.series_u2p;
-                                        if (x >= p[0]-r._tickLength && x <= p[0]+r._tickLength && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3])) {
-                                            return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-                                        }
-                                    }
-                                    // a hi low close chart
-                                    else {
-                                        var yp = s._yaxis.series_u2p;
-                                        if (x >= p[0]-r._tickLength && x <= p[0]+r._tickLength && y >= yp(s.data[j][1]) && y <= yp(s.data[j][2])) {
-                                            return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-                                        }
-                                    }
-                            
-                                }
-                                else {
-                                    d = Math.sqrt( (x-p[0]) * (x-p[0]) + (y-p[1]) * (y-p[1]) );
-                                    if (d <= threshold && (d <= d0 || d0 == null)) {
-                                       d0 = d;
-                                       return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-                                    }
-                                }
-                            } 
-                        }
-                        break;
-                }
-            }
-            
-            return null;
-        }
-        
-        
-        
-        this.onClick = function(ev) {
-            // Event passed in is normalized and will have data attribute.
-            // Event passed out is unnormalized.
-            var positions = getEventPosition(ev);
-            var p = ev.data.plot;
-            var neighbor = checkIntersection(positions.gridPos, p);
-            var evt = jQuery.Event('jqplotClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]);
-        };
-        
-        this.onDblClick = function(ev) {
-            // Event passed in is normalized and will have data attribute.
-            // Event passed out is unnormalized.
-            var positions = getEventPosition(ev);
-            var p = ev.data.plot;
-            var neighbor = checkIntersection(positions.gridPos, p);
-            var evt = jQuery.Event('jqplotDblClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]);
-        };
-        
-        this.onMouseDown = function(ev) {
-            var positions = getEventPosition(ev);
-            var p = ev.data.plot;
-            var neighbor = checkIntersection(positions.gridPos, p);
-            var evt = jQuery.Event('jqplotMouseDown');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]);
-        };
-        
-        this.onMouseUp = function(ev) {
-            var positions = getEventPosition(ev);
-            var evt = jQuery.Event('jqplotMouseUp');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            $(this).trigger(evt, [positions.gridPos, positions.dataPos, null, ev.data.plot]);
-        };
-        
-        this.onRightClick = function(ev) {
-            var positions = getEventPosition(ev);
-            var p = ev.data.plot;
-            var neighbor = checkIntersection(positions.gridPos, p);
-            if (p.captureRightClick) {
-                if (ev.which == 3) {
-                var evt = jQuery.Event('jqplotRightClick');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                    $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]);
-                }
-                else {
-                var evt = jQuery.Event('jqplotMouseUp');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                    $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]);
-                }
-            }
-        };
-        
-        this.onMouseMove = function(ev) {
-            var positions = getEventPosition(ev);
-            var p = ev.data.plot;
-            var neighbor = checkIntersection(positions.gridPos, p);
-            var evt = jQuery.Event('jqplotMouseMove');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            $(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]);
-        };
-        
-        this.onMouseEnter = function(ev) {
-            var positions = getEventPosition(ev);
-            var p = ev.data.plot;
-            var evt = jQuery.Event('jqplotMouseEnter');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            evt.relatedTarget = ev.relatedTarget;
-            $(this).trigger(evt, [positions.gridPos, positions.dataPos, null, p]);
-        };
-        
-        this.onMouseLeave = function(ev) {
-            var positions = getEventPosition(ev);
-            var p = ev.data.plot;
-            var evt = jQuery.Event('jqplotMouseLeave');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            evt.relatedTarget = ev.relatedTarget;
-            $(this).trigger(evt, [positions.gridPos, positions.dataPos, null, p]);
-        };
-        
-        // method: drawSeries
-        // Redraws all or just one series on the plot.  No axis scaling
-        // is performed and no other elements on the plot are redrawn.
-        // options is an options object to pass on to the series renderers.
-        // It can be an empty object {}.  idx is the series index
-        // to redraw if only one series is to be redrawn.
-        this.drawSeries = function(options, idx){
-            var i, series, ctx;
-            // if only one argument passed in and it is a number, use it ad idx.
-            idx = (typeof(options) === "number" && idx == null) ? options : idx;
-            options = (typeof(options) === "object") ? options : {};
-            // draw specified series
-            if (idx != undefined) {
-                series = this.series[idx];
-                ctx = series.shadowCanvas._ctx;
-                ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-                series.drawShadow(ctx, options, this);
-                ctx = series.canvas._ctx;
-                ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-                series.draw(ctx, options, this);
-                if (series.renderer.constructor == $.jqplot.BezierCurveRenderer) {
-                    if (idx < this.series.length - 1) {
-                        this.drawSeries(idx+1); 
-                    }
-                }
-            }
-            
-            else {
-                // if call series drawShadow method first, in case all series shadows
-                // should be drawn before any series.  This will ensure, like for 
-                // stacked bar plots, that shadows don't overlap series.
-                for (i=0; i<this.series.length; i++) {
-                    // first clear the canvas
-                    series = this.series[i];
-                    ctx = series.shadowCanvas._ctx;
-                    ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-                    series.drawShadow(ctx, options, this);
-                    ctx = series.canvas._ctx;
-                    ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-                    series.draw(ctx, options, this);
-                }
-            }
-            options = idx = i = series = ctx = null;
-        };
-        
-        // method: moveSeriesToFront
-        // This method requires jQuery 1.4+
-        // Moves the specified series canvas in front of all other series canvases.
-        // This effectively "draws" the specified series on top of all other series,
-        // although it is performed through DOM manipulation, no redrawing is performed.
-        //
-        // Parameters:
-        // idx - 0 based index of the series to move.  This will be the index of the series
-        // as it was first passed into the jqplot function.
-        this.moveSeriesToFront = function (idx) { 
-            idx = parseInt(idx, 10);
-            var stackIndex = $.inArray(idx, this.seriesStack);
-            // if already in front, return
-            if (stackIndex == -1) {
-                return;
-            }
-            if (stackIndex == this.seriesStack.length -1) {
-                this.previousSeriesStack = this.seriesStack.slice(0);
-                return;
-            }
-            var opidx = this.seriesStack[this.seriesStack.length -1];
-            var serelem = this.series[idx].canvas._elem.detach();
-            var shadelem = this.series[idx].shadowCanvas._elem.detach();
-            this.series[opidx].shadowCanvas._elem.after(shadelem);
-            this.series[opidx].canvas._elem.after(serelem);
-            this.previousSeriesStack = this.seriesStack.slice(0);
-            this.seriesStack.splice(stackIndex, 1);
-            this.seriesStack.push(idx);
-        };
-        
-        // method: moveSeriesToBack
-        // This method requires jQuery 1.4+
-        // Moves the specified series canvas behind all other series canvases.
-        //
-        // Parameters:
-        // idx - 0 based index of the series to move.  This will be the index of the series
-        // as it was first passed into the jqplot function.
-        this.moveSeriesToBack = function (idx) {
-            idx = parseInt(idx, 10);
-            var stackIndex = $.inArray(idx, this.seriesStack);
-            // if already in back, return
-            if (stackIndex == 0 || stackIndex == -1) {
-                return;
-            }
-            var opidx = this.seriesStack[0];
-            var serelem = this.series[idx].canvas._elem.detach();
-            var shadelem = this.series[idx].shadowCanvas._elem.detach();
-            this.series[opidx].shadowCanvas._elem.before(shadelem);
-            this.series[opidx].canvas._elem.before(serelem);
-            this.previousSeriesStack = this.seriesStack.slice(0);
-            this.seriesStack.splice(stackIndex, 1);
-            this.seriesStack.unshift(idx);
-        };
-        
-        // method: restorePreviousSeriesOrder
-        // This method requires jQuery 1.4+
-        // Restore the series canvas order to its previous state.
-        // Useful to put a series back where it belongs after moving
-        // it to the front.
-        this.restorePreviousSeriesOrder = function () {
-            var i, j, serelem, shadelem, temp, move, keep;
-            // if no change, return.
-            if (this.seriesStack == this.previousSeriesStack) {
-                return;
-            }
-            for (i=1; i<this.previousSeriesStack.length; i++) {
-                move = this.previousSeriesStack[i];
-                keep = this.previousSeriesStack[i-1];
-                serelem = this.series[move].canvas._elem.detach();
-                shadelem = this.series[move].shadowCanvas._elem.detach();
-                this.series[keep].shadowCanvas._elem.after(shadelem);
-                this.series[keep].canvas._elem.after(serelem);
-            }
-            temp = this.seriesStack.slice(0);
-            this.seriesStack = this.previousSeriesStack.slice(0);
-            this.previousSeriesStack = temp;
-        };
-        
-        // method: restoreOriginalSeriesOrder
-        // This method requires jQuery 1.4+
-        // Restore the series canvas order to its original order
-        // when the plot was created.
-        this.restoreOriginalSeriesOrder = function () {
-            var i, j, arr=[], serelem, shadelem;
-            for (i=0; i<this.series.length; i++) {
-                arr.push(i);
-            }
-            if (this.seriesStack == arr) {
-                return;
-            }
-            this.previousSeriesStack = this.seriesStack.slice(0);
-            this.seriesStack = arr;
-            for (i=1; i<this.seriesStack.length; i++) {
-                serelem = this.series[i].canvas._elem.detach();
-                shadelem = this.series[i].shadowCanvas._elem.detach();
-                this.series[i-1].shadowCanvas._elem.after(shadelem);
-                this.series[i-1].canvas._elem.after(serelem);
-            }
-        };
-        
-        this.activateTheme = function (name) {
-            this.themeEngine.activate(this, name);
-        };
-    }
-    
-    
-    // conpute a highlight color or array of highlight colors from given colors.
-    $.jqplot.computeHighlightColors  = function(colors) {
-        var ret;
-        if (jQuery.isArray(colors)) {
-            ret = [];
-            for (var i=0; i<colors.length; i++){
-                var rgba = $.jqplot.getColorComponents(colors[i]);
-                var newrgb = [rgba[0], rgba[1], rgba[2]];
-                var sum = newrgb[0] + newrgb[1] + newrgb[2];
-                for (var j=0; j<3; j++) {
-                    // when darkening, lowest color component can be is 60.
-                    newrgb[j] = (sum > 660) ?  newrgb[j] * 0.85 : 0.73 * newrgb[j] + 90;
-                    newrgb[j] = parseInt(newrgb[j], 10);
-                    (newrgb[j] > 255) ? 255 : newrgb[j];
-                }
-                // newrgb[3] = (rgba[3] > 0.4) ? rgba[3] * 0.4 : rgba[3] * 1.5;
-                // newrgb[3] = (rgba[3] > 0.5) ? 0.8 * rgba[3] - .1 : rgba[3] + 0.2;
-                newrgb[3] = 0.3 + 0.35 * rgba[3];
-                ret.push('rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+newrgb[3]+')');
-            }
-        }
-        else {
-            var rgba = $.jqplot.getColorComponents(colors);
-            var newrgb = [rgba[0], rgba[1], rgba[2]];
-            var sum = newrgb[0] + newrgb[1] + newrgb[2];
-            for (var j=0; j<3; j++) {
-                // when darkening, lowest color component can be is 60.
-                // newrgb[j] = (sum > 570) ?  newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]);
-                // newrgb[j] = parseInt(newrgb[j], 10);
-                newrgb[j] = (sum > 660) ?  newrgb[j] * 0.85 : 0.73 * newrgb[j] + 90;
-                newrgb[j] = parseInt(newrgb[j], 10);
-                (newrgb[j] > 255) ? 255 : newrgb[j];
-            }
-            // newrgb[3] = (rgba[3] > 0.4) ? rgba[3] * 0.4 : rgba[3] * 1.5;
-            // newrgb[3] = (rgba[3] > 0.5) ? 0.8 * rgba[3] - .1 : rgba[3] + 0.2;
-            newrgb[3] = 0.3 + 0.35 * rgba[3];
-            ret = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+newrgb[3]+')';
-        }
-        return ret;
-    };
-        
-   $.jqplot.ColorGenerator = function(colors) {
-        colors = colors || $.jqplot.config.defaultColors;
-        var idx = 0;
-        
-        this.next = function () { 
-            if (idx < colors.length) {
-                return colors[idx++];
-            }
-            else {
-                idx = 0;
-                return colors[idx++];
-            }
-        };
-        
-        this.previous = function () { 
-            if (idx > 0) {
-                return colors[idx--];
-            }
-            else {
-                idx = colors.length-1;
-                return colors[idx];
-            }
-        };
-        
-        // get a color by index without advancing pointer.
-        this.get = function(i) {
-            var idx = i - colors.length * Math.floor(i/colors.length);
-            return colors[idx];
-        };
-        
-        this.setColors = function(c) {
-            colors = c;
-        };
-        
-        this.reset = function() {
-            idx = 0;
-        };
-
-        this.getIndex = function() {
-            return idx;
-        };
-
-        this.setIndex = function(index) {
-            idx = index;
-        };
-    };
-
-    // convert a hex color string to rgb string.
-    // h - 3 or 6 character hex string, with or without leading #
-    // a - optional alpha
-    $.jqplot.hex2rgb = function(h, a) {
-        h = h.replace('#', '');
-        if (h.length == 3) {
-            h = h.charAt(0)+h.charAt(0)+h.charAt(1)+h.charAt(1)+h.charAt(2)+h.charAt(2);
-        }
-        var rgb;
-        rgb = 'rgba('+parseInt(h.slice(0,2), 16)+', '+parseInt(h.slice(2,4), 16)+', '+parseInt(h.slice(4,6), 16);
-        if (a) {
-            rgb += ', '+a;
-        }
-        rgb += ')';
-        return rgb;
-    };
-    
-    // convert an rgb color spec to a hex spec.  ignore any alpha specification.
-    $.jqplot.rgb2hex = function(s) {
-        var pat = /rgba?\( *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *(?:, *[0-9.]*)?\)/;
-        var m = s.match(pat);
-        var h = '#';
-        for (var i=1; i<4; i++) {
-            var temp;
-            if (m[i].search(/%/) != -1) {
-                temp = parseInt(255*m[i]/100, 10).toString(16);
-                if (temp.length == 1) {
-                    temp = '0'+temp;
-                }
-            }
-            else {
-                temp = parseInt(m[i], 10).toString(16);
-                if (temp.length == 1) {
-                    temp = '0'+temp;
-                }
-            }
-            h += temp;
-        }
-        return h;
-    };
-    
-    // given a css color spec, return an rgb css color spec
-    $.jqplot.normalize2rgb = function(s, a) {
-        if (s.search(/^ *rgba?\(/) != -1) {
-            return s; 
-        }
-        else if (s.search(/^ *#?[0-9a-fA-F]?[0-9a-fA-F]/) != -1) {
-            return $.jqplot.hex2rgb(s, a);
-        }
-        else {
-            throw 'invalid color spec';
-        }
-    };
-    
-    // extract the r, g, b, a color components out of a css color spec.
-    $.jqplot.getColorComponents = function(s) {
-        // check to see if a color keyword.
-        s = $.jqplot.colorKeywordMap[s] || s;
-        var rgb = $.jqplot.normalize2rgb(s);
-        var pat = /rgba?\( *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *,? *([0-9.]* *)?\)/;
-        var m = rgb.match(pat);
-        var ret = [];
-        for (var i=1; i<4; i++) {
-            if (m[i].search(/%/) != -1) {
-                ret[i-1] = parseInt(255*m[i]/100, 10);
-            }
-            else {
-                ret[i-1] = parseInt(m[i], 10);
-            }
-        }
-        ret[3] = parseFloat(m[4]) ? parseFloat(m[4]) : 1.0;
-        return ret;
-    };
-    
-    $.jqplot.colorKeywordMap = {
-        aliceblue: 'rgb(240, 248, 255)',
-        antiquewhite: 'rgb(250, 235, 215)',
-        aqua: 'rgb( 0, 255, 255)',
-        aquamarine: 'rgb(127, 255, 212)',
-        azure: 'rgb(240, 255, 255)',
-        beige: 'rgb(245, 245, 220)',
-        bisque: 'rgb(255, 228, 196)',
-        black: 'rgb( 0, 0, 0)',
-        blanchedalmond: 'rgb(255, 235, 205)',
-        blue: 'rgb( 0, 0, 255)',
-        blueviolet: 'rgb(138, 43, 226)',
-        brown: 'rgb(165, 42, 42)',
-        burlywood: 'rgb(222, 184, 135)',
-        cadetblue: 'rgb( 95, 158, 160)',
-        chartreuse: 'rgb(127, 255, 0)',
-        chocolate: 'rgb(210, 105, 30)',
-        coral: 'rgb(255, 127, 80)',
-        cornflowerblue: 'rgb(100, 149, 237)',
-        cornsilk: 'rgb(255, 248, 220)',
-        crimson: 'rgb(220, 20, 60)',
-        cyan: 'rgb( 0, 255, 255)',
-        darkblue: 'rgb( 0, 0, 139)',
-        darkcyan: 'rgb( 0, 139, 139)',
-        darkgoldenrod: 'rgb(184, 134, 11)',
-        darkgray: 'rgb(169, 169, 169)',
-        darkgreen: 'rgb( 0, 100, 0)',
-        darkgrey: 'rgb(169, 169, 169)',
-        darkkhaki: 'rgb(189, 183, 107)',
-        darkmagenta: 'rgb(139, 0, 139)',
-        darkolivegreen: 'rgb( 85, 107, 47)',
-        darkorange: 'rgb(255, 140, 0)',
-        darkorchid: 'rgb(153, 50, 204)',
-        darkred: 'rgb(139, 0, 0)',
-        darksalmon: 'rgb(233, 150, 122)',
-        darkseagreen: 'rgb(143, 188, 143)',
-        darkslateblue: 'rgb( 72, 61, 139)',
-        darkslategray: 'rgb( 47, 79, 79)',
-        darkslategrey: 'rgb( 47, 79, 79)',
-        darkturquoise: 'rgb( 0, 206, 209)',
-        darkviolet: 'rgb(148, 0, 211)',
-        deeppink: 'rgb(255, 20, 147)',
-        deepskyblue: 'rgb( 0, 191, 255)',
-        dimgray: 'rgb(105, 105, 105)',
-        dimgrey: 'rgb(105, 105, 105)',
-        dodgerblue: 'rgb( 30, 144, 255)',
-        firebrick: 'rgb(178, 34, 34)',
-        floralwhite: 'rgb(255, 250, 240)',
-        forestgreen: 'rgb( 34, 139, 34)',
-        fuchsia: 'rgb(255, 0, 255)',
-        gainsboro: 'rgb(220, 220, 220)',
-        ghostwhite: 'rgb(248, 248, 255)',
-        gold: 'rgb(255, 215, 0)',
-        goldenrod: 'rgb(218, 165, 32)',
-        gray: 'rgb(128, 128, 128)',
-        grey: 'rgb(128, 128, 128)',
-        green: 'rgb( 0, 128, 0)',
-        greenyellow: 'rgb(173, 255, 47)',
-        honeydew: 'rgb(240, 255, 240)',
-        hotpink: 'rgb(255, 105, 180)',
-        indianred: 'rgb(205, 92, 92)',
-        indigo: 'rgb( 75, 0, 130)',
-        ivory: 'rgb(255, 255, 240)',
-        khaki: 'rgb(240, 230, 140)',
-        lavender: 'rgb(230, 230, 250)',
-        lavenderblush: 'rgb(255, 240, 245)',
-        lawngreen: 'rgb(124, 252, 0)',
-        lemonchiffon: 'rgb(255, 250, 205)',
-        lightblue: 'rgb(173, 216, 230)',
-        lightcoral: 'rgb(240, 128, 128)',
-        lightcyan: 'rgb(224, 255, 255)',
-        lightgoldenrodyellow: 'rgb(250, 250, 210)',
-        lightgray: 'rgb(211, 211, 211)',
-        lightgreen: 'rgb(144, 238, 144)',
-        lightgrey: 'rgb(211, 211, 211)',
-        lightpink: 'rgb(255, 182, 193)',
-        lightsalmon: 'rgb(255, 160, 122)',
-        lightseagreen: 'rgb( 32, 178, 170)',
-        lightskyblue: 'rgb(135, 206, 250)',
-        lightslategray: 'rgb(119, 136, 153)',
-        lightslategrey: 'rgb(119, 136, 153)',
-        lightsteelblue: 'rgb(176, 196, 222)',
-        lightyellow: 'rgb(255, 255, 224)',
-        lime: 'rgb( 0, 255, 0)',
-        limegreen: 'rgb( 50, 205, 50)',
-        linen: 'rgb(250, 240, 230)',
-        magenta: 'rgb(255, 0, 255)',
-        maroon: 'rgb(128, 0, 0)',
-        mediumaquamarine: 'rgb(102, 205, 170)',
-        mediumblue: 'rgb( 0, 0, 205)',
-        mediumorchid: 'rgb(186, 85, 211)',
-        mediumpurple: 'rgb(147, 112, 219)',
-        mediumseagreen: 'rgb( 60, 179, 113)',
-        mediumslateblue: 'rgb(123, 104, 238)',
-        mediumspringgreen: 'rgb( 0, 250, 154)',
-        mediumturquoise: 'rgb( 72, 209, 204)',
-        mediumvioletred: 'rgb(199, 21, 133)',
-        midnightblue: 'rgb( 25, 25, 112)',
-        mintcream: 'rgb(245, 255, 250)',
-        mistyrose: 'rgb(255, 228, 225)',
-        moccasin: 'rgb(255, 228, 181)',
-        navajowhite: 'rgb(255, 222, 173)',
-        navy: 'rgb( 0, 0, 128)',
-        oldlace: 'rgb(253, 245, 230)',
-        olive: 'rgb(128, 128, 0)',
-        olivedrab: 'rgb(107, 142, 35)',
-        orange: 'rgb(255, 165, 0)',
-        orangered: 'rgb(255, 69, 0)',
-        orchid: 'rgb(218, 112, 214)',
-        palegoldenrod: 'rgb(238, 232, 170)',
-        palegreen: 'rgb(152, 251, 152)',
-        paleturquoise: 'rgb(175, 238, 238)',
-        palevioletred: 'rgb(219, 112, 147)',
-        papayawhip: 'rgb(255, 239, 213)',
-        peachpuff: 'rgb(255, 218, 185)',
-        peru: 'rgb(205, 133, 63)',
-        pink: 'rgb(255, 192, 203)',
-        plum: 'rgb(221, 160, 221)',
-        powderblue: 'rgb(176, 224, 230)',
-        purple: 'rgb(128, 0, 128)',
-        red: 'rgb(255, 0, 0)',
-        rosybrown: 'rgb(188, 143, 143)',
-        royalblue: 'rgb( 65, 105, 225)',
-        saddlebrown: 'rgb(139, 69, 19)',
-        salmon: 'rgb(250, 128, 114)',
-        sandybrown: 'rgb(244, 164, 96)',
-        seagreen: 'rgb( 46, 139, 87)',
-        seashell: 'rgb(255, 245, 238)',
-        sienna: 'rgb(160, 82, 45)',
-        silver: 'rgb(192, 192, 192)',
-        skyblue: 'rgb(135, 206, 235)',
-        slateblue: 'rgb(106, 90, 205)',
-        slategray: 'rgb(112, 128, 144)',
-        slategrey: 'rgb(112, 128, 144)',
-        snow: 'rgb(255, 250, 250)',
-        springgreen: 'rgb( 0, 255, 127)',
-        steelblue: 'rgb( 70, 130, 180)',
-        tan: 'rgb(210, 180, 140)',
-        teal: 'rgb( 0, 128, 128)',
-        thistle: 'rgb(216, 191, 216)',
-        tomato: 'rgb(255, 99, 71)',
-        turquoise: 'rgb( 64, 224, 208)',
-        violet: 'rgb(238, 130, 238)',
-        wheat: 'rgb(245, 222, 179)',
-        white: 'rgb(255, 255, 255)',
-        whitesmoke: 'rgb(245, 245, 245)',
-        yellow: 'rgb(255, 255, 0)',
-        yellowgreen: 'rgb(154, 205, 50)'
-    };
-
-    
-
-    // class: $.jqplot.AxisLabelRenderer
-    // Renderer to place labels on the axes.
-    $.jqplot.AxisLabelRenderer = function(options) {
-        // Group: Properties
-        $.jqplot.ElemContainer.call(this);
-        // name of the axis associated with this tick
-        this.axis;
-        // prop: show
-        // wether or not to show the tick (mark and label).
-        this.show = true;
-        // prop: label
-        // The text or html for the label.
-        this.label = '';
-        this.fontFamily = null;
-        this.fontSize = null;
-        this.textColor = null;
-        this._elem;
-        // prop: escapeHTML
-        // true to escape HTML entities in the label.
-        this.escapeHTML = false;
-        
-        $.extend(true, this, options);
-    };
-    
-    $.jqplot.AxisLabelRenderer.prototype = new $.jqplot.ElemContainer();
-    $.jqplot.AxisLabelRenderer.prototype.constructor = $.jqplot.AxisLabelRenderer;
-    
-    $.jqplot.AxisLabelRenderer.prototype.init = function(options) {
-        $.extend(true, this, options);
-    };
-    
-    $.jqplot.AxisLabelRenderer.prototype.draw = function(ctx, plot) {
-        // Memory Leaks patch
-        if (this._elem) {
-            this._elem.emptyForce();
-            this._elem = null;
-        }
-
-        this._elem = $('<div style="position:absolute;" class="jqplot-'+this.axis+'-label"></div>');
-        
-        if (Number(this.label)) {
-            this._elem.css('white-space', 'nowrap');
-        }
-        
-        if (!this.escapeHTML) {
-            this._elem.html(this.label);
-        }
-        else {
-            this._elem.text(this.label);
-        }
-        if (this.fontFamily) {
-            this._elem.css('font-family', this.fontFamily);
-        }
-        if (this.fontSize) {
-            this._elem.css('font-size', this.fontSize);
-        }
-        if (this.textColor) {
-            this._elem.css('color', this.textColor);
-        }
-        
-        return this._elem;
-    };
-    
-    $.jqplot.AxisLabelRenderer.prototype.pack = function() {
-    };
-
-    // class: $.jqplot.AxisTickRenderer
-    // A "tick" object showing the value of a tick/gridline on the plot.
-    $.jqplot.AxisTickRenderer = function(options) {
-        // Group: Properties
-        $.jqplot.ElemContainer.call(this);
-        // prop: mark
-        // tick mark on the axis.  One of 'inside', 'outside', 'cross', '' or null.
-        this.mark = 'outside';
-        // name of the axis associated with this tick
-        this.axis;
-        // prop: showMark
-        // wether or not to show the mark on the axis.
-        this.showMark = true;
-        // prop: showGridline
-        // wether or not to draw the gridline on the grid at this tick.
-        this.showGridline = true;
-        // prop: isMinorTick
-        // if this is a minor tick.
-        this.isMinorTick = false;
-        // prop: size
-        // Length of the tick beyond the grid in pixels.
-        // DEPRECATED: This has been superceeded by markSize
-        this.size = 4;
-        // prop:  markSize
-        // Length of the tick marks in pixels.  For 'cross' style, length
-        // will be stoked above and below axis, so total length will be twice this.
-        this.markSize = 6;
-        // prop: show
-        // wether or not to show the tick (mark and label).
-        // Setting this to false requires more testing.  It is recommended
-        // to set showLabel and showMark to false instead.
-        this.show = true;
-        // prop: showLabel
-        // wether or not to show the label.
-        this.showLabel = true;
-        this.label = null;
-        this.value = null;
-        this._styles = {};
-        // prop: formatter
-        // A class of a formatter for the tick text.  sprintf by default.
-        this.formatter = $.jqplot.DefaultTickFormatter;
-        // prop: prefix
-        // String to prepend to the tick label.
-        // Prefix is prepended to the formatted tick label.
-        this.prefix = '';
-        // prop: formatString
-        // string passed to the formatter.
-        this.formatString = '';
-        // prop: fontFamily
-        // css spec for the font-family css attribute.
-        this.fontFamily;
-        // prop: fontSize
-        // css spec for the font-size css attribute.
-        this.fontSize;
-        // prop: textColor
-        // css spec for the color attribute.
-        this.textColor;
-        // prop: escapeHTML
-        // true to escape HTML entities in the label.
-        this.escapeHTML = false;
-        this._elem;
-		this._breakTick = false;
-        
-        $.extend(true, this, options);
-    };
-    
-    $.jqplot.AxisTickRenderer.prototype.init = function(options) {
-        $.extend(true, this, options);
-    };
-    
-    $.jqplot.AxisTickRenderer.prototype = new $.jqplot.ElemContainer();
-    $.jqplot.AxisTickRenderer.prototype.constructor = $.jqplot.AxisTickRenderer;
-    
-    $.jqplot.AxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) {
-        this.value = value;
-        this.axis = axisName;
-        if (isMinor) {
-            this.isMinorTick = true;
-        }
-        return this;
-    };
-    
-    $.jqplot.AxisTickRenderer.prototype.draw = function() {
-        if (this.label === null) {
-            this.label = this.prefix + this.formatter(this.formatString, this.value);
-        }
-        var style = {position: 'absolute'};
-        if (Number(this.label)) {
-            style['whitSpace'] = 'nowrap';
-        }
-        
-        // Memory Leaks patch
-        if (this._elem) {
-            this._elem.emptyForce();
-            this._elem = null;
-        }
-
-        this._elem = $(document.createElement('div'));
-        this._elem.addClass("jqplot-"+this.axis+"-tick");
-        
-        if (!this.escapeHTML) {
-            this._elem.html(this.label);
-        }
-        else {
-            this._elem.text(this.label);
-        }
-        
-        this._elem.css(style);
-
-        for (var s in this._styles) {
-            this._elem.css(s, this._styles[s]);
-        }
-        if (this.fontFamily) {
-            this._elem.css('font-family', this.fontFamily);
-        }
-        if (this.fontSize) {
-            this._elem.css('font-size', this.fontSize);
-        }
-        if (this.textColor) {
-            this._elem.css('color', this.textColor);
-        }
-		if (this._breakTick) {
-			this._elem.addClass('jqplot-breakTick');
-		}
-        
-        return this._elem;
-    };
-        
-    $.jqplot.DefaultTickFormatter = function (format, val) {
-        if (typeof val == 'number') {
-            if (!format) {
-                format = $.jqplot.config.defaultTickFormatString;
-            }
-            return $.jqplot.sprintf(format, val);
-        }
-        else {
-            return String(val);
-        }
-    };
-    
-    $.jqplot.AxisTickRenderer.prototype.pack = function() {
-    };
-     
-    // Class: $.jqplot.CanvasGridRenderer
-    // The default jqPlot grid renderer, creating a grid on a canvas element.
-    // The renderer has no additional options beyond the <Grid> class.
-    $.jqplot.CanvasGridRenderer = function(){
-        this.shadowRenderer = new $.jqplot.ShadowRenderer();
-    };
-    
-    // called with context of Grid object
-    $.jqplot.CanvasGridRenderer.prototype.init = function(options) {
-        this._ctx;
-        $.extend(true, this, options);
-        // set the shadow renderer options
-        var sopts = {lineJoin:'miter', lineCap:'round', fill:false, isarc:false, angle:this.shadowAngle, offset:this.shadowOffset, alpha:this.shadowAlpha, depth:this.shadowDepth, lineWidth:this.shadowWidth, closePath:false, strokeStyle:this.shadowColor};
-        this.renderer.shadowRenderer.init(sopts);
-    };
-    
-    // called with context of Grid.
-    $.jqplot.CanvasGridRenderer.prototype.createElement = function(plot) {
-        var elem;
-        // Memory Leaks patch
-        if (this._elem) {
-          if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
-            elem = this._elem.get(0);
-            window.G_vmlCanvasManager.uninitElement(elem);
-            elem = null;
-          }
-          
-          this._elem.emptyForce();
-          this._elem = null;
-        }
-      
-        elem = plot.canvasManager.getCanvas();
-
-        var w = this._plotDimensions.width;
-        var h = this._plotDimensions.height;
-        elem.width = w;
-        elem.height = h;
-        this._elem = $(elem);
-        this._elem.addClass('jqplot-grid-canvas');
-        this._elem.css({ position: 'absolute', left: 0, top: 0 });
-        
-		elem = plot.canvasManager.initCanvas(elem);
-		
-        this._top = this._offsets.top;
-        this._bottom = h - this._offsets.bottom;
-        this._left = this._offsets.left;
-        this._right = w - this._offsets.right;
-        this._width = this._right - this._left;
-        this._height = this._bottom - this._top;
-        // avoid memory leak
-        elem = null;
-        return this._elem;
-    };
-    
-    $.jqplot.CanvasGridRenderer.prototype.draw = function() {
-        this._ctx = this._elem.get(0).getContext("2d");
-        var ctx = this._ctx;
-        var axes = this._axes;
-        // Add the grid onto the grid canvas.  This is the bottom most layer.
-        ctx.save();
-        ctx.clearRect(0, 0, this._plotDimensions.width, this._plotDimensions.height);
-        ctx.fillStyle = this.backgroundColor || this.background;
-        ctx.fillRect(this._left, this._top, this._width, this._height);
-        
-        ctx.save();
-        ctx.lineJoin = 'miter';
-        ctx.lineCap = 'butt';
-        ctx.lineWidth = this.gridLineWidth;
-        ctx.strokeStyle = this.gridLineColor;
-        var b, e, s, m;
-        var ax = ['xaxis', 'yaxis', 'x2axis', 'y2axis'];
-        for (var i=4; i>0; i--) {
-            var name = ax[i-1];
-            var axis = axes[name];
-            var ticks = axis._ticks;
-            var numticks = ticks.length;
-            if (axis.show) {
-                if (axis.drawBaseline) {
-                    var bopts = {};
-                    if (axis.baselineWidth !== null) {
-                        bopts.lineWidth = axis.baselineWidth;
-                    }
-                    if (axis.baselineColor !== null) {
-                        bopts.strokeStyle = axis.baselineColor;
-                    }
-                    switch (name) {
-                        case 'xaxis':
-                            drawLine (this._left, this._bottom, this._right, this._bottom, bopts);
-                            break;
-                        case 'yaxis':
-                            drawLine (this._left, this._bottom, this._left, this._top, bopts);
-                            break;
-                        case 'x2axis':
-                            drawLine (this._left, this._bottom, this._right, this._bottom, bopts);
-                            break;
-                        case 'y2axis':
-                            drawLine (this._right, this._bottom, this._right, this._top, bopts);
-                            break;
-                    }
-                }
-                for (var j=numticks; j>0; j--) {
-                    var t = ticks[j-1];
-                    if (t.show) {
-                        var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                        switch (name) {
-                            case 'xaxis':
-                                // draw the grid line if we should
-                                if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) {
-                                    drawLine(pos, this._top, pos, this._bottom);
-                                }
-                                // draw the mark
-                                if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) {
-                                    s = t.markSize;
-                                    m = t.mark;
-                                    var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                                    switch (m) {
-                                        case 'outside':
-                                            b = this._bottom;
-                                            e = this._bottom+s;
-                                            break;
-                                        case 'inside':
-                                            b = this._bottom-s;
-                                            e = this._bottom;
-                                            break;
-                                        case 'cross':
-                                            b = this._bottom-s;
-                                            e = this._bottom+s;
-                                            break;
-                                        default:
-                                            b = this._bottom;
-                                            e = this._bottom+s;
-                                            break;
-                                    }
-                                    // draw the shadow
-                                    if (this.shadow) {
-                                        this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false});
-                                    }
-                                    // draw the line
-                                    drawLine(pos, b, pos, e);
-                                }
-                                break;
-                            case 'yaxis':
-                                // draw the grid line
-                                if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) {
-                                    drawLine(this._right, pos, this._left, pos);
-                                }
-                                // draw the mark
-                                if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) {
-                                    s = t.markSize;
-                                    m = t.mark;
-                                    var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                                    switch (m) {
-                                        case 'outside':
-                                            b = this._left-s;
-                                            e = this._left;
-                                            break;
-                                        case 'inside':
-                                            b = this._left;
-                                            e = this._left+s;
-                                            break;
-                                        case 'cross':
-                                            b = this._left-s;
-                                            e = this._left+s;
-                                            break;
-                                        default:
-                                            b = this._left-s;
-                                            e = this._left;
-                                            break;
-                                            }
-                                    // draw the shadow
-                                    if (this.shadow) {
-                                        this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
-                                    }
-                                    drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
-                                }
-                                break;
-                            case 'x2axis':
-                                // draw the grid line
-                                if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) {
-                                    drawLine(pos, this._bottom, pos, this._top);
-                                }
-                                // draw the mark
-                                if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) {
-                                    s = t.markSize;
-                                    m = t.mark;
-                                    var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                                    switch (m) {
-                                        case 'outside':
-                                            b = this._top-s;
-                                            e = this._top;
-                                            break;
-                                        case 'inside':
-                                            b = this._top;
-                                            e = this._top+s;
-                                            break;
-                                        case 'cross':
-                                            b = this._top-s;
-                                            e = this._top+s;
-                                            break;
-                                        default:
-                                            b = this._top-s;
-                                            e = this._top;
-                                            break;
-                                            }
-                                    // draw the shadow
-                                    if (this.shadow) {
-                                        this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false});
-                                    }
-                                    drawLine(pos, b, pos, e);
-                                }
-                                break;
-                            case 'y2axis':
-                                // draw the grid line
-                                if (t.showGridline && this.drawGridlines && ((!t.isMinorTick && axis.drawMajorGridlines) || (t.isMinorTick && axis.drawMinorGridlines)) ) {
-                                    drawLine(this._left, pos, this._right, pos);
-                                }
-                                // draw the mark
-                                if (t.showMark && t.mark && ((!t.isMinorTick && axis.drawMajorTickMarks) || (t.isMinorTick && axis.drawMinorTickMarks)) ) {
-                                    s = t.markSize;
-                                    m = t.mark;
-                                    var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                                    switch (m) {
-                                        case 'outside':
-                                            b = this._right;
-                                            e = this._right+s;
-                                            break;
-                                        case 'inside':
-                                            b = this._right-s;
-                                            e = this._right;
-                                            break;
-                                        case 'cross':
-                                            b = this._right-s;
-                                            e = this._right+s;
-                                            break;
-                                        default:
-                                            b = this._right;
-                                            e = this._right+s;
-                                            break;
-                                            }
-                                    // draw the shadow
-                                    if (this.shadow) {
-                                        this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
-                                    }
-                                    drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
-                                }
-                                break;
-                            default:
-                                break;
-                        }
-                    }
-                }
-                t = null;
-            }
-            axis = null;
-            ticks = null;
-        }
-        // Now draw grid lines for additional y axes
-        //////
-        // TO DO: handle yMidAxis
-        //////
-        ax = ['y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis', 'yMidAxis'];
-        for (var i=7; i>0; i--) {
-            var axis = axes[ax[i-1]];
-            var ticks = axis._ticks;
-            if (axis.show) {
-                var tn = ticks[axis.numberTicks-1];
-                var t0 = ticks[0];
-                var left = axis.getLeft();
-                var points = [[left, tn.getTop() + tn.getHeight()/2], [left, t0.getTop() + t0.getHeight()/2 + 1.0]];
-                // draw the shadow
-                if (this.shadow) {
-                    this.renderer.shadowRenderer.draw(ctx, points, {lineCap:'butt', fill:false, closePath:false});
-                }
-                // draw the line
-                drawLine(points[0][0], points[0][1], points[1][0], points[1][1], {lineCap:'butt', strokeStyle:axis.borderColor, lineWidth:axis.borderWidth});
-                // draw the tick marks
-                for (var j=ticks.length; j>0; j--) {
-                    var t = ticks[j-1];
-                    s = t.markSize;
-                    m = t.mark;
-                    var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                    if (t.showMark && t.mark) {
-                        switch (m) {
-                            case 'outside':
-                                b = left;
-                                e = left+s;
-                                break;
-                            case 'inside':
-                                b = left-s;
-                                e = left;
-                                break;
-                            case 'cross':
-                                b = left-s;
-                                e = left+s;
-                                break;
-                            default:
-                                b = left;
-                                e = left+s;
-                                break;
-                        }
-                        points = [[b,pos], [e,pos]];
-                        // draw the shadow
-                        if (this.shadow) {
-                            this.renderer.shadowRenderer.draw(ctx, points, {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
-                        }
-                        // draw the line
-                        drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
-                    }
-                    t = null;
-                }
-                t0 = null;
-            }
-            axis = null;
-            ticks =  null;
-        }
-        
-        ctx.restore();
-        
-        function drawLine(bx, by, ex, ey, opts) {
-            ctx.save();
-            opts = opts || {};
-            if (opts.lineWidth == null || opts.lineWidth != 0){
-                $.extend(true, ctx, opts);
-                ctx.beginPath();
-                ctx.moveTo(bx, by);
-                ctx.lineTo(ex, ey);
-                ctx.stroke();
-                ctx.restore();
-            }
-        }
-        
-        if (this.shadow) {
-            var points = [[this._left, this._bottom], [this._right, this._bottom], [this._right, this._top]];
-            this.renderer.shadowRenderer.draw(ctx, points);
-        }
-        // Now draw border around grid.  Use axis border definitions. start at
-        // upper left and go clockwise.
-        if (this.borderWidth != 0 && this.drawBorder) {
-            drawLine (this._left, this._top, this._right, this._top, {lineCap:'round', strokeStyle:axes.x2axis.borderColor, lineWidth:axes.x2axis.borderWidth});
-            drawLine (this._right, this._top, this._right, this._bottom, {lineCap:'round', strokeStyle:axes.y2axis.borderColor, lineWidth:axes.y2axis.borderWidth});
-            drawLine (this._right, this._bottom, this._left, this._bottom, {lineCap:'round', strokeStyle:axes.xaxis.borderColor, lineWidth:axes.xaxis.borderWidth});
-            drawLine (this._left, this._bottom, this._left, this._top, {lineCap:'round', strokeStyle:axes.yaxis.borderColor, lineWidth:axes.yaxis.borderWidth});
-        }
-        // ctx.lineWidth = this.borderWidth;
-        // ctx.strokeStyle = this.borderColor;
-        // ctx.strokeRect(this._left, this._top, this._width, this._height);
-        
-        ctx.restore();
-        ctx =  null;
-        axes = null;
-    };
- 
-    // Class: $.jqplot.DivTitleRenderer
-    // The default title renderer for jqPlot.  This class has no options beyond the <Title> class. 
-    $.jqplot.DivTitleRenderer = function() {
-    };
-    
-    $.jqplot.DivTitleRenderer.prototype.init = function(options) {
-        $.extend(true, this, options);
-    };
-    
-    $.jqplot.DivTitleRenderer.prototype.draw = function() {
-        // Memory Leaks patch
-        if (this._elem) {
-            this._elem.emptyForce();
-            this._elem = null;
-        }
-
-        var r = this.renderer;
-        var elem = document.createElement('div');
-        this._elem = $(elem);
-        this._elem.addClass('jqplot-title');
-
-        if (!this.text) {
-            this.show = false;
-            this._elem.height(0);
-            this._elem.width(0);
-        }
-        else if (this.text) {
-            var color;
-            if (this.color) {
-                color = this.color;
-            }
-            else if (this.textColor) {
-                color = this.textColor;
-            }
-
-            // don't trust that a stylesheet is present, set the position.
-            var styles = {position:'absolute', top:'0px', left:'0px'};
-
-            if (this._plotWidth) {
-                styles['width'] = this._plotWidth+'px';
-            }
-            if (this.fontSize) {
-                styles['fontSize'] = this.fontSize;
-            }
-            if (typeof this.textAlign === 'string') {
-                styles['textAlign'] = this.textAlign;
-            }
-            else {
-                styles['textAlign'] = 'center';
-            }
-            if (color) {
-                styles['color'] = color;
-            }
-            if (this.paddingBottom) {
-                styles['paddingBottom'] = this.paddingBottom;
-            }
-            if (this.fontFamily) {
-                styles['fontFamily'] = this.fontFamily;
-            }
-
-            this._elem.css(styles);
-            if (this.escapeHtml) {
-                this._elem.text(this.text);
-            }
-            else {
-                this._elem.html(this.text);
-            }
-
-
-            // styletext += (this._plotWidth) ? 'width:'+this._plotWidth+'px;' : '';
-            // styletext += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
-            // styletext += (this.textAlign) ? 'text-align:'+this.textAlign+';' : 'text-align:center;';
-            // styletext += (color) ? 'color:'+color+';' : '';
-            // styletext += (this.paddingBottom) ? 'padding-bottom:'+this.paddingBottom+';' : '';
-            // this._elem = $('<div class="jqplot-title" style="'+styletext+'">'+this.text+'</div>');
-            // if (this.fontFamily) {
-            //     this._elem.css('font-family', this.fontFamily);
-            // }
-        }
-
-        elem = null;
-        
-        return this._elem;
-    };
-    
-    $.jqplot.DivTitleRenderer.prototype.pack = function() {
-        // nothing to do here
-    };
-  
-
-    var dotlen = 0.1;
-
-    $.jqplot.LinePattern = function (ctx, pattern) {
-
-		var defaultLinePatterns = {
-			dotted: [ dotlen, $.jqplot.config.dotGapLength ],
-			dashed: [ $.jqplot.config.dashLength, $.jqplot.config.gapLength ],
-			solid: null
-		};   	
-
-        if (typeof pattern === 'string') {
-            if (pattern[0] === '.' || pattern[0] === '-') {
-                var s = pattern;
-                pattern = [];
-                for (var i=0, imax=s.length; i<imax; i++) {
-                    if (s[i] === '.') {
-                        pattern.push( dotlen );
-                    }
-                    else if (s[i] === '-') {
-                        pattern.push( $.jqplot.config.dashLength );
-                    }
-                    else {
-                        continue;
-                    }
-                    pattern.push( $.jqplot.config.gapLength );
-                }
-            }
-            else {
-                pattern = defaultLinePatterns[pattern];
-            }
-        }
-
-        if (!(pattern && pattern.length)) {
-            return ctx;
-        }
-
-        var patternIndex = 0;
-        var patternDistance = pattern[0];
-        var px = 0;
-        var py = 0;
-        var pathx0 = 0;
-        var pathy0 = 0;
-
-        var moveTo = function (x, y) {
-            ctx.moveTo( x, y );
-            px = x;
-            py = y;
-            pathx0 = x;
-            pathy0 = y;
-        };
-
-        var lineTo = function (x, y) {
-            var scale = ctx.lineWidth;
-            var dx = x - px;
-            var dy = y - py;
-            var dist = Math.sqrt(dx*dx+dy*dy);
-            if ((dist > 0) && (scale > 0)) {
-                dx /= dist;
-                dy /= dist;
-                while (true) {
-                    var dp = scale * patternDistance;
-                    if (dp < dist) {
-                        px += dp * dx;
-                        py += dp * dy;
-                        if ((patternIndex & 1) == 0) {
-                            ctx.lineTo( px, py );
-                        }
-                        else {
-                            ctx.moveTo( px, py );
-                        }
-                        dist -= dp;
-                        patternIndex++;
-                        if (patternIndex >= pattern.length) {
-                            patternIndex = 0;
-                        }
-                        patternDistance = pattern[patternIndex];
-                    }
-                    else {
-                        px = x;
-                        py = y;
-                        if ((patternIndex & 1) == 0) {
-                            ctx.lineTo( px, py );
-                        }
-                        else {
-                            ctx.moveTo( px, py );
-                        }
-                        patternDistance -= dist / scale;
-                        break;
-                    }
-                }
-            }
-        };
-
-        var beginPath = function () {
-            ctx.beginPath();
-        };
-
-        var closePath = function () {
-            lineTo( pathx0, pathy0 );
-        };
-
-        return {
-            moveTo: moveTo,
-            lineTo: lineTo,
-            beginPath: beginPath,
-            closePath: closePath
-        };
-    };
-
-    // Class: $.jqplot.LineRenderer
-    // The default line renderer for jqPlot, this class has no options beyond the <Series> class.
-    // Draws series as a line.
-    $.jqplot.LineRenderer = function(){
-        this.shapeRenderer = new $.jqplot.ShapeRenderer();
-        this.shadowRenderer = new $.jqplot.ShadowRenderer();
-    };
-    
-    // called with scope of series.
-    $.jqplot.LineRenderer.prototype.init = function(options, plot) {
-        // Group: Properties
-        //
-        options = options || {};
-        this._type='line';
-        // prop: smooth
-        // True to draw a smoothed (interpolated) line through the data points
-        // with automatically computed number of smoothing points.
-        // Set to an integer number > 2 to specify number of smoothing points
-        // to use between each data point.
-        this.renderer.smooth = false;  // true or a number > 2 for smoothing.
-        this.renderer.tension = null; // null to auto compute or a number typically > 6.  Fewer points requires higher tension.
-        // prop: constrainSmoothing
-        // True to use a more accurate smoothing algorithm that will
-        // not overshoot any data points.  False to allow overshoot but
-        // produce a smoother looking line.
-        this.renderer.constrainSmoothing = true;
-        // this is smoothed data in grid coordinates, like gridData
-        this.renderer._smoothedData = [];
-        // this is smoothed data in plot units (plot coordinates), like plotData.
-        this.renderer._smoothedPlotData = [];
-        this.renderer._hiBandGridData = [];
-        this.renderer._lowBandGridData = [];
-        this.renderer._hiBandSmoothedData = [];
-        this.renderer._lowBandSmoothedData = [];
-
-        // prop: bandData
-        // Data used to draw error bands or confidence intervals above/below a line.
-        //
-        // bandData can be input in 3 forms.  jqPlot will figure out which is the
-        // low band line and which is the high band line for all forms:
-        // 
-        // A 2 dimensional array like [[yl1, yl2, ...], [yu1, yu2, ...]] where
-        // [yl1, yl2, ...] are y values of the lower line and
-        // [yu1, yu2, ...] are y values of the upper line.
-        // In this case there must be the same number of y data points as data points
-        // in the series and the bands will inherit the x values of the series.
-        //
-        // A 2 dimensional array like [[[xl1, yl1], [xl2, yl2], ...], [[xh1, yh1], [xh2, yh2], ...]]
-        // where [xl1, yl1] are x,y data points for the lower line and
-        // [xh1, yh1] are x,y data points for the high line.
-        // x values do not have to correspond to the x values of the series and can
-        // be of any arbitrary length.
-        //
-        // Can be of form [[yl1, yu1], [yl2, yu2], [yl3, yu3], ...] where
-        // there must be 3 or more arrays and there must be the same number of arrays
-        // as there are data points in the series.  In this case, 
-        // [yl1, yu1] specifies the lower and upper y values for the 1st
-        // data point and so on.  The bands will inherit the x
-        // values from the series.
-        this.renderer.bandData = [];
-
-        // Group: bands
-        // Banding around line, e.g error bands or confidence intervals.
-        this.renderer.bands = {
-            // prop: show
-            // true to show the bands.  If bandData or interval is
-            // supplied, show will be set to true by default.
-            show: false,
-            hiData: [],
-            lowData: [],
-            // prop: color
-            // color of lines at top and bottom of bands [default: series color].
-            color: this.color,
-            // prop: showLines
-            // True to show lines at top and bottom of bands [default: false].
-            showLines: false,
-            // prop: fill
-            // True to fill area between bands [default: true].
-            fill: true,
-            // prop: fillColor
-            // css color spec for filled area.  [default: series color].
-            fillColor: null,
-            _min: null,
-            _max: null,
-            // prop: interval
-            // User specified interval above and below line for bands [default: '3%''].
-            // Can be a value like 3 or a string like '3%' 
-            // or an upper/lower array like [1, -2] or ['2%', '-1.5%']
-            interval: '3%'
-        };
-
-
-        var lopts = {highlightMouseOver: options.highlightMouseOver, highlightMouseDown: options.highlightMouseDown, highlightColor: options.highlightColor};
-        
-        delete (options.highlightMouseOver);
-        delete (options.highlightMouseDown);
-        delete (options.highlightColor);
-        
-        $.extend(true, this.renderer, options);
-
-        this.renderer.options = options;
-
-        // if we are given some band data, and bands aren't explicity set to false in options, turn them on.
-        if (this.renderer.bandData.length > 1 && (!options.bands || options.bands.show == null)) {
-            this.renderer.bands.show = true;
-        }
-
-        // if we are given an interval, and bands aren't explicity set to false in options, turn them on.
-        else if (options.bands && options.bands.show == null && options.bands.interval != null) {
-            this.renderer.bands.show = true;
-        }
-
-        // if plot is filled, turn off bands.
-        if (this.fill) {
-            this.renderer.bands.show = false;
-        }
-
-        if (this.renderer.bands.show) {
-            this.renderer.initBands.call(this, this.renderer.options, plot);
-        }
-
-
-        // smoothing is not compatible with stacked lines, disable
-        if (this._stack) {
-            this.renderer.smooth = false;
-        }
-
-        // set the shape renderer options
-        var opts = {lineJoin:this.lineJoin, lineCap:this.lineCap, fill:this.fill, isarc:false, strokeStyle:this.color, fillStyle:this.fillColor, lineWidth:this.lineWidth, linePattern:this.linePattern, closePath:this.fill};
-        this.renderer.shapeRenderer.init(opts);
-
-        var shadow_offset = options.shadowOffset;
-        // set the shadow renderer options
-        if (shadow_offset == null) {
-            // scale the shadowOffset to the width of the line.
-            if (this.lineWidth > 2.5) {
-                shadow_offset = 1.25 * (1 + (Math.atan((this.lineWidth/2.5))/0.785398163 - 1)*0.6);
-                // var shadow_offset = this.shadowOffset;
-            }
-            // for skinny lines, don't make such a big shadow.
-            else {
-                shadow_offset = 1.25 * Math.atan((this.lineWidth/2.5))/0.785398163;
-            }
-        }
-        
-        var sopts = {lineJoin:this.lineJoin, lineCap:this.lineCap, fill:this.fill, isarc:false, angle:this.shadowAngle, offset:shadow_offset, alpha:this.shadowAlpha, depth:this.shadowDepth, lineWidth:this.lineWidth, linePattern:this.linePattern, closePath:this.fill};
-        this.renderer.shadowRenderer.init(sopts);
-        this._areaPoints = [];
-        this._boundingBox = [[],[]];
-        
-        if (!this.isTrendline && this.fill || this.renderer.bands.show) {
-            // Group: Properties
-            //        
-            // prop: highlightMouseOver
-            // True to highlight area on a filled plot when moused over.
-            // This must be false to enable highlightMouseDown to highlight when clicking on an area on a filled plot.
-            this.highlightMouseOver = true;
-            // prop: highlightMouseDown
-            // True to highlight when a mouse button is pressed over an area on a filled plot.
-            // This will be disabled if highlightMouseOver is true.
-            this.highlightMouseDown = false;
-            // prop: highlightColor
-            // color to use when highlighting an area on a filled plot.
-            this.highlightColor = null;
-            // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
-            if (lopts.highlightMouseDown && lopts.highlightMouseOver == null) {
-                lopts.highlightMouseOver = false;
-            }
-        
-            $.extend(true, this, {highlightMouseOver: lopts.highlightMouseOver, highlightMouseDown: lopts.highlightMouseDown, highlightColor: lopts.highlightColor});
-            
-            if (!this.highlightColor) {
-                var fc = (this.renderer.bands.show) ? this.renderer.bands.fillColor : this.fillColor;
-                this.highlightColor = $.jqplot.computeHighlightColors(fc);
-            }
-            // turn off (disable) the highlighter plugin
-            if (this.highlighter) {
-                this.highlighter.show = false;
-            }
-        }
-        
-        if (!this.isTrendline && plot) {
-            plot.plugins.lineRenderer = {};
-            plot.postInitHooks.addOnce(postInit);
-            plot.postDrawHooks.addOnce(postPlotDraw);
-            plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
-            plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
-            plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
-            plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
-            plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
-        }
-
-    };
-
-    $.jqplot.LineRenderer.prototype.initBands = function(options, plot) {
-        // use bandData if no data specified in bands option
-        //var bd = this.renderer.bandData;
-        var bd = options.bandData || [];
-        var bands = this.renderer.bands;
-        bands.hiData = [];
-        bands.lowData = [];
-        var data = this.data;
-        bands._max = null;
-        bands._min = null;
-        // If 2 arrays, and each array greater than 2 elements, assume it is hi and low data bands of y values.
-        if (bd.length == 2) {
-            // Do we have an array of x,y values?
-            // like [[[1,1], [2,4], [3,3]], [[1,3], [2,6], [3,5]]]
-            if ($.isArray(bd[0][0])) {
-                // since an arbitrary array of points, spin through all of them to determine max and min lines.
-
-                var p;
-                var bdminidx = 0, bdmaxidx = 0;
-                for (var i = 0, l = bd[0].length; i<l; i++) {
-                    p = bd[0][i];
-                    if ((p[1] != null && p[1] > bands._max) || bands._max == null) {
-                        bands._max = p[1];
-                    }
-                    if ((p[1] != null && p[1] < bands._min) || bands._min == null) {
-                        bands._min = p[1];
-                    }
-                }
-                for (var i = 0, l = bd[1].length; i<l; i++) {
-                    p = bd[1][i];
-                    if ((p[1] != null && p[1] > bands._max) || bands._max == null) {
-                        bands._max = p[1];
-                        bdmaxidx = 1;
-                    }
-                    if ((p[1] != null && p[1] < bands._min) || bands._min == null) {
-                        bands._min = p[1];
-                        bdminidx = 1;
-                    }
-                }
-
-                if (bdmaxidx === bdminidx) {
-                    bands.show = false;
-                }
-
-                bands.hiData = bd[bdmaxidx];
-                bands.lowData = bd[bdminidx];
-            }
-            // else data is arrays of y values
-            // like [[1,4,3], [3,6,5]]
-            // must have same number of band data points as points in series
-            else if (bd[0].length === data.length && bd[1].length === data.length) {
-                var hi = (bd[0][0] > bd[1][0]) ? 0 : 1;
-                var low = (hi) ? 0 : 1;
-                for (var i=0, l=data.length; i < l; i++) {
-                    bands.hiData.push([data[i][0], bd[hi][i]]);
-                    bands.lowData.push([data[i][0], bd[low][i]]);
-                }
-            }
-
-            // we don't have proper data array, don't show bands.
-            else {
-                bands.show = false;
-            }
-        }
-
-        // if more than 2 arrays, have arrays of [ylow, yhi] values.
-        // note, can't distinguish case of [[ylow, yhi], [ylow, yhi]] from [[ylow, ylow], [yhi, yhi]]
-        // this is assumed to be of the latter form.
-        else if (bd.length > 2 && !$.isArray(bd[0][0])) {
-            var hi = (bd[0][0] > bd[0][1]) ? 0 : 1;
-            var low = (hi) ? 0 : 1;
-            for (var i=0, l=bd.length; i<l; i++) {
-                bands.hiData.push([data[i][0], bd[i][hi]]);
-                bands.lowData.push([data[i][0], bd[i][low]]);
-            }
-        }
-
-        // don't have proper data, auto calculate
-        else {
-            var intrv = bands.interval;
-            var a = null;
-            var b = null;
-            var afunc = null;
-            var bfunc = null;
-
-            if ($.isArray(intrv)) {
-                a = intrv[0];
-                b = intrv[1];
-            }
-            else {
-                a = intrv;
-            }
-
-            if (isNaN(a)) {
-                // we have a string
-                if (a.charAt(a.length - 1) === '%') {
-                    afunc = 'multiply';
-                    a = parseFloat(a)/100 + 1;
-                }
-            }
-
-            else {
-                a = parseFloat(a);
-                afunc = 'add';
-            }
-
-            if (b !== null && isNaN(b)) {
-                // we have a string
-                if (b.charAt(b.length - 1) === '%') {
-                    bfunc = 'multiply';
-                    b = parseFloat(b)/100 + 1;
-                }
-            }
-
-            else if (b !== null) {
-                b = parseFloat(b);
-                bfunc = 'add';
-            }
-
-            if (a !== null) {
-                if (b === null) {
-                    b = -a;
-                    bfunc = afunc;
-                    if (bfunc === 'multiply') {
-                        b += 2;
-                    }
-                }
-
-                // make sure a always applies to hi band.
-                if (a < b) {
-                    var temp = a;
-                    a = b;
-                    b = temp;
-                    temp = afunc;
-                    afunc = bfunc;
-                    bfunc = temp;
-                }
-
-                for (var i=0, l = data.length; i < l; i++) {
-                    switch (afunc) {
-                        case 'add':
-                            bands.hiData.push([data[i][0], data[i][1] + a]);
-                            break;
-                        case 'multiply':
-                            bands.hiData.push([data[i][0], data[i][1] * a]);
-                            break;
-                    }
-                    switch (bfunc) {
-                        case 'add':
-                            bands.lowData.push([data[i][0], data[i][1] + b]);
-                            break;
-                        case 'multiply':
-                            bands.lowData.push([data[i][0], data[i][1] * b]);
-                            break;
-                    }
-                }
-            }
-
-            else {
-                bands.show = false;
-            }
-        }
-
-        var hd = bands.hiData;
-        var ld = bands.lowData;
-        for (var i = 0, l = hd.length; i<l; i++) {
-            if ((hd[i][1] != null && hd[i][1] > bands._max) || bands._max == null) {
-                bands._max = hd[i][1];
-            }
-        }
-        for (var i = 0, l = ld.length; i<l; i++) {
-            if ((ld[i][1] != null && ld[i][1] < bands._min) || bands._min == null) {
-                bands._min = ld[i][1];
-            }
-        }
-
-        // one last check for proper data
-        // these don't apply any more since allowing arbitrary x,y values
-        // if (bands.hiData.length != bands.lowData.length) {
-        //     bands.show = false;
-        // }
-
-        // if (bands.hiData.length != this.data.length) {
-        //     bands.show = false;
-        // }
-
-        if (bands.fillColor === null) {
-            var c = $.jqplot.getColorComponents(bands.color);
-            // now adjust alpha to differentiate fill
-            c[3] = c[3] * 0.5;
-            bands.fillColor = 'rgba(' + c[0] +', '+ c[1] +', '+ c[2] +', '+ c[3] + ')';
-        }
-    };
-
-    function getSteps (d, f) {
-        return (3.4182054+f) * Math.pow(d, -0.3534992);
-    }
-
-    function computeSteps (d1, d2) {
-        var s = Math.sqrt(Math.pow((d2[0]- d1[0]), 2) + Math.pow ((d2[1] - d1[1]), 2));
-        return 5.7648 * Math.log(s) + 7.4456;
-    }
-
-    function tanh (x) {
-        var a = (Math.exp(2*x) - 1) / (Math.exp(2*x) + 1);
-        return a;
-    }
-
-    //////////
-    // computeConstrainedSmoothedData
-    // An implementation of the constrained cubic spline interpolation
-    // method as presented in:
-    //
-    // Kruger, CJC, Constrained Cubic Spine Interpolation for Chemical Engineering Applications
-    // http://www.korf.co.uk/spline.pdf
-    //
-    // The implementation below borrows heavily from the sample Visual Basic
-    // implementation by CJC Kruger found in http://www.korf.co.uk/spline.xls
-    //
-    /////////
-
-    // called with scope of series
-    function computeConstrainedSmoothedData (gd) {
-        var smooth = this.renderer.smooth;
-        var dim = this.canvas.getWidth();
-        var xp = this._xaxis.series_p2u;
-        var yp = this._yaxis.series_p2u; 
-        var steps =null;
-        var _steps = null;
-        var dist = gd.length/dim;
-        var _smoothedData = [];
-        var _smoothedPlotData = [];
-
-        if (!isNaN(parseFloat(smooth))) {
-            steps = parseFloat(smooth);
-        }
-        else {
-            steps = getSteps(dist, 0.5);
-        }
-
-        var yy = [];
-        var xx = [];
-
-        for (var i=0, l = gd.length; i<l; i++) {
-            yy.push(gd[i][1]);
-            xx.push(gd[i][0]);
-        }
-
-        function dxx(x1, x0) {
-            if (x1 - x0 == 0) {
-                return Math.pow(10,10);
-            }
-            else {
-                return x1 - x0;
-            }
-        }
-
-        var A, B, C, D;
-        // loop through each line segment.  Have # points - 1 line segments.  Nmber segments starting at 1.
-        var nmax = gd.length - 1;
-        for (var num = 1, gdl = gd.length; num<gdl; num++) {
-            var gxx = [];
-            var ggxx = [];
-            // point at each end of segment.
-            for (var j = 0; j < 2; j++) {
-                var i = num - 1 + j; // point number, 0 to # points.
-
-                if (i == 0 || i == nmax) {
-                    gxx[j] = Math.pow(10, 10);
-                }
-                else if (yy[i+1] - yy[i] == 0 || yy[i] - yy[i-1] == 0) {
-                    gxx[j] = 0;
-                }
-                else if (((xx[i+1] - xx[i]) / (yy[i+1] - yy[i]) + (xx[i] - xx[i-1]) / (yy[i] - yy[i-1])) == 0 ) {
-                    gxx[j] = 0;
-                }
-                else if ( (yy[i+1] - yy[i]) * (yy[i] - yy[i-1]) < 0 ) {
-                    gxx[j] = 0;
-                }
-
-                else {
-                    gxx[j] = 2 / (dxx(xx[i + 1], xx[i]) / (yy[i + 1] - yy[i]) + dxx(xx[i], xx[i - 1]) / (yy[i] - yy[i - 1]));
-                }
-            }
-
-            // Reset first derivative (slope) at first and last point
-            if (num == 1) {
-                // First point has 0 2nd derivative
-                gxx[0] = 3 / 2 * (yy[1] - yy[0]) / dxx(xx[1], xx[0]) - gxx[1] / 2;
-            }
-            else if (num == nmax) {
-                // Last point has 0 2nd derivative
-                gxx[1] = 3 / 2 * (yy[nmax] - yy[nmax - 1]) / dxx(xx[nmax], xx[nmax - 1]) - gxx[0] / 2;
-            }   
-
-            // Calc second derivative at points
-            ggxx[0] = -2 * (gxx[1] + 2 * gxx[0]) / dxx(xx[num], xx[num - 1]) + 6 * (yy[num] - yy[num - 1]) / Math.pow(dxx(xx[num], xx[num - 1]), 2);
-            ggxx[1] = 2 * (2 * gxx[1] + gxx[0]) / dxx(xx[num], xx[num - 1]) - 6 * (yy[num] - yy[num - 1]) / Math.pow(dxx(xx[num], xx[num - 1]), 2);
-
-            // Calc constants for cubic interpolation
-            D = 1 / 6 * (ggxx[1] - ggxx[0]) / dxx(xx[num], xx[num - 1]);
-            C = 1 / 2 * (xx[num] * ggxx[0] - xx[num - 1] * ggxx[1]) / dxx(xx[num], xx[num - 1]);
-            B = (yy[num] - yy[num - 1] - C * (Math.pow(xx[num], 2) - Math.pow(xx[num - 1], 2)) - D * (Math.pow(xx[num], 3) - Math.pow(xx[num - 1], 3))) / dxx(xx[num], xx[num - 1]);
-            A = yy[num - 1] - B * xx[num - 1] - C * Math.pow(xx[num - 1], 2) - D * Math.pow(xx[num - 1], 3);
-
-            var increment = (xx[num] - xx[num - 1]) / steps;
-            var temp, tempx;
-
-            for (var j = 0, l = steps; j < l; j++) {
-                temp = [];
-                tempx = xx[num - 1] + j * increment;
-                temp.push(tempx);
-                temp.push(A + B * tempx + C * Math.pow(tempx, 2) + D * Math.pow(tempx, 3));
-                _smoothedData.push(temp);
-                _smoothedPlotData.push([xp(temp[0]), yp(temp[1])]);
-            }
-        }
-
-        _smoothedData.push(gd[i]);
-        _smoothedPlotData.push([xp(gd[i][0]), yp(gd[i][1])]);
-
-        return [_smoothedData, _smoothedPlotData];
-    }
-
-    ///////
-    // computeHermiteSmoothedData
-    // A hermite spline smoothing of the plot data.
-    // This implementation is derived from the one posted
-    // by krypin on the jqplot-users mailing list:
-    //
-    // http://groups.google.com/group/jqplot-users/browse_thread/thread/748be6a445723cea?pli=1
-    //
-    // with a blog post:
-    //
-    // http://blog.statscollector.com/a-plugin-renderer-for-jqplot-to-draw-a-hermite-spline/
-    //
-    // and download of the original plugin:
-    //
-    // http://blog.statscollector.com/wp-content/uploads/2010/02/jqplot.hermiteSplineRenderer.js
-    //////////
-
-    // called with scope of series
-    function computeHermiteSmoothedData (gd) {
-        var smooth = this.renderer.smooth;
-        var tension = this.renderer.tension;
-        var dim = this.canvas.getWidth();
-        var xp = this._xaxis.series_p2u;
-        var yp = this._yaxis.series_p2u; 
-        var steps =null;
-        var _steps = null;
-        var a = null;
-        var a1 = null;
-        var a2 = null;
-        var slope = null;
-        var slope2 = null;
-        var temp = null;
-        var t, s, h1, h2, h3, h4;
-        var TiX, TiY, Ti1X, Ti1Y;
-        var pX, pY, p;
-        var sd = [];
-        var spd = [];
-        var dist = gd.length/dim;
-        var min, max, stretch, scale, shift;
-        var _smoothedData = [];
-        var _smoothedPlotData = [];
-        if (!isNaN(parseFloat(smooth))) {
-            steps = parseFloat(smooth);
-        }
-        else {
-            steps = getSteps(dist, 0.5);
-        }
-        if (!isNaN(parseFloat(tension))) {
-            tension = parseFloat(tension);
-        }
-
-        for (var i=0, l = gd.length-1; i < l; i++) {
-
-            if (tension === null) {
-                slope = Math.abs((gd[i+1][1] - gd[i][1]) / (gd[i+1][0] - gd[i][0]));
-
-                min = 0.3;
-                max = 0.6;
-                stretch = (max - min)/2.0;
-                scale = 2.5;
-                shift = -1.4;
-
-                temp = slope/scale + shift;
-
-                a1 = stretch * tanh(temp) - stretch * tanh(shift) + min;
-
-                // if have both left and right line segments, will use  minimum tension. 
-                if (i > 0) {
-                    slope2 = Math.abs((gd[i][1] - gd[i-1][1]) / (gd[i][0] - gd[i-1][0]));
-                }
-                temp = slope2/scale + shift;
-
-                a2 = stretch * tanh(temp) - stretch * tanh(shift) + min;
-
-                a = (a1 + a2)/2.0;
-
-            }
-            else {
-                a = tension;
-            }
-            for (t=0; t < steps; t++) {
-                s = t / steps;
-                h1 = (1 + 2*s)*Math.pow((1-s),2);
-                h2 = s*Math.pow((1-s),2);
-                h3 = Math.pow(s,2)*(3-2*s);
-                h4 = Math.pow(s,2)*(s-1);     
-                
-                if (gd[i-1]) {  
-                    TiX = a * (gd[i+1][0] - gd[i-1][0]); 
-                    TiY = a * (gd[i+1][1] - gd[i-1][1]);
-                } else {
-                    TiX = a * (gd[i+1][0] - gd[i][0]); 
-                    TiY = a * (gd[i+1][1] - gd[i][1]);                                  
-                }
-                if (gd[i+2]) {  
-                    Ti1X = a * (gd[i+2][0] - gd[i][0]); 
-                    Ti1Y = a * (gd[i+2][1] - gd[i][1]);
-                } else {
-                    Ti1X = a * (gd[i+1][0] - gd[i][0]); 
-                    Ti1Y = a * (gd[i+1][1] - gd[i][1]);                                 
-                }
-                
-                pX = h1*gd[i][0] + h3*gd[i+1][0] + h2*TiX + h4*Ti1X;
-                pY = h1*gd[i][1] + h3*gd[i+1][1] + h2*TiY + h4*Ti1Y;
-                p = [pX, pY];
-
-                _smoothedData.push(p);
-                _smoothedPlotData.push([xp(pX), yp(pY)]);
-            }
-        }
-        _smoothedData.push(gd[l]);
-        _smoothedPlotData.push([xp(gd[l][0]), yp(gd[l][1])]);
-
-        return [_smoothedData, _smoothedPlotData];
-    }
-    
-    // setGridData
-    // converts the user data values to grid coordinates and stores them
-    // in the gridData array.
-    // Called with scope of a series.
-    $.jqplot.LineRenderer.prototype.setGridData = function(plot) {
-        // recalculate the grid data
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var data = this._plotData;
-        var pdata = this._prevPlotData;
-        this.gridData = [];
-        this._prevGridData = [];
-        this.renderer._smoothedData = [];
-        this.renderer._smoothedPlotData = [];
-        this.renderer._hiBandGridData = [];
-        this.renderer._lowBandGridData = [];
-        this.renderer._hiBandSmoothedData = [];
-        this.renderer._lowBandSmoothedData = [];
-        var bands = this.renderer.bands;
-        var hasNull = false;
-        for (var i=0, l=this.data.length; i < l; i++) {
-            // if not a line series or if no nulls in data, push the converted point onto the array.
-            if (data[i][0] != null && data[i][1] != null) {
-                this.gridData.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1])]);
-            }
-            // else if there is a null, preserve it.
-            else if (data[i][0] == null) {
-                hasNull = true;
-                this.gridData.push([null, yp.call(this._yaxis, data[i][1])]);
-            }
-            else if (data[i][1] == null) {
-                hasNull = true;
-                this.gridData.push([xp.call(this._xaxis, data[i][0]), null]);
-            }
-            // if not a line series or if no nulls in data, push the converted point onto the array.
-            if (pdata[i] != null && pdata[i][0] != null && pdata[i][1] != null) {
-                this._prevGridData.push([xp.call(this._xaxis, pdata[i][0]), yp.call(this._yaxis, pdata[i][1])]);
-            }
-            // else if there is a null, preserve it.
-            else if (pdata[i] != null && pdata[i][0] == null) {
-                this._prevGridData.push([null, yp.call(this._yaxis, pdata[i][1])]);
-            }  
-            else if (pdata[i] != null && pdata[i][0] != null && pdata[i][1] == null) {
-                this._prevGridData.push([xp.call(this._xaxis, pdata[i][0]), null]);
-            }
-        }
-
-        // don't do smoothing or bands on broken lines.
-        if (hasNull) {
-            this.renderer.smooth = false;
-            if (this._type === 'line') {
-                bands.show = false;
-            }
-        }
-
-        if (this._type === 'line' && bands.show) {
-            for (var i=0, l=bands.hiData.length; i<l; i++) {
-                this.renderer._hiBandGridData.push([xp.call(this._xaxis, bands.hiData[i][0]), yp.call(this._yaxis, bands.hiData[i][1])]);
-            }
-            for (var i=0, l=bands.lowData.length; i<l; i++) {
-                this.renderer._lowBandGridData.push([xp.call(this._xaxis, bands.lowData[i][0]), yp.call(this._yaxis, bands.lowData[i][1])]);
-            }
-        }
-
-        // calculate smoothed data if enough points and no nulls
-        if (this._type === 'line' && this.renderer.smooth && this.gridData.length > 2) {
-            var ret;
-            if (this.renderer.constrainSmoothing) {
-                ret = computeConstrainedSmoothedData.call(this, this.gridData);
-                this.renderer._smoothedData = ret[0];
-                this.renderer._smoothedPlotData = ret[1];
-
-                if (bands.show) {
-                    ret = computeConstrainedSmoothedData.call(this, this.renderer._hiBandGridData);
-                    this.renderer._hiBandSmoothedData = ret[0];
-                    ret = computeConstrainedSmoothedData.call(this, this.renderer._lowBandGridData);
-                    this.renderer._lowBandSmoothedData = ret[0];
-                }
-
-                ret = null;
-            }
-            else {
-                ret = computeHermiteSmoothedData.call(this, this.gridData);
-                this.renderer._smoothedData = ret[0];
-                this.renderer._smoothedPlotData = ret[1];
-
-                if (bands.show) {
-                    ret = computeHermiteSmoothedData.call(this, this.renderer._hiBandGridData);
-                    this.renderer._hiBandSmoothedData = ret[0];
-                    ret = computeHermiteSmoothedData.call(this, this.renderer._lowBandGridData);
-                    this.renderer._lowBandSmoothedData = ret[0];
-                }
-
-                ret = null;
-            }
-        }
-    };
-    
-    // makeGridData
-    // converts any arbitrary data values to grid coordinates and
-    // returns them.  This method exists so that plugins can use a series'
-    // linerenderer to generate grid data points without overwriting the
-    // grid data associated with that series.
-    // Called with scope of a series.
-    $.jqplot.LineRenderer.prototype.makeGridData = function(data, plot) {
-        // recalculate the grid data
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var gd = [];
-        var pgd = [];
-        this.renderer._smoothedData = [];
-        this.renderer._smoothedPlotData = [];
-        this.renderer._hiBandGridData = [];
-        this.renderer._lowBandGridData = [];
-        this.renderer._hiBandSmoothedData = [];
-        this.renderer._lowBandSmoothedData = [];
-        var bands = this.renderer.bands;
-        var hasNull = false;
-        for (var i=0; i<data.length; i++) {
-            // if not a line series or if no nulls in data, push the converted point onto the array.
-            if (data[i][0] != null && data[i][1] != null) {
-                gd.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1])]);
-            }
-            // else if there is a null, preserve it.
-            else if (data[i][0] == null) {
-                hasNull = true;
-                gd.push([null, yp.call(this._yaxis, data[i][1])]);
-            }
-            else if (data[i][1] == null) {
-                hasNull = true;
-                gd.push([xp.call(this._xaxis, data[i][0]), null]);
-            }
-        }
-
-        // don't do smoothing or bands on broken lines.
-        if (hasNull) {
-            this.renderer.smooth = false;
-            if (this._type === 'line') {
-                bands.show = false;
-            }
-        }
-
-        if (this._type === 'line' && bands.show) {
-            for (var i=0, l=bands.hiData.length; i<l; i++) {
-                this.renderer._hiBandGridData.push([xp.call(this._xaxis, bands.hiData[i][0]), yp.call(this._yaxis, bands.hiData[i][1])]);
-            }
-            for (var i=0, l=bands.lowData.length; i<l; i++) {
-                this.renderer._lowBandGridData.push([xp.call(this._xaxis, bands.lowData[i][0]), yp.call(this._yaxis, bands.lowData[i][1])]);
-            }
-        }
-
-        if (this._type === 'line' && this.renderer.smooth && gd.length > 2) {
-            var ret;
-            if (this.renderer.constrainSmoothing) {
-                ret = computeConstrainedSmoothedData.call(this, gd);
-                this.renderer._smoothedData = ret[0];
-                this.renderer._smoothedPlotData = ret[1];
-
-                if (bands.show) {
-                    ret = computeConstrainedSmoothedData.call(this, this.renderer._hiBandGridData);
-                    this.renderer._hiBandSmoothedData = ret[0];
-                    ret = computeConstrainedSmoothedData.call(this, this.renderer._lowBandGridData);
-                    this.renderer._lowBandSmoothedData = ret[0];
-                }
-
-                ret = null;
-            }
-            else {
-                ret = computeHermiteSmoothedData.call(this, gd);
-                this.renderer._smoothedData = ret[0];
-                this.renderer._smoothedPlotData = ret[1];
-
-                if (bands.show) {
-                    ret = computeHermiteSmoothedData.call(this, this.renderer._hiBandGridData);
-                    this.renderer._hiBandSmoothedData = ret[0];
-                    ret = computeHermiteSmoothedData.call(this, this.renderer._lowBandGridData);
-                    this.renderer._lowBandSmoothedData = ret[0];
-                }
-
-                ret = null;
-            }
-        }
-        return gd;
-    };
-    
-
-    // called within scope of series.
-    $.jqplot.LineRenderer.prototype.draw = function(ctx, gd, options, plot) {
-        var i;
-        // get a copy of the options, so we don't modify the original object.
-        var opts = $.extend(true, {}, options);
-        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
-        var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
-        var fill = (opts.fill != undefined) ? opts.fill : this.fill;
-        var fillAndStroke = (opts.fillAndStroke != undefined) ? opts.fillAndStroke : this.fillAndStroke;
-        var xmin, ymin, xmax, ymax;
-        ctx.save();
-        if (gd.length) {
-            if (showLine) {
-                // if we fill, we'll have to add points to close the curve.
-                if (fill) {
-                    if (this.fillToZero) { 
-                        // have to break line up into shapes at axis crossings
-                        var negativeColor = this.negativeColor;
-                        if (! this.useNegativeColors) {
-                            negativeColor = opts.fillStyle;
-                        }
-                        var isnegative = false;
-                        var posfs = opts.fillStyle;
-                    
-                        // if stoking line as well as filling, get a copy of line data.
-                        if (fillAndStroke) {
-                            var fasgd = gd.slice(0);
-                        }
-                        // if not stacked, fill down to axis
-                        if (this.index == 0 || !this._stack) {
-                        
-                            var tempgd = [];
-                            var pd = (this.renderer.smooth) ? this.renderer._smoothedPlotData : this._plotData;
-                            this._areaPoints = [];
-                            var pyzero = this._yaxis.series_u2p(this.fillToValue);
-                            var pxzero = this._xaxis.series_u2p(this.fillToValue);
-
-                            opts.closePath = true;
-                            
-                            if (this.fillAxis == 'y') {
-                                tempgd.push([gd[0][0], pyzero]);
-                                this._areaPoints.push([gd[0][0], pyzero]);
-                                
-                                for (var i=0; i<gd.length-1; i++) {
-                                    tempgd.push(gd[i]);
-                                    this._areaPoints.push(gd[i]);
-                                    // do we have an axis crossing?
-                                    if (pd[i][1] * pd[i+1][1] < 0) {
-                                        if (pd[i][1] < 0) {
-                                            isnegative = true;
-                                            opts.fillStyle = negativeColor;
-                                        }
-                                        else {
-                                            isnegative = false;
-                                            opts.fillStyle = posfs;
-                                        }
-                                        
-                                        var xintercept = gd[i][0] + (gd[i+1][0] - gd[i][0]) * (pyzero-gd[i][1])/(gd[i+1][1] - gd[i][1]);
-                                        tempgd.push([xintercept, pyzero]);
-                                        this._areaPoints.push([xintercept, pyzero]);
-                                        // now draw this shape and shadow.
-                                        if (shadow) {
-                                            this.renderer.shadowRenderer.draw(ctx, tempgd, opts);
-                                        }
-                                        this.renderer.shapeRenderer.draw(ctx, tempgd, opts);
-                                        // now empty temp array and continue
-                                        tempgd = [[xintercept, pyzero]];
-                                        // this._areaPoints = [[xintercept, pyzero]];
-                                    }   
-                                }
-                                if (pd[gd.length-1][1] < 0) {
-                                    isnegative = true;
-                                    opts.fillStyle = negativeColor;
-                                }
-                                else {
-                                    isnegative = false;
-                                    opts.fillStyle = posfs;
-                                }
-                                tempgd.push(gd[gd.length-1]);
-                                this._areaPoints.push(gd[gd.length-1]);
-                                tempgd.push([gd[gd.length-1][0], pyzero]); 
-                                this._areaPoints.push([gd[gd.length-1][0], pyzero]); 
-                            }
-                            // now draw the last area.
-                            if (shadow) {
-                                this.renderer.shadowRenderer.draw(ctx, tempgd, opts);
-                            }
-                            this.renderer.shapeRenderer.draw(ctx, tempgd, opts);
-                            
-                            
-                            // var gridymin = this._yaxis.series_u2p(0);
-                            // // IE doesn't return new length on unshift
-                            // gd.unshift([gd[0][0], gridymin]);
-                            // len = gd.length;
-                            // gd.push([gd[len - 1][0], gridymin]);                   
-                        }
-                        // if stacked, fill to line below 
-                        else {
-                            var prev = this._prevGridData;
-                            for (var i=prev.length; i>0; i--) {
-                                gd.push(prev[i-1]);
-                                // this._areaPoints.push(prev[i-1]);
-                            }
-                            if (shadow) {
-                                this.renderer.shadowRenderer.draw(ctx, gd, opts);
-                            }
-                            this._areaPoints = gd;
-                            this.renderer.shapeRenderer.draw(ctx, gd, opts);
-                        }
-                    }
-                    /////////////////////////
-                    // Not filled to zero
-                    ////////////////////////
-                    else {                    
-                        // if stoking line as well as filling, get a copy of line data.
-                        if (fillAndStroke) {
-                            var fasgd = gd.slice(0);
-                        }
-                        // if not stacked, fill down to axis
-                        if (this.index == 0 || !this._stack) {
-                            // var gridymin = this._yaxis.series_u2p(this._yaxis.min) - this.gridBorderWidth / 2;
-                            var gridymin = ctx.canvas.height;
-                            // IE doesn't return new length on unshift
-                            gd.unshift([gd[0][0], gridymin]);
-                            var len = gd.length;
-                            gd.push([gd[len - 1][0], gridymin]);                   
-                        }
-                        // if stacked, fill to line below 
-                        else {
-                            var prev = this._prevGridData;
-                            for (var i=prev.length; i>0; i--) {
-                                gd.push(prev[i-1]);
-                            }
-                        }
-                        this._areaPoints = gd;
-                        
-                        if (shadow) {
-                            this.renderer.shadowRenderer.draw(ctx, gd, opts);
-                        }
-            
-                        this.renderer.shapeRenderer.draw(ctx, gd, opts);                        
-                    }
-                    if (fillAndStroke) {
-                        var fasopts = $.extend(true, {}, opts, {fill:false, closePath:false});
-                        this.renderer.shapeRenderer.draw(ctx, fasgd, fasopts);
-                        //////////
-                        // TODO: figure out some way to do shadows nicely
-                        // if (shadow) {
-                        //     this.renderer.shadowRenderer.draw(ctx, fasgd, fasopts);
-                        // }
-                        // now draw the markers
-                        if (this.markerRenderer.show) {
-                            if (this.renderer.smooth) {
-                                fasgd = this.gridData;
-                            }
-                            for (i=0; i<fasgd.length; i++) {
-                                this.markerRenderer.draw(fasgd[i][0], fasgd[i][1], ctx, opts.markerOptions);
-                            }
-                        }
-                    }
-                }
-                else {
-
-                    if (this.renderer.bands.show) {
-                        var bdat;
-                        var bopts = $.extend(true, {}, opts);
-                        if (this.renderer.bands.showLines) {
-                            bdat = (this.renderer.smooth) ? this.renderer._hiBandSmoothedData : this.renderer._hiBandGridData;
-                            this.renderer.shapeRenderer.draw(ctx, bdat, opts);
-                            bdat = (this.renderer.smooth) ? this.renderer._lowBandSmoothedData : this.renderer._lowBandGridData;
-                            this.renderer.shapeRenderer.draw(ctx, bdat, bopts);
-                        }
-
-                        if (this.renderer.bands.fill) {
-                            if (this.renderer.smooth) {
-                                bdat = this.renderer._hiBandSmoothedData.concat(this.renderer._lowBandSmoothedData.reverse());
-                            }
-                            else {
-                                bdat = this.renderer._hiBandGridData.concat(this.renderer._lowBandGridData.reverse());
-                            }
-                            this._areaPoints = bdat;
-                            bopts.closePath = true;
-                            bopts.fill = true;
-                            bopts.fillStyle = this.renderer.bands.fillColor;
-                            this.renderer.shapeRenderer.draw(ctx, bdat, bopts);
-                        }
-                    }
-
-                    if (shadow) {
-                        this.renderer.shadowRenderer.draw(ctx, gd, opts);
-                    }
-    
-                    this.renderer.shapeRenderer.draw(ctx, gd, opts);
-                }
-            }
-            // calculate the bounding box
-            var xmin = xmax = ymin = ymax = null;
-            for (i=0; i<this._areaPoints.length; i++) {
-                var p = this._areaPoints[i];
-                if (xmin > p[0] || xmin == null) {
-                    xmin = p[0];
-                }
-                if (ymax < p[1] || ymax == null) {
-                    ymax = p[1];
-                }
-                if (xmax < p[0] || xmax == null) {
-                    xmax = p[0];
-                }
-                if (ymin > p[1] || ymin == null) {
-                    ymin = p[1];
-                }
-            }
-
-            if (this.type === 'line' && this.renderer.bands.show) {
-                ymax = this._yaxis.series_u2p(this.renderer.bands._min);
-                ymin = this._yaxis.series_u2p(this.renderer.bands._max);
-            }
-
-            this._boundingBox = [[xmin, ymax], [xmax, ymin]];
-        
-            // now draw the markers
-            if (this.markerRenderer.show && !fill) {
-                if (this.renderer.smooth) {
-                    gd = this.gridData;
-                }
-                for (i=0; i<gd.length; i++) {
-                    if (gd[i][0] != null && gd[i][1] != null) {
-                        this.markerRenderer.draw(gd[i][0], gd[i][1], ctx, opts.markerOptions);
-                    }
-                }
-            }
-        }
-        
-        ctx.restore();
-    };  
-    
-    $.jqplot.LineRenderer.prototype.drawShadow = function(ctx, gd, options) {
-        // This is a no-op, shadows drawn with lines.
-    };
-    
-    // called with scope of plot.
-    // make sure to not leave anything highlighted.
-    function postInit(target, data, options) {
-        for (var i=0; i<this.series.length; i++) {
-            if (this.series[i].renderer.constructor == $.jqplot.LineRenderer) {
-                // don't allow mouseover and mousedown at same time.
-                if (this.series[i].highlightMouseOver) {
-                    this.series[i].highlightMouseDown = false;
-                }
-            }
-        }
-    }  
-    
-    // called within context of plot
-    // create a canvas which we can draw on.
-    // insert it before the eventCanvas, so eventCanvas will still capture events.
-    function postPlotDraw() {
-        // Memory Leaks patch    
-        if (this.plugins.lineRenderer && this.plugins.lineRenderer.highlightCanvas) {
-          this.plugins.lineRenderer.highlightCanvas.resetCanvas();
-          this.plugins.lineRenderer.highlightCanvas = null;
-        }
-        
-        this.plugins.lineRenderer.highlightedSeriesIndex = null;
-        this.plugins.lineRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
-        
-        this.eventCanvas._elem.before(this.plugins.lineRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-lineRenderer-highlight-canvas', this._plotDimensions, this));
-        this.plugins.lineRenderer.highlightCanvas.setContext();
-        this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
-    } 
-    
-    function highlight (plot, sidx, pidx, points) {
-        var s = plot.series[sidx];
-        var canvas = plot.plugins.lineRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        s._highlightedPoint = pidx;
-        plot.plugins.lineRenderer.highlightedSeriesIndex = sidx;
-        var opts = {fillStyle: s.highlightColor};
-        if (s.type === 'line' && s.renderer.bands.show) {
-            opts.fill = true;
-            opts.closePath = true;
-        }
-        s.renderer.shapeRenderer.draw(canvas._ctx, points, opts);
-        canvas = null;
-    }
-    
-    function unhighlight (plot) {
-        var canvas = plot.plugins.lineRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        for (var i=0; i<plot.series.length; i++) {
-            plot.series[i]._highlightedPoint = null;
-        }
-        plot.plugins.lineRenderer.highlightedSeriesIndex = null;
-        plot.target.trigger('jqplotDataUnhighlight');
-        canvas = null;
-    }
-    
-    
-    function handleMove(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt1 = jQuery.Event('jqplotDataMouseOver');
-            evt1.pageX = ev.pageX;
-            evt1.pageY = ev.pageY;
-            plot.target.trigger(evt1, ins);
-            if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.lineRenderer.highlightedSeriesIndex)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    }
-    
-    function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.lineRenderer.highlightedSeriesIndex)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    }
-    
-    function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
-        var idx = plot.plugins.lineRenderer.highlightedSeriesIndex;
-        if (idx != null && plot.series[idx].highlightMouseDown) {
-            unhighlight(plot);
-        }
-    }
-    
-    function handleClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt = jQuery.Event('jqplotDataClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }
-    
-    function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var idx = plot.plugins.lineRenderer.highlightedSeriesIndex;
-            if (idx != null && plot.series[idx].highlightMouseDown) {
-                unhighlight(plot);
-            }
-            var evt = jQuery.Event('jqplotDataRightClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }
-    
-    
-    // class: $.jqplot.LinearAxisRenderer
-    // The default jqPlot axis renderer, creating a numeric axis.
-    $.jqplot.LinearAxisRenderer = function() {
-    };
-    
-    // called with scope of axis object.
-    $.jqplot.LinearAxisRenderer.prototype.init = function(options){
-        // prop: breakPoints
-        // EXPERIMENTAL!! Use at your own risk!
-        // Works only with linear axes and the default tick renderer.
-        // Array of [start, stop] points to create a broken axis.
-        // Broken axes have a "jump" in them, which is an immediate 
-        // transition from a smaller value to a larger value.
-        // Currently, axis ticks MUST be manually assigned if using breakPoints
-        // by using the axis ticks array option.
-        this.breakPoints = null;
-        // prop: breakTickLabel
-        // Label to use at the axis break if breakPoints are specified.
-        this.breakTickLabel = "&asymp;";
-        // prop: drawBaseline
-        // True to draw the axis baseline.
-        this.drawBaseline = true;
-        // prop: baselineWidth
-        // width of the baseline in pixels.
-        this.baselineWidth = null;
-        // prop: baselineColor
-        // CSS color spec for the baseline.
-        this.baselineColor = null;
-        // prop: forceTickAt0
-        // This will ensure that there is always a tick mark at 0.
-        // If data range is strictly positive or negative,
-        // this will force 0 to be inside the axis bounds unless
-        // the appropriate axis pad (pad, padMin or padMax) is set
-        // to 0, then this will force an axis min or max value at 0.
-        // This has know effect when any of the following options
-        // are set:  autoscale, min, max, numberTicks or tickInterval.
-        this.forceTickAt0 = false;
-        // prop: forceTickAt100
-        // This will ensure that there is always a tick mark at 100.
-        // If data range is strictly above or below 100,
-        // this will force 100 to be inside the axis bounds unless
-        // the appropriate axis pad (pad, padMin or padMax) is set
-        // to 0, then this will force an axis min or max value at 100.
-        // This has know effect when any of the following options
-        // are set:  autoscale, min, max, numberTicks or tickInterval.
-        this.forceTickAt100 = false;
-        // prop: tickInset
-        // Controls the amount to inset the first and last ticks from 
-        // the edges of the grid, in multiples of the tick interval.
-        // 0 is no inset, 0.5 is one half a tick interval, 1 is a full
-        // tick interval, etc.
-        this.tickInset = 0;
-        // prop: minorTicks
-        // Number of ticks to add between "major" ticks.
-        // Major ticks are ticks supplied by user or auto computed.
-        // Minor ticks cannot be created by user.
-        this.minorTicks = 0;
-        this.alignTicks = false;
-        this._autoFormatString = '';
-        this._overrideFormatString = false;
-        this._scalefact = 1.0;
-        $.extend(true, this, options);
-        if (this.breakPoints) {
-            if (!$.isArray(this.breakPoints)) {
-                this.breakPoints = null;
-            }
-            else if (this.breakPoints.length < 2 || this.breakPoints[1] <= this.breakPoints[0]) {
-                this.breakPoints = null;
-            }
-        }
-        if (this.numberTicks != null && this.numberTicks < 2) {
-            this.numberTicks = 2;
-        }
-        this.resetDataBounds();
-    };
-    
-    // called with scope of axis
-    $.jqplot.LinearAxisRenderer.prototype.draw = function(ctx, plot) {
-        if (this.show) {
-            // populate the axis label and value properties.
-            // createTicks is a method on the renderer, but
-            // call it within the scope of the axis.
-            this.renderer.createTicks.call(this, plot);
-            // fill a div with axes labels in the right direction.
-            // Need to pregenerate each axis to get it's bounds and
-            // position it and the labels correctly on the plot.
-            var dim=0;
-            var temp;
-            // Added for theming.
-            if (this._elem) {
-                // Memory Leaks patch
-                //this._elem.empty();
-                this._elem.emptyForce();
-                this._elem = null;
-            }
-            
-            this._elem = $(document.createElement('div'));
-            this._elem.addClass('jqplot-axis jqplot-'+this.name);
-            this._elem.css('position', 'absolute');
-
-            
-            if (this.name == 'xaxis' || this.name == 'x2axis') {
-                this._elem.width(this._plotDimensions.width);
-            }
-            else {
-                this._elem.height(this._plotDimensions.height);
-            }
-            
-            // create a _label object.
-            this.labelOptions.axis = this.name;
-            this._label = new this.labelRenderer(this.labelOptions);
-            if (this._label.show) {
-                var elem = this._label.draw(ctx, plot);
-                elem.appendTo(this._elem);
-                elem = null;
-            }
-    
-            var t = this._ticks;
-            var tick;
-            for (var i=0; i<t.length; i++) {
-                tick = t[i];
-                if (tick.show && tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
-                    this._elem.append(tick.draw(ctx, plot));
-                }
-            }
-            tick = null;
-            t = null;
-        }
-        return this._elem;
-    };
-    
-    // called with scope of an axis
-    $.jqplot.LinearAxisRenderer.prototype.reset = function() {
-        this.min = this._options.min;
-        this.max = this._options.max;
-        this.tickInterval = this._options.tickInterval;
-        this.numberTicks = this._options.numberTicks;
-        this._autoFormatString = '';
-        if (this._overrideFormatString && this.tickOptions && this.tickOptions.formatString) {
-            this.tickOptions.formatString = '';
-        }
-
-        // this._ticks = this.__ticks;
-    };
-    
-    // called with scope of axis
-    $.jqplot.LinearAxisRenderer.prototype.set = function() { 
-        var dim = 0;
-        var temp;
-        var w = 0;
-        var h = 0;
-        var lshow = (this._label == null) ? false : this._label.show;
-        if (this.show) {
-            var t = this._ticks;
-            var tick;
-            for (var i=0; i<t.length; i++) {
-                tick = t[i];
-                if (!tick._breakTick && tick.show && tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
-                    if (this.name == 'xaxis' || this.name == 'x2axis') {
-                        temp = tick._elem.outerHeight(true);
-                    }
-                    else {
-                        temp = tick._elem.outerWidth(true);
-                    }
-                    if (temp > dim) {
-                        dim = temp;
-                    }
-                }
-            }
-            tick = null;
-            t = null;
-            
-            if (lshow) {
-                w = this._label._elem.outerWidth(true);
-                h = this._label._elem.outerHeight(true); 
-            }
-            if (this.name == 'xaxis') {
-                dim = dim + h;
-                this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'});
-            }
-            else if (this.name == 'x2axis') {
-                dim = dim + h;
-                this._elem.css({'height':dim+'px', left:'0px', top:'0px'});
-            }
-            else if (this.name == 'yaxis') {
-                dim = dim + w;
-                this._elem.css({'width':dim+'px', left:'0px', top:'0px'});
-                if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
-                    this._label._elem.css('width', w+'px');
-                }
-            }
-            else {
-                dim = dim + w;
-                this._elem.css({'width':dim+'px', right:'0px', top:'0px'});
-                if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
-                    this._label._elem.css('width', w+'px');
-                }
-            }
-        }  
-    };    
-    
-    // called with scope of axis
-    $.jqplot.LinearAxisRenderer.prototype.createTicks = function(plot) {
-        // we're are operating on an axis here
-        var ticks = this._ticks;
-        var userTicks = this.ticks;
-        var name = this.name;
-        // databounds were set on axis initialization.
-        var db = this._dataBounds;
-        var dim, interval;
-        var min, max;
-        var pos1, pos2;
-        var tt, i;
-        // get a copy of user's settings for min/max.
-        var userMin = this.min;
-        var userMax = this.max;
-        var userNT = this.numberTicks;
-        var userTI = this.tickInterval;
-        
-        // if we already have ticks, use them.
-        // ticks must be in order of increasing value.
-        
-        if (userTicks.length) {
-            // ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed
-            for (i=0; i<userTicks.length; i++){
-                var ut = userTicks[i];
-                var t = new this.tickRenderer(this.tickOptions);
-                if ($.isArray(ut)) {
-                    t.value = ut[0];
-                    if (this.breakPoints) {
-                        if (ut[0] == this.breakPoints[0]) {
-                            t.label = this.breakTickLabel;
-                            t._breakTick = true;
-                            t.showGridline = false;
-                            t.showMark = false;
-                        }
-                        else if (ut[0] > this.breakPoints[0] && ut[0] <= this.breakPoints[1]) {
-                            t.show = false;
-                            t.showGridline = false;
-                            t.label = ut[1];
-                        }
-                        else {
-                            t.label = ut[1];
-                        }
-                    }
-                    else {
-                        t.label = ut[1];
-                    }
-                    t.setTick(ut[0], this.name);
-                    this._ticks.push(t);
-                }
-
-                else if ($.isPlainObject(ut)) {
-                    $.extend(true, t, ut);
-                    t.axis = this.name;
-                    this._ticks.push(t);
-                }
-                
-                else {
-                    t.value = ut;
-                    if (this.breakPoints) {
-                        if (ut == this.breakPoints[0]) {
-                            t.label = this.breakTickLabel;
-                            t._breakTick = true;
-                            t.showGridline = false;
-                            t.showMark = false;
-                        }
-                        else if (ut > this.breakPoints[0] && ut <= this.breakPoints[1]) {
-                            t.show = false;
-                            t.showGridline = false;
-                        }
-                    }
-                    t.setTick(ut, this.name);
-                    this._ticks.push(t);
-                }
-            }
-            this.numberTicks = userTicks.length;
-            this.min = this._ticks[0].value;
-            this.max = this._ticks[this.numberTicks-1].value;
-            this.tickInterval = (this.max - this.min) / (this.numberTicks - 1);
-        }
-        
-        // we don't have any ticks yet, let's make some!
-        else {
-            if (name == 'xaxis' || name == 'x2axis') {
-                dim = this._plotDimensions.width;
-            }
-            else {
-                dim = this._plotDimensions.height;
-            }
-
-            var _numberTicks = this.numberTicks;
-
-            // if aligning this axis, use number of ticks from previous axis.
-            // Do I need to reset somehow if alignTicks is changed and then graph is replotted??
-            if (this.alignTicks) {
-                if (this.name === 'x2axis' && plot.axes.xaxis.show) {
-                    _numberTicks = plot.axes.xaxis.numberTicks;
-                }
-                else if (this.name.charAt(0) === 'y' && this.name !== 'yaxis' && this.name !== 'yMidAxis' && plot.axes.yaxis.show) {
-                    _numberTicks = plot.axes.yaxis.numberTicks;
-                }
-            }
-            
-            // // if min, max and number of ticks specified, user can't specify interval.
-            // if (!this.autoscale && this.min != null && this.max != null && this.numberTicks != null) {
-            //     console.log('doing this');
-            //     this.tickInterval = null;
-            // }
-            
-            // if max, min, and interval specified and interval won't fit, ignore interval.
-            // if (this.min != null && this.max != null && this.tickInterval != null) {
-            //     if (parseInt((this.max-this.min)/this.tickInterval, 10) != (this.max-this.min)/this.tickInterval) {
-            //         this.tickInterval = null;
-            //     }
-            // }
-        
-            min = ((this.min != null) ? this.min : db.min);
-            max = ((this.max != null) ? this.max : db.max);
-
-            var range = max - min;
-            var rmin, rmax;
-            var temp;
-
-            if (this.tickOptions == null || !this.tickOptions.formatString) {
-                this._overrideFormatString = true;
-            }
-
-            // Doing complete autoscaling
-            if (this.min == null && this.max == null && this.tickInterval == null && !this.autoscale) {
-                // Check if user must have tick at 0 or 100 and ensure they are in range.
-                // The autoscaling algorithm will always place ticks at 0 and 100 if they are in range.
-                if (this.forceTickAt0) {
-                    if (min > 0) {
-                        min = 0;
-                    }
-                    if (max < 0) {
-                        max = 0;
-                    }
-                }
-
-                if (this.forceTickAt100) {
-                    if (min > 100) {
-                        min = 100;
-                    }
-                    if (max < 100) {
-                        max = 100;
-                    }
-                }
-
-                var threshold = 30;
-                var tdim = Math.max(dim, threshold+1);
-                this._scalefact =  (tdim-threshold)/300.0;
-                var ret = $.jqplot.LinearTickGenerator(min, max, this._scalefact, _numberTicks); 
-                // calculate a padded max and min, points should be less than these
-                // so that they aren't too close to the edges of the plot.
-                // User can adjust how much padding is allowed with pad, padMin and PadMax options. 
-                var tumin = min + range*(this.padMin - 1);
-                var tumax = max - range*(this.padMax - 1);
-
-                // if they're equal, we shouldn't have to do anything, right?
-                // if (min <=tumin || max >= tumax) {
-                if (min <tumin || max > tumax) {
-                    tumin = min - range*(this.padMin - 1);
-                    tumax = max + range*(this.padMax - 1);
-                    ret = $.jqplot.LinearTickGenerator(tumin, tumax, this._scalefact, _numberTicks);
-                }
-
-                this.min = ret[0];
-                this.max = ret[1];
-                // if numberTicks specified, it should return the same.
-                this.numberTicks = ret[2];
-                this._autoFormatString = ret[3];
-                this.tickInterval = ret[4];
-            }
-
-            // User has specified some axis scale related option, can use auto algorithm
-            else {
-                
-                // if min and max are same, space them out a bit
-                if (min == max) {
-                    var adj = 0.05;
-                    if (min > 0) {
-                        adj = Math.max(Math.log(min)/Math.LN10, 0.05);
-                    }
-                    min -= adj;
-                    max += adj;
-                }
-                
-                // autoscale.  Can't autoscale if min or max is supplied.
-                // Will use numberTicks and tickInterval if supplied.  Ticks
-                // across multiple axes may not line up depending on how
-                // bars are to be plotted.
-                if (this.autoscale && this.min == null && this.max == null) {
-                    var rrange, ti, margin;
-                    var forceMinZero = false;
-                    var forceZeroLine = false;
-                    var intervals = {min:null, max:null, average:null, stddev:null};
-                    // if any series are bars, or if any are fill to zero, and if this
-                    // is the axis to fill toward, check to see if we can start axis at zero.
-                    for (var i=0; i<this._series.length; i++) {
-                        var s = this._series[i];
-                        var faname = (s.fillAxis == 'x') ? s._xaxis.name : s._yaxis.name;
-                        // check to see if this is the fill axis
-                        if (this.name == faname) {
-                            var vals = s._plotValues[s.fillAxis];
-                            var vmin = vals[0];
-                            var vmax = vals[0];
-                            for (var j=1; j<vals.length; j++) {
-                                if (vals[j] < vmin) {
-                                    vmin = vals[j];
-                                }
-                                else if (vals[j] > vmax) {
-                                    vmax = vals[j];
-                                }
-                            }
-                            var dp = (vmax - vmin) / vmax;
-                            // is this sries a bar?
-                            if (s.renderer.constructor == $.jqplot.BarRenderer) {
-                                // if no negative values and could also check range.
-                                if (vmin >= 0 && (s.fillToZero || dp > 0.1)) {
-                                    forceMinZero = true;
-                                }
-                                else {
-                                    forceMinZero = false;
-                                    if (s.fill && s.fillToZero && vmin < 0 && vmax > 0) {
-                                        forceZeroLine = true;
-                                    }
-                                    else {
-                                        forceZeroLine = false;
-                                    }
-                                }
-                            }
-                            
-                            // if not a bar and filling, use appropriate method.
-                            else if (s.fill) {
-                                if (vmin >= 0 && (s.fillToZero || dp > 0.1)) {
-                                    forceMinZero = true;
-                                }
-                                else if (vmin < 0 && vmax > 0 && s.fillToZero) {
-                                    forceMinZero = false;
-                                    forceZeroLine = true;
-                                }
-                                else {
-                                    forceMinZero = false;
-                                    forceZeroLine = false;
-                                }
-                            }
-                            
-                            // if not a bar and not filling, only change existing state
-                            // if it doesn't make sense
-                            else if (vmin < 0) {
-                                forceMinZero = false;
-                            }
-                        }
-                    }
-                    
-                    // check if we need make axis min at 0.
-                    if (forceMinZero) {
-                        // compute number of ticks
-                        this.numberTicks = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing);
-                        this.min = 0;
-                        userMin = 0;
-                        // what order is this range?
-                        // what tick interval does that give us?
-                        ti = max/(this.numberTicks-1);
-                        temp = Math.pow(10, Math.abs(Math.floor(Math.log(ti)/Math.LN10)));
-                        if (ti/temp == parseInt(ti/temp, 10)) {
-                            ti += temp;
-                        }
-                        this.tickInterval = Math.ceil(ti/temp) * temp;
-                        this.max = this.tickInterval * (this.numberTicks - 1);
-                    }
-                    
-                    // check if we need to make sure there is a tick at 0.
-                    else if (forceZeroLine) {
-                        // compute number of ticks
-                        this.numberTicks = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing);
-                        var ntmin = Math.ceil(Math.abs(min)/range*(this.numberTicks-1));
-                        var ntmax = this.numberTicks - 1  - ntmin;
-                        ti = Math.max(Math.abs(min/ntmin), Math.abs(max/ntmax));
-                        temp = Math.pow(10, Math.abs(Math.floor(Math.log(ti)/Math.LN10)));
-                        this.tickInterval = Math.ceil(ti/temp) * temp;
-                        this.max = this.tickInterval * ntmax;
-                        this.min = -this.tickInterval * ntmin;
-                    }
-                    
-                    // if nothing else, do autoscaling which will try to line up ticks across axes.
-                    else {  
-                        if (this.numberTicks == null){
-                            if (this.tickInterval) {
-                                this.numberTicks = 3 + Math.ceil(range / this.tickInterval);
-                            }
-                            else {
-                                this.numberTicks = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing);
-                            }
-                        }
-                
-                        if (this.tickInterval == null) {
-                            // get a tick interval
-                            ti = range/(this.numberTicks - 1);
-
-                            if (ti < 1) {
-                                temp = Math.pow(10, Math.abs(Math.floor(Math.log(ti)/Math.LN10)));
-                            }
-                            else {
-                                temp = 1;
-                            }
-                            this.tickInterval = Math.ceil(ti*temp*this.pad)/temp;
-                        }
-                        else {
-                            temp = 1 / this.tickInterval;
-                        }
-                        
-                        // try to compute a nicer, more even tick interval
-                        // temp = Math.pow(10, Math.floor(Math.log(ti)/Math.LN10));
-                        // this.tickInterval = Math.ceil(ti/temp) * temp;
-                        rrange = this.tickInterval * (this.numberTicks - 1);
-                        margin = (rrange - range)/2;
-           
-                        if (this.min == null) {
-                            this.min = Math.floor(temp*(min-margin))/temp;
-                        }
-                        if (this.max == null) {
-                            this.max = this.min + rrange;
-                        }
-                    }
-
-                    // Compute a somewhat decent format string if it is needed.
-                    // get precision of interval and determine a format string.
-                    var sf = $.jqplot.getSignificantFigures(this.tickInterval);
-
-                    var fstr;
-
-                    // if we have only a whole number, use integer formatting
-                    if (sf.digitsLeft >= sf.significantDigits) {
-                        fstr = '%d';
-                    }
-
-                    else {
-                        var temp = Math.max(0, 5 - sf.digitsLeft);
-                        temp = Math.min(temp, sf.digitsRight);
-                        fstr = '%.'+ temp + 'f';
-                    }
-
-                    this._autoFormatString = fstr;
-                }
-                
-                // Use the default algorithm which pads each axis to make the chart
-                // centered nicely on the grid.
-                else {
-
-                    rmin = (this.min != null) ? this.min : min - range*(this.padMin - 1);
-                    rmax = (this.max != null) ? this.max : max + range*(this.padMax - 1);
-                    range = rmax - rmin;
-        
-                    if (this.numberTicks == null){
-                        // if tickInterval is specified by user, we will ignore computed maximum.
-                        // max will be equal or greater to fit even # of ticks.
-                        if (this.tickInterval != null) {
-                            this.numberTicks = Math.ceil((rmax - rmin)/this.tickInterval)+1;
-                        }
-                        else if (dim > 100) {
-                            this.numberTicks = parseInt(3+(dim-100)/75, 10);
-                        }
-                        else {
-                            this.numberTicks = 2;
-                        }
-                    }
-                
-                    if (this.tickInterval == null) {
-                        this.tickInterval = range / (this.numberTicks-1);
-                    }
-                    
-                    if (this.max == null) {
-                        rmax = rmin + this.tickInterval*(this.numberTicks - 1);
-                    }        
-                    if (this.min == null) {
-                        rmin = rmax - this.tickInterval*(this.numberTicks - 1);
-                    }
-
-                    // get precision of interval and determine a format string.
-                    var sf = $.jqplot.getSignificantFigures(this.tickInterval);
-
-                    var fstr;
-
-                    // if we have only a whole number, use integer formatting
-                    if (sf.digitsLeft >= sf.significantDigits) {
-                        fstr = '%d';
-                    }
-
-                    else {
-                        var temp = Math.max(0, 5 - sf.digitsLeft);
-                        temp = Math.min(temp, sf.digitsRight);
-                        fstr = '%.'+ temp + 'f';
-                    }
-
-
-                    this._autoFormatString = fstr;
-
-                    this.min = rmin;
-                    this.max = rmax;
-                }
-                
-                if (this.renderer.constructor == $.jqplot.LinearAxisRenderer && this._autoFormatString == '') {
-                    // fix for misleading tick display with small range and low precision.
-                    range = this.max - this.min;
-                    // figure out precision
-                    var temptick = new this.tickRenderer(this.tickOptions);
-                    // use the tick formatString or, the default.
-                    var fs = temptick.formatString || $.jqplot.config.defaultTickFormatString; 
-                    var fs = fs.match($.jqplot.sprintf.regex)[0];
-                    var precision = 0;
-                    if (fs) {
-                        if (fs.search(/[fFeEgGpP]/) > -1) {
-                            var m = fs.match(/\%\.(\d{0,})?[eEfFgGpP]/);
-                            if (m) {
-                                precision = parseInt(m[1], 10);
-                            }
-                            else {
-                                precision = 6;
-                            }
-                        }
-                        else if (fs.search(/[di]/) > -1) {
-                            precision = 0;
-                        }
-                        // fact will be <= 1;
-                        var fact = Math.pow(10, -precision);
-                        if (this.tickInterval < fact) {
-                            // need to correct underrange
-                            if (userNT == null && userTI == null) {
-                                this.tickInterval = fact;
-                                if (userMax == null && userMin == null) {
-                                    // this.min = Math.floor((this._dataBounds.min - this.tickInterval)/fact) * fact;
-                                    this.min = Math.floor(this._dataBounds.min/fact) * fact;
-                                    if (this.min == this._dataBounds.min) {
-                                        this.min = this._dataBounds.min - this.tickInterval;
-                                    }
-                                    // this.max = Math.ceil((this._dataBounds.max + this.tickInterval)/fact) * fact;
-                                    this.max = Math.ceil(this._dataBounds.max/fact) * fact;
-                                    if (this.max == this._dataBounds.max) {
-                                        this.max = this._dataBounds.max + this.tickInterval;
-                                    }
-                                    var n = (this.max - this.min)/this.tickInterval;
-                                    n = n.toFixed(11);
-                                    n = Math.ceil(n);
-                                    this.numberTicks = n + 1;
-                                }
-                                else if (userMax == null) {
-                                    // add one tick for top of range.
-                                    var n = (this._dataBounds.max - this.min) / this.tickInterval;
-                                    n = n.toFixed(11);
-                                    this.numberTicks = Math.ceil(n) + 2;
-                                    this.max = this.min + this.tickInterval * (this.numberTicks-1);
-                                }
-                                else if (userMin == null) {
-                                    // add one tick for bottom of range.
-                                    var n = (this.max - this._dataBounds.min) / this.tickInterval;
-                                    n = n.toFixed(11);
-                                    this.numberTicks = Math.ceil(n) + 2;
-                                    this.min = this.max - this.tickInterval * (this.numberTicks-1);
-                                }
-                                else {
-                                    // calculate a number of ticks so max is within axis scale
-                                    this.numberTicks = Math.ceil((userMax - userMin)/this.tickInterval) + 1;
-                                    // if user's min and max don't fit evenly in ticks, adjust.
-                                    // This takes care of cases such as user min set to 0, max set to 3.5 but tick
-                                    // format string set to %d (integer ticks)
-                                    this.min =  Math.floor(userMin*Math.pow(10, precision))/Math.pow(10, precision);
-                                    this.max =  Math.ceil(userMax*Math.pow(10, precision))/Math.pow(10, precision);
-                                    // this.max = this.min + this.tickInterval*(this.numberTicks-1);
-                                    this.numberTicks = Math.ceil((this.max - this.min)/this.tickInterval) + 1;
-                                }
-                            }
-                        }
-                    }
-                }
-                
-            }
-            
-            if (this._overrideFormatString && this._autoFormatString != '') {
-                this.tickOptions = this.tickOptions || {};
-                this.tickOptions.formatString = this._autoFormatString;
-            }
-
-            var t, to;
-            for (var i=0; i<this.numberTicks; i++){
-                tt = this.min + i * this.tickInterval;
-                t = new this.tickRenderer(this.tickOptions);
-                // var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
-
-                t.setTick(tt, this.name);
-                this._ticks.push(t);
-
-                if (i < this.numberTicks - 1) {
-                    for (var j=0; j<this.minorTicks; j++) {
-                        tt += this.tickInterval/(this.minorTicks+1);
-                        to = $.extend(true, {}, this.tickOptions, {name:this.name, value:tt, label:'', isMinorTick:true});
-                        t = new this.tickRenderer(to);
-                        this._ticks.push(t);
-                    }
-                }
-                t = null;
-            }
-        }
-
-        if (this.tickInset) {
-            this.min = this.min - this.tickInset * this.tickInterval;
-            this.max = this.max + this.tickInset * this.tickInterval;
-        }
-
-        ticks = null;
-    };
-    
-    // Used to reset just the values of the ticks and then repack, which will
-    // recalculate the positioning functions.  It is assuemd that the 
-    // number of ticks is the same and the values of the new array are at the
-    // proper interval.
-    // This method needs to be called with the scope of an axis object, like:
-    //
-    // > plot.axes.yaxis.renderer.resetTickValues.call(plot.axes.yaxis, yarr);
-    //
-    $.jqplot.LinearAxisRenderer.prototype.resetTickValues = function(opts) {
-        if ($.isArray(opts) && opts.length == this._ticks.length) {
-            var t;
-            for (var i=0; i<opts.length; i++) {
-                t = this._ticks[i];
-                t.value = opts[i];
-                t.label = t.formatter(t.formatString, opts[i]);
-                t.label = t.prefix + t.label;
-                t._elem.html(t.label);
-            }
-            t = null;
-            this.min = $.jqplot.arrayMin(opts);
-            this.max = $.jqplot.arrayMax(opts);
-            this.pack();
-        }
-        // Not implemented yet.
-        // else if ($.isPlainObject(opts)) {
-        // 
-        // }
-    };
-    
-    // called with scope of axis
-    $.jqplot.LinearAxisRenderer.prototype.pack = function(pos, offsets) {
-        // Add defaults for repacking from resetTickValues function.
-        pos = pos || {};
-        offsets = offsets || this._offsets;
-        
-        var ticks = this._ticks;
-        var max = this.max;
-        var min = this.min;
-        var offmax = offsets.max;
-        var offmin = offsets.min;
-        var lshow = (this._label == null) ? false : this._label.show;
-        
-        for (var p in pos) {
-            this._elem.css(p, pos[p]);
-        }
-        
-        this._offsets = offsets;
-        // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left.
-        var pixellength = offmax - offmin;
-        var unitlength = max - min;
-        
-        // point to unit and unit to point conversions references to Plot DOM element top left corner.
-        if (this.breakPoints) {
-            unitlength = unitlength - this.breakPoints[1] + this.breakPoints[0];
-            
-            this.p2u = function(p){
-                return (p - offmin) * unitlength / pixellength + min;
-            };
-        
-            this.u2p = function(u){
-                if (u > this.breakPoints[0] && u < this.breakPoints[1]){
-                    u = this.breakPoints[0];
-                }
-                if (u <= this.breakPoints[0]) {
-                    return (u - min) * pixellength / unitlength + offmin;
-                }
-                else {
-                    return (u - this.breakPoints[1] + this.breakPoints[0] - min) * pixellength / unitlength + offmin;
-                }
-            };
-                
-            if (this.name.charAt(0) == 'x'){
-                this.series_u2p = function(u){
-                    if (u > this.breakPoints[0] && u < this.breakPoints[1]){
-                        u = this.breakPoints[0];
-                    }
-                    if (u <= this.breakPoints[0]) {
-                        return (u - min) * pixellength / unitlength;
-                    }
-                    else {
-                        return (u - this.breakPoints[1] + this.breakPoints[0] - min) * pixellength / unitlength;
-                    }
-                };
-                this.series_p2u = function(p){
-                    return p * unitlength / pixellength + min;
-                };
-            }
-        
-            else {
-                this.series_u2p = function(u){
-                    if (u > this.breakPoints[0] && u < this.breakPoints[1]){
-                        u = this.breakPoints[0];
-                    }
-                    if (u >= this.breakPoints[1]) {
-                        return (u - max) * pixellength / unitlength;
-                    }
-                    else {
-                        return (u + this.breakPoints[1] - this.breakPoints[0] - max) * pixellength / unitlength;
-                    }
-                };
-                this.series_p2u = function(p){
-                    return p * unitlength / pixellength + max;
-                };
-            }
-        }
-        else {
-            this.p2u = function(p){
-                return (p - offmin) * unitlength / pixellength + min;
-            };
-        
-            this.u2p = function(u){
-                return (u - min) * pixellength / unitlength + offmin;
-            };
-                
-            if (this.name == 'xaxis' || this.name == 'x2axis'){
-                this.series_u2p = function(u){
-                    return (u - min) * pixellength / unitlength;
-                };
-                this.series_p2u = function(p){
-                    return p * unitlength / pixellength + min;
-                };
-            }
-        
-            else {
-                this.series_u2p = function(u){
-                    return (u - max) * pixellength / unitlength;
-                };
-                this.series_p2u = function(p){
-                    return p * unitlength / pixellength + max;
-                };
-            }
-        }
-        
-        if (this.show) {
-            if (this.name == 'xaxis' || this.name == 'x2axis') {
-                for (var i=0; i<ticks.length; i++) {
-                    var t = ticks[i];
-                    if (t.show && t.showLabel) {
-                        var shim;
-                        
-                        if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
-                            // will need to adjust auto positioning based on which axis this is.
-                            var temp = (this.name == 'xaxis') ? 1 : -1;
-                            switch (t.labelPosition) {
-                                case 'auto':
-                                    // position at end
-                                    if (temp * t.angle < 0) {
-                                        shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    }
-                                    // position at start
-                                    else {
-                                        shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'end':
-                                    shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                                case 'start':
-                                    shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    break;
-                                case 'middle':
-                                    shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                                default:
-                                    shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                            }
-                        }
-                        else {
-                            shim = -t.getWidth()/2;
-                        }
-                        var val = this.u2p(t.value) + shim + 'px';
-                        t._elem.css('left', val);
-                        t.pack();
-                    }
-                }
-                if (lshow) {
-                    var w = this._label._elem.outerWidth(true);
-                    this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px');
-                    if (this.name == 'xaxis') {
-                        this._label._elem.css('bottom', '0px');
-                    }
-                    else {
-                        this._label._elem.css('top', '0px');
-                    }
-                    this._label.pack();
-                }
-            }
-            else {
-                for (var i=0; i<ticks.length; i++) {
-                    var t = ticks[i];
-                    if (t.show && t.showLabel) {                        
-                        var shim;
-                        if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
-                            // will need to adjust auto positioning based on which axis this is.
-                            var temp = (this.name == 'yaxis') ? 1 : -1;
-                            switch (t.labelPosition) {
-                                case 'auto':
-                                    // position at end
-                                case 'end':
-                                    if (temp * t.angle < 0) {
-                                        shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
-                                    }
-                                    else {
-                                        shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'start':
-                                    if (t.angle > 0) {
-                                        shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
-                                    }
-                                    else {
-                                        shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'middle':
-                                    // if (t.angle > 0) {
-                                    //     shim = -t.getHeight()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    // }
-                                    // else {
-                                    //     shim = -t.getHeight()/2 - t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    // }
-                                    shim = -t.getHeight()/2;
-                                    break;
-                                default:
-                                    shim = -t.getHeight()/2;
-                                    break;
-                            }
-                        }
-                        else {
-                            shim = -t.getHeight()/2;
-                        }
-                        
-                        var val = this.u2p(t.value) + shim + 'px';
-                        t._elem.css('top', val);
-                        t.pack();
-                    }
-                }
-                if (lshow) {
-                    var h = this._label._elem.outerHeight(true);
-                    this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px');
-                    if (this.name == 'yaxis') {
-                        this._label._elem.css('left', '0px');
-                    }
-                    else {
-                        this._label._elem.css('right', '0px');
-                    }   
-                    this._label.pack();
-                }
-            }
-        }
-
-        ticks = null;
-    };
-
-
-    /**
-    * The following code was generaously given to me a while back by Scott Prahl.
-    * He did a good job at computing axes min, max and number of ticks for the 
-    * case where the user has not set any scale related parameters (tickInterval,
-    * numberTicks, min or max).  I had ignored this use case for a long time,
-    * focusing on the more difficult case where user has set some option controlling
-    * tick generation.  Anyway, about time I got this into jqPlot.
-    * Thanks Scott!!
-    */
-    
-    /**
-    * Copyright (c) 2010 Scott Prahl
-    * The next three routines are currently available for use in all personal 
-    * or commercial projects under both the MIT and GPL version 2.0 licenses. 
-    * This means that you can choose the license that best suits your project 
-    * and use it accordingly. 
-    */
-
-    // A good format string depends on the interval. If the interval is greater 
-    // than 1 then there is no need to show any decimal digits. If it is < 1.0, then
-    // use the magnitude of the interval to determine the number of digits to show.
-    function bestFormatString (interval)
-    {
-        var fstr;
-        interval = Math.abs(interval);
-        if (interval >= 10) {
-            fstr = '%d';
-        }
-
-        else if (interval > 1) {
-            if (interval === parseInt(interval)) {
-                fstr = '%d';
-            }
-            else {
-                fstr = '%.1f';
-            }
-        }
-
-        else {
-            var expv = -Math.floor(Math.log(interval)/Math.LN10);
-            fstr = '%.' + expv + 'f';
-        }
-        
-        return fstr; 
-    }
-
-    var _factors = [0.1, 0.2, 0.3, 0.4, 0.5, 0.8, 1, 2, 3, 4, 5];
-
-    var _getLowerFactor = function(f) {
-        var i = _factors.indexOf(f);
-        if (i > 0) {
-            return _factors[i-1];
-        }
-        else {
-            return _factors[_factors.length - 1] / 100;
-        }
-    };
-
-    var _getHigherFactor = function(f) {
-        var i = _factors.indexOf(f);
-        if (i < _factors.length-1) {
-            return _factors[i+1];
-        }
-        else {
-            return _factors[0] * 100;
-        }
-    };
-
-    // This will return an interval of form 2 * 10^n, 5 * 10^n or 10 * 10^n
-    // it is based soley on the range and number of ticks.  So if user specifies
-    // number of ticks, use this.
-    function bestInterval(range, numberTicks) {
-        var minimum = range / (numberTicks - 1);
-        var magnitude = Math.pow(10, Math.floor(Math.log(minimum) / Math.LN10));
-        var residual = minimum / magnitude;
-        var interval;
-        // "nicest" ranges are 1, 2, 5 or powers of these.
-        // for magnitudes below 1, only allow these. 
-        if (magnitude < 1) {
-            if (residual > 5) {
-                interval = 10 * magnitude;
-            }
-            else if (residual > 2) {
-                interval = 5 * magnitude;
-            }
-            else if (residual > 1) {
-                interval = 2 * magnitude;
-            }
-            else {
-                interval = magnitude;
-            }
-        }
-        // for large ranges (whole integers), allow intervals like 3, 4 or powers of these.
-        // this helps a lot with poor choices for number of ticks. 
-        else {
-            if (residual > 5) {
-                interval = 10 * magnitude;
-            }
-            else if (residual > 4) {
-                interval = 5 * magnitude;
-            }
-            else if (residual > 3) {
-                interval = 4 * magnitude;
-            }
-            else if (residual > 2) {
-                interval = 3 * magnitude;
-            }
-            else if (residual > 1) {
-                interval = 2 * magnitude;
-            }
-            else {
-                interval = magnitude;
-            }
-        }
-
-        return interval;
-    }
-
-    // This will return an interval of form 2 * 10^n, 5 * 10^n or 10 * 10^n
-    // it is based soley on the range of data, number of ticks must be computed later.
-    function bestLinearInterval(range, scalefact) {
-        var expv = Math.floor(Math.log(range)/Math.LN10);
-        var magnitude = Math.pow(10, expv);
-        // 0 < f < 10
-        var f = range / magnitude;
-        var fact;
-        // for large plots, scalefact will decrease f and increase number of ticks.
-        // for small plots, scalefact will increase f and decrease number of ticks.
-        f = f/scalefact;
-
-        // for large plots, smaller interval, more ticks.
-        if (f<=0.38) {
-            fact = 0.1;
-        }
-        else if (f<=1.6) {
-            fact = 0.2;
-        }
-        else if (f<=4.0) {
-            fact = 0.5;
-        }
-        else if (f<=8.0) {
-            fact = 1.0;
-        }
-        // for very small plots, larger interval, less ticks in number ticks
-        else if (f<=16.0) {
-            fact = 2;
-        }
-        else {
-            fact = 5;
-        } 
-
-        return fact*magnitude; 
-    }
-
-    function bestLinearComponents(range, scalefact) {
-        var expv = Math.floor(Math.log(range)/Math.LN10);
-        var magnitude = Math.pow(10, expv);
-        // 0 < f < 10
-        var f = range / magnitude;
-        var interval;
-        var fact;
-        // for large plots, scalefact will decrease f and increase number of ticks.
-        // for small plots, scalefact will increase f and decrease number of ticks.
-        f = f/scalefact;
-
-        // for large plots, smaller interval, more ticks.
-        if (f<=0.38) {
-            fact = 0.1;
-        }
-        else if (f<=1.6) {
-            fact = 0.2;
-        }
-        else if (f<=4.0) {
-            fact = 0.5;
-        }
-        else if (f<=8.0) {
-            fact = 1.0;
-        }
-        // for very small plots, larger interval, less ticks in number ticks
-        else if (f<=16.0) {
-            fact = 2;
-        }
-        // else if (f<=20.0) {
-        //     fact = 3;
-        // }
-        // else if (f<=24.0) {
-        //     fact = 4;
-        // }
-        else {
-            fact = 5;
-        } 
-
-        interval = fact * magnitude;
-
-        return [interval, fact, magnitude];
-    }
-
-    // Given the min and max for a dataset, return suitable endpoints
-    // for the graphing, a good number for the number of ticks, and a
-    // format string so that extraneous digits are not displayed.
-    // returned is an array containing [min, max, nTicks, format]
-    $.jqplot.LinearTickGenerator = function(axis_min, axis_max, scalefact, numberTicks) {
-        // if endpoints are equal try to include zero otherwise include one
-        if (axis_min === axis_max) {
-            axis_max = (axis_max) ? 0 : 1;
-        }
-
-        scalefact = scalefact || 1.0;
-
-        // make sure range is positive
-        if (axis_max < axis_min) {
-            var a = axis_max;
-            axis_max = axis_min;
-            axis_min = a;
-        }
-
-        var r = [];
-        var ss = bestLinearInterval(axis_max - axis_min, scalefact);
-        
-        if (numberTicks == null) {
-
-            // Figure out the axis min, max and number of ticks
-            // the min and max will be some multiple of the tick interval,
-            // 1*10^n, 2*10^n or 5*10^n.  This gaurantees that, if the
-            // axis min is negative, 0 will be a tick.
-            r[0] = Math.floor(axis_min / ss) * ss;  // min
-            r[1] = Math.ceil(axis_max / ss) * ss;   // max
-            r[2] = Math.round((r[1]-r[0])/ss+1.0);  // number of ticks
-            r[3] = bestFormatString(ss);            // format string
-            r[4] = ss;                              // tick Interval
-        }
-
-        else {
-            var tempr = [];
-
-            // Figure out the axis min, max and number of ticks
-            // the min and max will be some multiple of the tick interval,
-            // 1*10^n, 2*10^n or 5*10^n.  This gaurantees that, if the
-            // axis min is negative, 0 will be a tick.
-            tempr[0] = Math.floor(axis_min / ss) * ss;  // min
-            tempr[1] = Math.ceil(axis_max / ss) * ss;   // max
-            tempr[2] = Math.round((tempr[1]-tempr[0])/ss+1.0);    // number of ticks
-            tempr[3] = bestFormatString(ss);            // format string
-            tempr[4] = ss;                              // tick Interval
-
-            // first, see if we happen to get the right number of ticks
-            if (tempr[2] === numberTicks) {
-                r = tempr;
-            }
-
-            else {
-
-                var newti = bestInterval(tempr[1] - tempr[0], numberTicks);
-
-                r[0] = tempr[0];
-                r[2] = numberTicks;
-                r[4] = newti;
-                r[3] = bestFormatString(newti);
-                r[1] = r[0] + (r[2] - 1) * r[4];        // max
-            }
-        }
-
-        return r;
-    };
-
-    $.jqplot.LinearTickGenerator.bestLinearInterval = bestLinearInterval;
-    $.jqplot.LinearTickGenerator.bestInterval = bestInterval;
-    $.jqplot.LinearTickGenerator.bestLinearComponents = bestLinearComponents;
-
-
-    // class: $.jqplot.MarkerRenderer
-    // The default jqPlot marker renderer, rendering the points on the line.
-    $.jqplot.MarkerRenderer = function(options){
-        // Group: Properties
-        
-        // prop: show
-        // wether or not to show the marker.
-        this.show = true;
-        // prop: style
-        // One of diamond, circle, square, x, plus, dash, filledDiamond, filledCircle, filledSquare
-        this.style = 'filledCircle';
-        // prop: lineWidth
-        // size of the line for non-filled markers.
-        this.lineWidth = 2;
-        // prop: size
-        // Size of the marker (diameter or circle, length of edge of square, etc.)
-        this.size = 9.0;
-        // prop: color
-        // color of marker.  Will be set to color of series by default on init.
-        this.color = '#666666';
-        // prop: shadow
-        // wether or not to draw a shadow on the line
-        this.shadow = true;
-        // prop: shadowAngle
-        // Shadow angle in degrees
-        this.shadowAngle = 45;
-        // prop: shadowOffset
-        // Shadow offset from line in pixels
-        this.shadowOffset = 1;
-        // prop: shadowDepth
-        // Number of times shadow is stroked, each stroke offset shadowOffset from the last.
-        this.shadowDepth = 3;
-        // prop: shadowAlpha
-        // Alpha channel transparency of shadow.  0 = transparent.
-        this.shadowAlpha = '0.07';
-        // prop: shadowRenderer
-        // Renderer that will draws the shadows on the marker.
-        this.shadowRenderer = new $.jqplot.ShadowRenderer();
-        // prop: shapeRenderer
-        // Renderer that will draw the marker.
-        this.shapeRenderer = new $.jqplot.ShapeRenderer();
-        
-        $.extend(true, this, options);
-    };
-    
-    $.jqplot.MarkerRenderer.prototype.init = function(options) {
-        $.extend(true, this, options);
-        var sdopt = {angle:this.shadowAngle, offset:this.shadowOffset, alpha:this.shadowAlpha, lineWidth:this.lineWidth, depth:this.shadowDepth, closePath:true};
-        if (this.style.indexOf('filled') != -1) {
-            sdopt.fill = true;
-        }
-        if (this.style.indexOf('ircle') != -1) {
-            sdopt.isarc = true;
-            sdopt.closePath = false;
-        }
-        this.shadowRenderer.init(sdopt);
-        
-        var shopt = {fill:false, isarc:false, strokeStyle:this.color, fillStyle:this.color, lineWidth:this.lineWidth, closePath:true};
-        if (this.style.indexOf('filled') != -1) {
-            shopt.fill = true;
-        }
-        if (this.style.indexOf('ircle') != -1) {
-            shopt.isarc = true;
-            shopt.closePath = false;
-        }
-        this.shapeRenderer.init(shopt);
-    };
-    
-    $.jqplot.MarkerRenderer.prototype.drawDiamond = function(x, y, ctx, fill, options) {
-        var stretch = 1.2;
-        var dx = this.size/2/stretch;
-        var dy = this.size/2*stretch;
-        var points = [[x-dx, y], [x, y+dy], [x+dx, y], [x, y-dy]];
-        if (this.shadow) {
-            this.shadowRenderer.draw(ctx, points);
-        }
-        this.shapeRenderer.draw(ctx, points, options);
-    };
-    
-    $.jqplot.MarkerRenderer.prototype.drawPlus = function(x, y, ctx, fill, options) {
-        var stretch = 1.0;
-        var dx = this.size/2*stretch;
-        var dy = this.size/2*stretch;
-        var points1 = [[x, y-dy], [x, y+dy]];
-        var points2 = [[x+dx, y], [x-dx, y]];
-        var opts = $.extend(true, {}, this.options, {closePath:false});
-        if (this.shadow) {
-            this.shadowRenderer.draw(ctx, points1, {closePath:false});
-            this.shadowRenderer.draw(ctx, points2, {closePath:false});
-        }
-        this.shapeRenderer.draw(ctx, points1, opts);
-        this.shapeRenderer.draw(ctx, points2, opts);
-    };
-    
-    $.jqplot.MarkerRenderer.prototype.drawX = function(x, y, ctx, fill, options) {
-        var stretch = 1.0;
-        var dx = this.size/2*stretch;
-        var dy = this.size/2*stretch;
-        var opts = $.extend(true, {}, this.options, {closePath:false});
-        var points1 = [[x-dx, y-dy], [x+dx, y+dy]];
-        var points2 = [[x-dx, y+dy], [x+dx, y-dy]];
-        if (this.shadow) {
-            this.shadowRenderer.draw(ctx, points1, {closePath:false});
-            this.shadowRenderer.draw(ctx, points2, {closePath:false});
-        }
-        this.shapeRenderer.draw(ctx, points1, opts);
-        this.shapeRenderer.draw(ctx, points2, opts);
-    };
-    
-    $.jqplot.MarkerRenderer.prototype.drawDash = function(x, y, ctx, fill, options) {
-        var stretch = 1.0;
-        var dx = this.size/2*stretch;
-        var dy = this.size/2*stretch;
-        var points = [[x-dx, y], [x+dx, y]];
-        if (this.shadow) {
-            this.shadowRenderer.draw(ctx, points);
-        }
-        this.shapeRenderer.draw(ctx, points, options);
-    };
-    
-    $.jqplot.MarkerRenderer.prototype.drawLine = function(p1, p2, ctx, fill, options) {
-        var points = [p1, p2];
-        if (this.shadow) {
-            this.shadowRenderer.draw(ctx, points);
-        }
-        this.shapeRenderer.draw(ctx, points, options);
-    };
-    
-    $.jqplot.MarkerRenderer.prototype.drawSquare = function(x, y, ctx, fill, options) {
-        var stretch = 1.0;
-        var dx = this.size/2/stretch;
-        var dy = this.size/2*stretch;
-        var points = [[x-dx, y-dy], [x-dx, y+dy], [x+dx, y+dy], [x+dx, y-dy]];
-        if (this.shadow) {
-            this.shadowRenderer.draw(ctx, points);
-        }
-        this.shapeRenderer.draw(ctx, points, options);
-    };
-    
-    $.jqplot.MarkerRenderer.prototype.drawCircle = function(x, y, ctx, fill, options) {
-        var radius = this.size/2;
-        var end = 2*Math.PI;
-        var points = [x, y, radius, 0, end, true];
-        if (this.shadow) {
-            this.shadowRenderer.draw(ctx, points);
-        }
-        this.shapeRenderer.draw(ctx, points, options);
-    };
-    
-    $.jqplot.MarkerRenderer.prototype.draw = function(x, y, ctx, options) {
-        options = options || {};
-        // hack here b/c shape renderer uses canvas based color style options
-        // and marker uses css style names.
-        if (options.show == null || options.show != false) {
-            if (options.color && !options.fillStyle) {
-                options.fillStyle = options.color;
-            }
-            if (options.color && !options.strokeStyle) {
-                options.strokeStyle = options.color;
-            }
-            switch (this.style) {
-                case 'diamond':
-                    this.drawDiamond(x,y,ctx, false, options);
-                    break;
-                case 'filledDiamond':
-                    this.drawDiamond(x,y,ctx, true, options);
-                    break;
-                case 'circle':
-                    this.drawCircle(x,y,ctx, false, options);
-                    break;
-                case 'filledCircle':
-                    this.drawCircle(x,y,ctx, true, options);
-                    break;
-                case 'square':
-                    this.drawSquare(x,y,ctx, false, options);
-                    break;
-                case 'filledSquare':
-                    this.drawSquare(x,y,ctx, true, options);
-                    break;
-                case 'x':
-                    this.drawX(x,y,ctx, true, options);
-                    break;
-                case 'plus':
-                    this.drawPlus(x,y,ctx, true, options);
-                    break;
-                case 'dash':
-                    this.drawDash(x,y,ctx, true, options);
-                    break;
-                case 'line':
-                    this.drawLine(x, y, ctx, false, options);
-                    break;
-                default:
-                    this.drawDiamond(x,y,ctx, false, options);
-                    break;
-            }
-        }
-    };
-    
-    // class: $.jqplot.shadowRenderer
-    // The default jqPlot shadow renderer, rendering shadows behind shapes.
-    $.jqplot.ShadowRenderer = function(options){ 
-        // Group: Properties
-        
-        // prop: angle
-        // Angle of the shadow in degrees.  Measured counter-clockwise from the x axis.
-        this.angle = 45;
-        // prop: offset
-        // Pixel offset at the given shadow angle of each shadow stroke from the last stroke.
-        this.offset = 1;
-        // prop: alpha
-        // alpha transparency of shadow stroke.
-        this.alpha = 0.07;
-        // prop: lineWidth
-        // width of the shadow line stroke.
-        this.lineWidth = 1.5;
-        // prop: lineJoin
-        // How line segments of the shadow are joined.
-        this.lineJoin = 'miter';
-        // prop: lineCap
-        // how ends of the shadow line are rendered.
-        this.lineCap = 'round';
-        // prop; closePath
-        // whether line path segment is closed upon itself.
-        this.closePath = false;
-        // prop: fill
-        // whether to fill the shape.
-        this.fill = false;
-        // prop: depth
-        // how many times the shadow is stroked.  Each stroke will be offset by offset at angle degrees.
-        this.depth = 3;
-        this.strokeStyle = 'rgba(0,0,0,0.1)';
-        // prop: isarc
-        // wether the shadow is an arc or not.
-        this.isarc = false;
-        
-        $.extend(true, this, options);
-    };
-    
-    $.jqplot.ShadowRenderer.prototype.init = function(options) {
-        $.extend(true, this, options);
-    };
-    
-    // function: draw
-    // draws an transparent black (i.e. gray) shadow.
-    //
-    // ctx - canvas drawing context
-    // points - array of points or [x, y, radius, start angle (rad), end angle (rad)]
-    $.jqplot.ShadowRenderer.prototype.draw = function(ctx, points, options) {
-        ctx.save();
-        var opts = (options != null) ? options : {};
-        var fill = (opts.fill != null) ? opts.fill : this.fill;
-        var fillRect = (opts.fillRect != null) ? opts.fillRect : this.fillRect;
-        var closePath = (opts.closePath != null) ? opts.closePath : this.closePath;
-        var offset = (opts.offset != null) ? opts.offset : this.offset;
-        var alpha = (opts.alpha != null) ? opts.alpha : this.alpha;
-        var depth = (opts.depth != null) ? opts.depth : this.depth;
-        var isarc = (opts.isarc != null) ? opts.isarc : this.isarc;
-        var linePattern = (opts.linePattern != null) ? opts.linePattern : this.linePattern;
-        ctx.lineWidth = (opts.lineWidth != null) ? opts.lineWidth : this.lineWidth;
-        ctx.lineJoin = (opts.lineJoin != null) ? opts.lineJoin : this.lineJoin;
-        ctx.lineCap = (opts.lineCap != null) ? opts.lineCap : this.lineCap;
-        ctx.strokeStyle = opts.strokeStyle || this.strokeStyle || 'rgba(0,0,0,'+alpha+')';
-        ctx.fillStyle = opts.fillStyle || this.fillStyle || 'rgba(0,0,0,'+alpha+')';
-        for (var j=0; j<depth; j++) {
-            var ctxPattern = $.jqplot.LinePattern(ctx, linePattern);
-            ctx.translate(Math.cos(this.angle*Math.PI/180)*offset, Math.sin(this.angle*Math.PI/180)*offset);
-            ctxPattern.beginPath();
-            if (isarc) {
-                ctx.arc(points[0], points[1], points[2], points[3], points[4], true);                
-            }
-            else if (fillRect) {
-                if (fillRect) {
-                    ctx.fillRect(points[0], points[1], points[2], points[3]);
-                }
-            }
-            else if (points && points.length){
-                var move = true;
-                for (var i=0; i<points.length; i++) {
-                    // skip to the first non-null point and move to it.
-                    if (points[i][0] != null && points[i][1] != null) {
-                        if (move) {
-                            ctxPattern.moveTo(points[i][0], points[i][1]);
-                            move = false;
-                        }
-                        else {
-                            ctxPattern.lineTo(points[i][0], points[i][1]);
-                        }
-                    }
-                    else {
-                        move = true;
-                    }
-                }
-                
-            }
-            if (closePath) {
-                ctxPattern.closePath();
-            }
-            if (fill) {
-                ctx.fill();
-            }
-            else {
-                ctx.stroke();
-            }
-        }
-        ctx.restore();
-    };
-    
-    // class: $.jqplot.shapeRenderer
-    // The default jqPlot shape renderer.  Given a set of points will
-    // plot them and either stroke a line (fill = false) or fill them (fill = true).
-    // If a filled shape is desired, closePath = true must also be set to close
-    // the shape.
-    $.jqplot.ShapeRenderer = function(options){
-        
-        this.lineWidth = 1.5;
-        // prop: linePattern
-        // line pattern 'dashed', 'dotted', 'solid', some combination
-        // of '-' and '.' characters such as '.-.' or a numerical array like 
-        // [draw, skip, draw, skip, ...] such as [1, 10] to draw a dotted line, 
-        // [1, 10, 20, 10] to draw a dot-dash line, and so on.
-        this.linePattern = 'solid';
-        // prop: lineJoin
-        // How line segments of the shadow are joined.
-        this.lineJoin = 'miter';
-        // prop: lineCap
-        // how ends of the shadow line are rendered.
-        this.lineCap = 'round';
-        // prop; closePath
-        // whether line path segment is closed upon itself.
-        this.closePath = false;
-        // prop: fill
-        // whether to fill the shape.
-        this.fill = false;
-        // prop: isarc
-        // wether the shadow is an arc or not.
-        this.isarc = false;
-        // prop: fillRect
-        // true to draw shape as a filled rectangle.
-        this.fillRect = false;
-        // prop: strokeRect
-        // true to draw shape as a stroked rectangle.
-        this.strokeRect = false;
-        // prop: clearRect
-        // true to cear a rectangle.
-        this.clearRect = false;
-        // prop: strokeStyle
-        // css color spec for the stoke style
-        this.strokeStyle = '#999999';
-        // prop: fillStyle
-        // css color spec for the fill style.
-        this.fillStyle = '#999999'; 
-        
-        $.extend(true, this, options);
-    };
-    
-    $.jqplot.ShapeRenderer.prototype.init = function(options) {
-        $.extend(true, this, options);
-    };
-    
-    // function: draw
-    // draws the shape.
-    //
-    // ctx - canvas drawing context
-    // points - array of points for shapes or 
-    // [x, y, width, height] for rectangles or
-    // [x, y, radius, start angle (rad), end angle (rad)] for circles and arcs.
-    $.jqplot.ShapeRenderer.prototype.draw = function(ctx, points, options) {
-        ctx.save();
-        var opts = (options != null) ? options : {};
-        var fill = (opts.fill != null) ? opts.fill : this.fill;
-        var closePath = (opts.closePath != null) ? opts.closePath : this.closePath;
-        var fillRect = (opts.fillRect != null) ? opts.fillRect : this.fillRect;
-        var strokeRect = (opts.strokeRect != null) ? opts.strokeRect : this.strokeRect;
-        var clearRect = (opts.clearRect != null) ? opts.clearRect : this.clearRect;
-        var isarc = (opts.isarc != null) ? opts.isarc : this.isarc;
-        var linePattern = (opts.linePattern != null) ? opts.linePattern : this.linePattern;
-        var ctxPattern = $.jqplot.LinePattern(ctx, linePattern);
-        ctx.lineWidth = opts.lineWidth || this.lineWidth;
-        ctx.lineJoin = opts.lineJoin || this.lineJoin;
-        ctx.lineCap = opts.lineCap || this.lineCap;
-        ctx.strokeStyle = (opts.strokeStyle || opts.color) || this.strokeStyle;
-        ctx.fillStyle = opts.fillStyle || this.fillStyle;
-        ctx.beginPath();
-        if (isarc) {
-            ctx.arc(points[0], points[1], points[2], points[3], points[4], true);   
-            if (closePath) {
-                ctx.closePath();
-            }
-            if (fill) {
-                ctx.fill();
-            }
-            else {
-                ctx.stroke();
-            }
-            ctx.restore();
-            return;
-        }
-        else if (clearRect) {
-            ctx.clearRect(points[0], points[1], points[2], points[3]);
-            ctx.restore();
-            return;
-        }
-        else if (fillRect || strokeRect) {
-            if (fillRect) {
-                ctx.fillRect(points[0], points[1], points[2], points[3]);
-            }
-            if (strokeRect) {
-                ctx.strokeRect(points[0], points[1], points[2], points[3]);
-                ctx.restore();
-                return;
-            }
-        }
-        else if (points && points.length){
-            var move = true;
-            for (var i=0; i<points.length; i++) {
-                // skip to the first non-null point and move to it.
-                if (points[i][0] != null && points[i][1] != null) {
-                    if (move) {
-                        ctxPattern.moveTo(points[i][0], points[i][1]);
-                        move = false;
-                    }
-                    else {
-                        ctxPattern.lineTo(points[i][0], points[i][1]);
-                    }
-                }
-                else {
-                    move = true;
-                }
-            }
-            if (closePath) {
-                ctxPattern.closePath();
-            }
-            if (fill) {
-                ctx.fill();
-            }
-            else {
-                ctx.stroke();
-            }
-        }
-        ctx.restore();
-    };
-    
-    // class $.jqplot.TableLegendRenderer
-    // The default legend renderer for jqPlot.
-    $.jqplot.TableLegendRenderer = function(){
-        //
-    };
-    
-    $.jqplot.TableLegendRenderer.prototype.init = function(options) {
-        $.extend(true, this, options);
-    };
-        
-    $.jqplot.TableLegendRenderer.prototype.addrow = function (label, color, pad, reverse) {
-        var rs = (pad) ? this.rowSpacing+'px' : '0px';
-        var tr;
-        var td;
-        var elem;
-        var div0;
-        var div1;
-        elem = document.createElement('tr');
-        tr = $(elem);
-        tr.addClass('jqplot-table-legend');
-        elem = null;
-
-        if (reverse){
-            tr.prependTo(this._elem);
-        }
-
-        else{
-            tr.appendTo(this._elem);
-        }
-
-        if (this.showSwatches) {
-            td = $(document.createElement('td'));
-            td.addClass('jqplot-table-legend jqplot-table-legend-swatch');
-            td.css({textAlign: 'center', paddingTop: rs});
-
-            div0 = $(document.createElement('div'));
-            div0.addClass('jqplot-table-legend-swatch-outline');
-            div1 = $(document.createElement('div'));
-            div1.addClass('jqplot-table-legend-swatch');
-            div1.css({backgroundColor: color, borderColor: color});
-
-            tr.append(td.append(div0.append(div1)));
-
-            // $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
-            // '<div><div class="jqplot-table-legend-swatch" style="background-color:'+color+';border-color:'+color+';"></div>'+
-            // '</div></td>').appendTo(tr);
-        }
-        if (this.showLabels) {
-            td = $(document.createElement('td'));
-            td.addClass('jqplot-table-legend jqplot-table-legend-label');
-            td.css('paddingTop', rs);
-            tr.append(td);
-
-            // elem = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
-            // elem.appendTo(tr);
-            if (this.escapeHtml) {
-                td.text(label);
-            }
-            else {
-                td.html(label);
-            }
-        }
-        td = null;
-        div0 = null;
-        div1 = null;
-        tr = null;
-        elem = null;
-    };
-    
-    // called with scope of legend
-    $.jqplot.TableLegendRenderer.prototype.draw = function() {
-        if (this._elem) {
-            this._elem.emptyForce();
-            this._elem = null;
-        }
-
-        if (this.show) {
-            var series = this._series;
-            // make a table.  one line label per row.
-            var elem = document.createElement('table');
-            this._elem = $(elem);
-            this._elem.addClass('jqplot-table-legend');
-
-            var ss = {position:'absolute'};
-            if (this.background) {
-                ss['background'] = this.background;
-            }
-            if (this.border) {
-                ss['border'] = this.border;
-            }
-            if (this.fontSize) {
-                ss['fontSize'] = this.fontSize;
-            }
-            if (this.fontFamily) {
-                ss['fontFamily'] = this.fontFamily;
-            }
-            if (this.textColor) {
-                ss['textColor'] = this.textColor;
-            }
-            if (this.marginTop != null) {
-                ss['marginTop'] = this.marginTop;
-            }
-            if (this.marginBottom != null) {
-                ss['marginBottom'] = this.marginBottom;
-            }
-            if (this.marginLeft != null) {
-                ss['marginLeft'] = this.marginLeft;
-            }
-            if (this.marginRight != null) {
-                ss['marginRight'] = this.marginRight;
-            }
-            
-        
-            var pad = false, 
-                reverse = false,
-				s;
-            for (var i = 0; i< series.length; i++) {
-                s = series[i];
-                if (s._stack || s.renderer.constructor == $.jqplot.BezierCurveRenderer){
-                    reverse = true;
-                }
-                if (s.show && s.showLabel) {
-                    var lt = this.labels[i] || s.label.toString();
-                    if (lt) {
-                        var color = s.color;
-                        if (reverse && i < series.length - 1){
-                            pad = true;
-                        }
-                        else if (reverse && i == series.length - 1){
-                            pad = false;
-                        }
-                        this.renderer.addrow.call(this, lt, color, pad, reverse);
-                        pad = true;
-                    }
-                    // let plugins add more rows to legend.  Used by trend line plugin.
-                    for (var j=0; j<$.jqplot.addLegendRowHooks.length; j++) {
-                        var item = $.jqplot.addLegendRowHooks[j].call(this, s);
-                        if (item) {
-                            this.renderer.addrow.call(this, item.label, item.color, pad);
-                            pad = true;
-                        } 
-                    }
-                    lt = null;
-                }
-            }
-        }
-        return this._elem;
-    };
-    
-    $.jqplot.TableLegendRenderer.prototype.pack = function(offsets) {
-        if (this.show) {       
-            if (this.placement == 'insideGrid') {
-                switch (this.location) {
-                    case 'nw':
-                        var a = offsets.left;
-                        var b = offsets.top;
-                        this._elem.css('left', a);
-                        this._elem.css('top', b);
-                        break;
-                    case 'n':
-                        var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-                        var b = offsets.top;
-                        this._elem.css('left', a);
-                        this._elem.css('top', b);
-                        break;
-                    case 'ne':
-                        var a = offsets.right;
-                        var b = offsets.top;
-                        this._elem.css({right:a, top:b});
-                        break;
-                    case 'e':
-                        var a = offsets.right;
-                        var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-                        this._elem.css({right:a, top:b});
-                        break;
-                    case 'se':
-                        var a = offsets.right;
-                        var b = offsets.bottom;
-                        this._elem.css({right:a, bottom:b});
-                        break;
-                    case 's':
-                        var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-                        var b = offsets.bottom;
-                        this._elem.css({left:a, bottom:b});
-                        break;
-                    case 'sw':
-                        var a = offsets.left;
-                        var b = offsets.bottom;
-                        this._elem.css({left:a, bottom:b});
-                        break;
-                    case 'w':
-                        var a = offsets.left;
-                        var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-                        this._elem.css({left:a, top:b});
-                        break;
-                    default:  // same as 'se'
-                        var a = offsets.right;
-                        var b = offsets.bottom;
-                        this._elem.css({right:a, bottom:b});
-                        break;
-                }
-                
-            }
-            else if (this.placement == 'outside'){
-                switch (this.location) {
-                    case 'nw':
-                        var a = this._plotDimensions.width - offsets.left;
-                        var b = offsets.top;
-                        this._elem.css('right', a);
-                        this._elem.css('top', b);
-                        break;
-                    case 'n':
-                        var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-                        var b = this._plotDimensions.height - offsets.top;
-                        this._elem.css('left', a);
-                        this._elem.css('bottom', b);
-                        break;
-                    case 'ne':
-                        var a = this._plotDimensions.width - offsets.right;
-                        var b = offsets.top;
-                        this._elem.css({left:a, top:b});
-                        break;
-                    case 'e':
-                        var a = this._plotDimensions.width - offsets.right;
-                        var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-                        this._elem.css({left:a, top:b});
-                        break;
-                    case 'se':
-                        var a = this._plotDimensions.width - offsets.right;
-                        var b = offsets.bottom;
-                        this._elem.css({left:a, bottom:b});
-                        break;
-                    case 's':
-                        var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-                        var b = this._plotDimensions.height - offsets.bottom;
-                        this._elem.css({left:a, top:b});
-                        break;
-                    case 'sw':
-                        var a = this._plotDimensions.width - offsets.left;
-                        var b = offsets.bottom;
-                        this._elem.css({right:a, bottom:b});
-                        break;
-                    case 'w':
-                        var a = this._plotDimensions.width - offsets.left;
-                        var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-                        this._elem.css({right:a, top:b});
-                        break;
-                    default:  // same as 'se'
-                        var a = offsets.right;
-                        var b = offsets.bottom;
-                        this._elem.css({right:a, bottom:b});
-                        break;
-                }
-            }
-            else {
-                switch (this.location) {
-                    case 'nw':
-                        this._elem.css({left:0, top:offsets.top});
-                        break;
-                    case 'n':
-                        var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-                        this._elem.css({left: a, top:offsets.top});
-                        break;
-                    case 'ne':
-                        this._elem.css({right:0, top:offsets.top});
-                        break;
-                    case 'e':
-                        var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-                        this._elem.css({right:offsets.right, top:b});
-                        break;
-                    case 'se':
-                        this._elem.css({right:offsets.right, bottom:offsets.bottom});
-                        break;
-                    case 's':
-                        var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-                        this._elem.css({left: a, bottom:offsets.bottom});
-                        break;
-                    case 'sw':
-                        this._elem.css({left:offsets.left, bottom:offsets.bottom});
-                        break;
-                    case 'w':
-                        var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-                        this._elem.css({left:offsets.left, top:b});
-                        break;
-                    default:  // same as 'se'
-                        this._elem.css({right:offsets.right, bottom:offsets.bottom});
-                        break;
-                }
-            }
-        } 
-    };
-
-    /**
-     * Class: $.jqplot.ThemeEngine
-     * Theme Engine provides a programatic way to change some of the  more
-     * common jqplot styling options such as fonts, colors and grid options.
-     * A theme engine instance is created with each plot.  The theme engine
-     * manages a collection of themes which can be modified, added to, or 
-     * applied to the plot.
-     * 
-     * The themeEngine class is not instantiated directly.
-     * When a plot is initialized, the current plot options are scanned
-     * an a default theme named "Default" is created.  This theme is
-     * used as the basis for other themes added to the theme engine and
-     * is always available.
-     * 
-     * A theme is a simple javascript object with styling parameters for
-     * various entities of the plot.  A theme has the form:
-     * 
-     * 
-     * > {
-     * >     _name:f "Default",
-     * >     target: {
-     * >         backgroundColor: "transparent"
-     * >     },
-     * >     legend: {
-     * >         textColor: null,
-     * >         fontFamily: null,
-     * >         fontSize: null,
-     * >         border: null,
-     * >         background: null
-     * >     },
-     * >     title: {
-     * >         textColor: "rgb(102, 102, 102)",
-     * >         fontFamily: "'Trebuchet MS',Arial,Helvetica,sans-serif",
-     * >         fontSize: "19.2px",
-     * >         textAlign: "center"
-     * >     },
-     * >     seriesStyles: {},
-     * >     series: [{
-     * >         color: "#4bb2c5",
-     * >         lineWidth: 2.5,
-     * >         linePattern: "solid",
-     * >         shadow: true,
-     * >         fillColor: "#4bb2c5",
-     * >         showMarker: true,
-     * >         markerOptions: {
-     * >             color: "#4bb2c5",
-     * >             show: true,
-     * >             style: 'filledCircle',
-     * >             lineWidth: 1.5,
-     * >             size: 4,
-     * >             shadow: true
-     * >         }
-     * >     }],
-     * >     grid: {
-     * >         drawGridlines: true,
-     * >         gridLineColor: "#cccccc",
-     * >         gridLineWidth: 1,
-     * >         backgroundColor: "#fffdf6",
-     * >         borderColor: "#999999",
-     * >         borderWidth: 2,
-     * >         shadow: true
-     * >     },
-     * >     axesStyles: {
-     * >         label: {},
-     * >         ticks: {}
-     * >     },
-     * >     axes: {
-     * >         xaxis: {
-     * >             borderColor: "#999999",
-     * >             borderWidth: 2,
-     * >             ticks: {
-     * >                 show: true,
-     * >                 showGridline: true,
-     * >                 showLabel: true,
-     * >                 showMark: true,
-     * >                 size: 4,
-     * >                 textColor: "",
-     * >                 whiteSpace: "nowrap",
-     * >                 fontSize: "12px",
-     * >                 fontFamily: "'Trebuchet MS',Arial,Helvetica,sans-serif"
-     * >             },
-     * >             label: {
-     * >                 textColor: "rgb(102, 102, 102)",
-     * >                 whiteSpace: "normal",
-     * >                 fontSize: "14.6667px",
-     * >                 fontFamily: "'Trebuchet MS',Arial,Helvetica,sans-serif",
-     * >                 fontWeight: "400"
-     * >             }
-     * >         },
-     * >         yaxis: {
-     * >             borderColor: "#999999",
-     * >             borderWidth: 2,
-     * >             ticks: {
-     * >                 show: true,
-     * >                 showGridline: true,
-     * >                 showLabel: true,
-     * >                 showMark: true,
-     * >                 size: 4,
-     * >                 textColor: "",
-     * >                 whiteSpace: "nowrap",
-     * >                 fontSize: "12px",
-     * >                 fontFamily: "'Trebuchet MS',Arial,Helvetica,sans-serif"
-     * >             },
-     * >             label: {
-     * >                 textColor: null,
-     * >                 whiteSpace: null,
-     * >                 fontSize: null,
-     * >                 fontFamily: null,
-     * >                 fontWeight: null
-     * >             }
-     * >         },
-     * >         x2axis: {...
-     * >         },
-     * >         ...
-     * >         y9axis: {...
-     * >         }
-     * >     }
-     * > }
-     * 
-     * "seriesStyles" is a style object that will be applied to all series in the plot.
-     * It will forcibly override any styles applied on the individual series.  "axesStyles" is
-     * a style object that will be applied to all axes in the plot.  It will also forcibly
-     * override any styles on the individual axes.
-     * 
-     * The example shown above has series options for a line series.  Options for other
-     * series types are shown below:
-     * 
-     * Bar Series:
-     * 
-     * > {
-     * >     color: "#4bb2c5",
-     * >     seriesColors: ["#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"],
-     * >     lineWidth: 2.5,
-     * >     shadow: true,
-     * >     barPadding: 2,
-     * >     barMargin: 10,
-     * >     barWidth: 15.09375,
-     * >     highlightColors: ["rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)", "rgb(129,201,214)"]
-     * > }
-     * 
-     * Pie Series:
-     * 
-     * > {
-     * >     seriesColors: ["#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"],
-     * >     padding: 20,
-     * >     sliceMargin: 0,
-     * >     fill: true,
-     * >     shadow: true,
-     * >     startAngle: 0,
-     * >     lineWidth: 2.5,
-     * >     highlightColors: ["rgb(129,201,214)", "rgb(240,189,104)", "rgb(214,202,165)", "rgb(137,180,158)", "rgb(168,180,137)", "rgb(180,174,89)", "rgb(180,113,161)", "rgb(129,141,236)", "rgb(227,205,120)", "rgb(255,138,76)", "rgb(76,169,219)", "rgb(215,126,190)", "rgb(220,232,135)", "rgb(200,167,96)", "rgb(103,202,235)", "rgb(208,154,215)"]
-     * > }
-     * 
-     * Funnel Series:
-     * 
-     * > {
-     * >     color: "#4bb2c5",
-     * >     lineWidth: 2,
-     * >     shadow: true,
-     * >     padding: {
-     * >         top: 20,
-     * >         right: 20,
-     * >         bottom: 20,
-     * >         left: 20
-     * >     },
-     * >     sectionMargin: 6,
-     * >     seriesColors: ["#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"],
-     * >     highlightColors: ["rgb(147,208,220)", "rgb(242,199,126)", "rgb(220,210,178)", "rgb(154,191,172)", "rgb(180,191,154)", "rgb(191,186,112)", "rgb(191,133,174)", "rgb(147,157,238)", "rgb(231,212,139)", "rgb(255,154,102)", "rgb(102,181,224)", "rgb(221,144,199)", "rgb(225,235,152)", "rgb(200,167,96)", "rgb(124,210,238)", "rgb(215,169,221)"]
-     * > }
-     * 
-     */
-    $.jqplot.ThemeEngine = function(){
-        // Group: Properties
-        //
-        // prop: themes
-        // hash of themes managed by the theme engine.  
-        // Indexed by theme name.
-        this.themes = {};
-        // prop: activeTheme
-        // Pointer to currently active theme
-        this.activeTheme=null;
-        
-    };
-    
-    // called with scope of plot
-    $.jqplot.ThemeEngine.prototype.init = function() {
-        // get the Default theme from the current plot settings.
-        var th = new $.jqplot.Theme({_name:'Default'});
-        var n, i, nn;
-        
-        for (n in th.target) {
-            if (n == "textColor") {
-                th.target[n] = this.target.css('color');
-            }
-            else {
-                th.target[n] = this.target.css(n);
-            }
-        }
-        
-        if (this.title.show && this.title._elem) {
-            for (n in th.title) {
-                if (n == "textColor") {
-                    th.title[n] = this.title._elem.css('color');
-                }
-                else {
-                    th.title[n] = this.title._elem.css(n);
-                }
-            }
-        }
-        
-        for (n in th.grid) {
-            th.grid[n] = this.grid[n];
-        }
-        if (th.grid.backgroundColor == null && this.grid.background != null) {
-            th.grid.backgroundColor = this.grid.background;
-        }
-        if (this.legend.show && this.legend._elem) {
-            for (n in th.legend) {
-                if (n == 'textColor') {
-                    th.legend[n] = this.legend._elem.css('color');
-                }
-                else {
-                    th.legend[n] = this.legend._elem.css(n);
-                }
-            }
-        }
-        var s;
-        
-        for (i=0; i<this.series.length; i++) {
-            s = this.series[i];
-            if (s.renderer.constructor == $.jqplot.LineRenderer) {
-                th.series.push(new LineSeriesProperties());
-            }
-            else if (s.renderer.constructor == $.jqplot.BarRenderer) {
-                th.series.push(new BarSeriesProperties());
-            }
-            else if (s.renderer.constructor == $.jqplot.PieRenderer) {
-                th.series.push(new PieSeriesProperties());
-            }
-            else if (s.renderer.constructor == $.jqplot.DonutRenderer) {
-                th.series.push(new DonutSeriesProperties());
-            }
-            else if (s.renderer.constructor == $.jqplot.FunnelRenderer) {
-                th.series.push(new FunnelSeriesProperties());
-            }
-            else if (s.renderer.constructor == $.jqplot.MeterGaugeRenderer) {
-                th.series.push(new MeterSeriesProperties());
-            }
-            else {
-                th.series.push({});
-            }
-            for (n in th.series[i]) {
-                th.series[i][n] = s[n];
-            }
-        }
-        var a, ax;
-        for (n in this.axes) {
-            ax = this.axes[n];
-            a = th.axes[n] = new AxisProperties();
-            a.borderColor = ax.borderColor;
-            a.borderWidth = ax.borderWidth;
-            if (ax._ticks && ax._ticks[0]) {
-                for (nn in a.ticks) {
-                    if (ax._ticks[0].hasOwnProperty(nn)) {
-                        a.ticks[nn] = ax._ticks[0][nn];
-                    }
-                    else if (ax._ticks[0]._elem){
-                        a.ticks[nn] = ax._ticks[0]._elem.css(nn);
-                    }
-                }
-            }
-            if (ax._label && ax._label.show) {
-                for (nn in a.label) {
-                    // a.label[nn] = ax._label._elem.css(nn);
-                    if (ax._label[nn]) {
-                        a.label[nn] = ax._label[nn];
-                    }
-                    else if (ax._label._elem){
-                        if (nn == 'textColor') {
-                            a.label[nn] = ax._label._elem.css('color');
-                        }
-                        else {
-                            a.label[nn] = ax._label._elem.css(nn);
-                        }
-                    }
-                }
-            }
-        }
-        this.themeEngine._add(th);
-        this.themeEngine.activeTheme  = this.themeEngine.themes[th._name];
-    };
-    /**
-     * Group: methods
-     * 
-     * method: get
-     * 
-     * Get and return the named theme or the active theme if no name given.
-     * 
-     * parameter:
-     * 
-     * name - name of theme to get.
-     * 
-     * returns:
-     * 
-     * Theme instance of given name.
-     */   
-    $.jqplot.ThemeEngine.prototype.get = function(name) {
-        if (!name) {
-            // return the active theme
-            return this.activeTheme;
-        }
-        else {
-            return this.themes[name];
-        }
-    };
-    
-    function numericalOrder(a,b) { return a-b; }
-    
-    /**
-     * method: getThemeNames
-     * 
-     * Return the list of theme names in this manager in alpha-numerical order.
-     * 
-     * parameter:
-     * 
-     * None
-     * 
-     * returns:
-     * 
-     * A the list of theme names in this manager in alpha-numerical order.
-     */       
-    $.jqplot.ThemeEngine.prototype.getThemeNames = function() {
-        var tn = [];
-        for (var n in this.themes) {
-            tn.push(n);
-        }
-        return tn.sort(numericalOrder);
-    };
-
-    /**
-     * method: getThemes
-     * 
-     * Return a list of themes in alpha-numerical order by name.
-     * 
-     * parameter:
-     * 
-     * None
-     * 
-     * returns:
-     * 
-     * A list of themes in alpha-numerical order by name.
-     */ 
-    $.jqplot.ThemeEngine.prototype.getThemes = function() {
-        var tn = [];
-        var themes = [];
-        for (var n in this.themes) {
-            tn.push(n);
-        }
-        tn.sort(numericalOrder);
-        for (var i=0; i<tn.length; i++) {
-            themes.push(this.themes[tn[i]]);
-        }
-        return themes;
-    };
-    
-    $.jqplot.ThemeEngine.prototype.activate = function(plot, name) {
-        // sometimes need to redraw whole plot.
-        var redrawPlot = false;
-        if (!name && this.activeTheme && this.activeTheme._name) {
-            name = this.activeTheme._name;
-        }
-        if (!this.themes.hasOwnProperty(name)) {
-            throw new Error("No theme of that name");
-        }
-        else {
-            var th = this.themes[name];
-            this.activeTheme = th;
-            var val, checkBorderColor = false, checkBorderWidth = false;
-            var arr = ['xaxis', 'x2axis', 'yaxis', 'y2axis'];
-            
-            for (i=0; i<arr.length; i++) {
-                var ax = arr[i];
-                if (th.axesStyles.borderColor != null) {
-                    plot.axes[ax].borderColor = th.axesStyles.borderColor;
-                }
-                if (th.axesStyles.borderWidth != null) {
-                    plot.axes[ax].borderWidth = th.axesStyles.borderWidth;
-                }
-            }
-            
-            for (var axname in plot.axes) {
-                var axis = plot.axes[axname];
-                if (axis.show) {
-                    var thaxis = th.axes[axname] || {};
-                    var thaxstyle = th.axesStyles;
-                    var thax = $.jqplot.extend(true, {}, thaxis, thaxstyle);
-                    val = (th.axesStyles.borderColor != null) ? th.axesStyles.borderColor : thax.borderColor;
-                    if (thax.borderColor != null) {
-                        axis.borderColor = thax.borderColor;
-                        redrawPlot = true;
-                    }
-                    val = (th.axesStyles.borderWidth != null) ? th.axesStyles.borderWidth : thax.borderWidth;
-                    if (thax.borderWidth != null) {
-                        axis.borderWidth = thax.borderWidth;
-                        redrawPlot = true;
-                    }
-                    if (axis._ticks && axis._ticks[0]) {
-                        for (var nn in thax.ticks) {
-                            // val = null;
-                            // if (th.axesStyles.ticks && th.axesStyles.ticks[nn] != null) {
-                            //     val = th.axesStyles.ticks[nn];
-                            // }
-                            // else if (thax.ticks[nn] != null){
-                            //     val = thax.ticks[nn]
-                            // }
-                            val = thax.ticks[nn];
-                            if (val != null) {
-                                axis.tickOptions[nn] = val;
-                                axis._ticks = [];
-                                redrawPlot = true;
-                            }
-                        }
-                    }
-                    if (axis._label && axis._label.show) {
-                        for (var nn in thax.label) {
-                            // val = null;
-                            // if (th.axesStyles.label && th.axesStyles.label[nn] != null) {
-                            //     val = th.axesStyles.label[nn];
-                            // }
-                            // else if (thax.label && thax.label[nn] != null){
-                            //     val = thax.label[nn]
-                            // }
-                            val = thax.label[nn];
-                            if (val != null) {
-                                axis.labelOptions[nn] = val;
-                                redrawPlot = true;
-                            }
-                        }
-                    }
-                    
-                }
-            }            
-            
-            for (var n in th.grid) {
-                if (th.grid[n] != null) {
-                    plot.grid[n] = th.grid[n];
-                }
-            }
-            if (!redrawPlot) {
-                plot.grid.draw();
-            }
-            
-            if (plot.legend.show) { 
-                for (n in th.legend) {
-                    if (th.legend[n] != null) {
-                        plot.legend[n] = th.legend[n];
-                    }
-                }
-            }
-            if (plot.title.show) {
-                for (n in th.title) {
-                    if (th.title[n] != null) {
-                        plot.title[n] = th.title[n];
-                    }
-                }
-            }
-            
-            var i;
-            for (i=0; i<th.series.length; i++) {
-                var opts = {};
-                var redrawSeries = false;
-                for (n in th.series[i]) {
-                    val = (th.seriesStyles[n] != null) ? th.seriesStyles[n] : th.series[i][n];
-                    if (val != null) {
-                        opts[n] = val;
-                        if (n == 'color') {
-                            plot.series[i].renderer.shapeRenderer.fillStyle = val;
-                            plot.series[i].renderer.shapeRenderer.strokeStyle = val;
-                            plot.series[i][n] = val;
-                        }
-                        else if ((n == 'lineWidth') || (n == 'linePattern')) {
-                            plot.series[i].renderer.shapeRenderer[n] = val;
-                            plot.series[i][n] = val;
-                        }
-                        else if (n == 'markerOptions') {
-                            merge (plot.series[i].markerOptions, val);
-                            merge (plot.series[i].markerRenderer, val);
-                        }
-                        else {
-                            plot.series[i][n] = val;
-                        }
-                        redrawPlot = true;
-                    }
-                }
-            }
-            
-            if (redrawPlot) {
-                plot.target.empty();
-                plot.draw();
-            }
-            
-            for (n in th.target) {
-                if (th.target[n] != null) {
-                    plot.target.css(n, th.target[n]);
-                }
-            }
-        }
-        
-    };
-    
-    $.jqplot.ThemeEngine.prototype._add = function(theme, name) {
-        if (name) {
-            theme._name = name;
-        }
-        if (!theme._name) {
-            theme._name = Date.parse(new Date());
-        }
-        if (!this.themes.hasOwnProperty(theme._name)) {
-            this.themes[theme._name] = theme;
-        }
-        else {
-            throw new Error("jqplot.ThemeEngine Error: Theme already in use");
-        }
-    };
-    
-    // method remove
-    // Delete the named theme, return true on success, false on failure.
-    
-
-    /**
-     * method: remove
-     * 
-     * Remove the given theme from the themeEngine.
-     * 
-     * parameters:
-     * 
-     * name - name of the theme to remove.
-     * 
-     * returns:
-     * 
-     * true on success, false on failure.
-     */
-    $.jqplot.ThemeEngine.prototype.remove = function(name) {
-        if (name == 'Default') {
-            return false;
-        }
-        return delete this.themes[name];
-    };
-
-    /**
-     * method: newTheme
-     * 
-     * Create a new theme based on the default theme, adding it the themeEngine.
-     * 
-     * parameters:
-     * 
-     * name - name of the new theme.
-     * obj - optional object of styles to be applied to this new theme.
-     * 
-     * returns:
-     * 
-     * new Theme object.
-     */
-    $.jqplot.ThemeEngine.prototype.newTheme = function(name, obj) {
-        if (typeof(name) == 'object') {
-            obj = obj || name;
-            name = null;
-        }
-        if (obj && obj._name) {
-            name = obj._name;
-        }
-        else {
-            name = name || Date.parse(new Date());
-        }
-        // var th = new $.jqplot.Theme(name);
-        var th = this.copy(this.themes['Default']._name, name);
-        $.jqplot.extend(th, obj);
-        return th;
-    };
-    
-    // function clone(obj) {
-    //     return eval(obj.toSource());
-    // }
-    
-    function clone(obj){
-        if(obj == null || typeof(obj) != 'object'){
-            return obj;
-        }
-    
-        var temp = new obj.constructor();
-        for(var key in obj){
-            temp[key] = clone(obj[key]);
-        }   
-        return temp;
-    }
-    
-    $.jqplot.clone = clone;
-    
-    function merge(obj1, obj2) {
-        if (obj2 ==  null || typeof(obj2) != 'object') {
-            return;
-        }
-        for (var key in obj2) {
-            if (key == 'highlightColors') {
-                obj1[key] = clone(obj2[key]);
-            }
-            if (obj2[key] != null && typeof(obj2[key]) == 'object') {
-                if (!obj1.hasOwnProperty(key)) {
-                    obj1[key] = {};
-                }
-                merge(obj1[key], obj2[key]);
-            }
-            else {
-                obj1[key] = obj2[key];
-            }
-        }
-    }
-    
-    $.jqplot.merge = merge;
-    
-        // Use the jQuery 1.3.2 extend function since behaviour in jQuery 1.4 seems problematic
-    $.jqplot.extend = function() {
-        // copy reference to target object
-        var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
-
-        // Handle a deep copy situation
-        if ( typeof target === "boolean" ) {
-            deep = target;
-            target = arguments[1] || {};
-            // skip the boolean and the target
-            i = 2;
-        }
-
-        // Handle case when target is a string or something (possible in deep copy)
-        if ( typeof target !== "object" && !toString.call(target) === "[object Function]" ) {
-            target = {};
-        }
-
-        for ( ; i < length; i++ ){
-            // Only deal with non-null/undefined values
-            if ( (options = arguments[ i ]) != null ) {
-                // Extend the base object
-                for ( var name in options ) {
-                    var src = target[ name ], copy = options[ name ];
-
-                    // Prevent never-ending loop
-                    if ( target === copy ) {
-                        continue;
-                    }
-
-                    // Recurse if we're merging object values
-                    if ( deep && copy && typeof copy === "object" && !copy.nodeType ) {
-                        target[ name ] = $.jqplot.extend( deep, 
-                            // Never move original objects, clone them
-                            src || ( copy.length != null ? [ ] : { } )
-                        , copy );
-                    }
-                    // Don't bring in undefined values
-                    else if ( copy !== undefined ) {
-                        target[ name ] = copy;
-                    }
-                }
-            }
-        }
-        // Return the modified object
-        return target;
-    };
-
-    /**
-     * method: rename
-     * 
-     * Rename a theme.
-     * 
-     * parameters:
-     * 
-     * oldName - current name of the theme.
-     * newName - desired name of the theme.
-     * 
-     * returns:
-     * 
-     * new Theme object.
-     */
-    $.jqplot.ThemeEngine.prototype.rename = function (oldName, newName) {
-        if (oldName == 'Default' || newName == 'Default') {
-            throw new Error ("jqplot.ThemeEngine Error: Cannot rename from/to Default");
-        }
-        if (this.themes.hasOwnProperty(newName)) {
-            throw new Error ("jqplot.ThemeEngine Error: New name already in use.");
-        }
-        else if (this.themes.hasOwnProperty(oldName)) {
-            var th = this.copy (oldName, newName);
-            this.remove(oldName);
-            return th;
-        }
-        throw new Error("jqplot.ThemeEngine Error: Old name or new name invalid");
-    };
-
-    /**
-     * method: copy
-     * 
-     * Create a copy of an existing theme in the themeEngine, adding it the themeEngine.
-     * 
-     * parameters:
-     * 
-     * sourceName - name of the existing theme.
-     * targetName - name of the copy.
-     * obj - optional object of style parameter to apply to the new theme.
-     * 
-     * returns:
-     * 
-     * new Theme object.
-     */
-    $.jqplot.ThemeEngine.prototype.copy = function (sourceName, targetName, obj) {
-        if (targetName == 'Default') {
-            throw new Error ("jqplot.ThemeEngine Error: Cannot copy over Default theme");
-        }
-        if (!this.themes.hasOwnProperty(sourceName)) {
-            var s = "jqplot.ThemeEngine Error: Source name invalid";
-            throw new Error(s);
-        }
-        if (this.themes.hasOwnProperty(targetName)) {
-            var s = "jqplot.ThemeEngine Error: Target name invalid";
-            throw new Error(s);
-        }
-        else {
-            var th = clone(this.themes[sourceName]);
-            th._name = targetName;
-            $.jqplot.extend(true, th, obj);
-            this._add(th);
-            return th;
-        }
-    };
-    
-    
-    $.jqplot.Theme = function(name, obj) {
-        if (typeof(name) == 'object') {
-            obj = obj || name;
-            name = null;
-        }
-        name = name || Date.parse(new Date());
-        this._name = name;
-        this.target = {
-            backgroundColor: null
-        };
-        this.legend = {
-            textColor: null,
-            fontFamily: null,
-            fontSize: null,
-            border: null,
-            background: null
-        };
-        this.title = {
-            textColor: null,
-            fontFamily: null,
-            fontSize: null,
-            textAlign: null
-        };
-        this.seriesStyles = {};
-        this.series = [];
-        this.grid = {
-            drawGridlines: null,
-            gridLineColor: null,
-            gridLineWidth: null,
-            backgroundColor: null,
-            borderColor: null,
-            borderWidth: null,
-            shadow: null
-        };
-        this.axesStyles = {label:{}, ticks:{}};
-        this.axes = {};
-        if (typeof(obj) == 'string') {
-            this._name = obj;
-        }
-        else if(typeof(obj) == 'object') {
-            $.jqplot.extend(true, this, obj);
-        }
-    };
-    
-    var AxisProperties = function() {
-        this.borderColor = null;
-        this.borderWidth = null;
-        this.ticks = new AxisTicks();
-        this.label = new AxisLabel();
-    };
-    
-    var AxisTicks = function() {
-        this.show = null;
-        this.showGridline = null;
-        this.showLabel = null;
-        this.showMark = null;
-        this.size = null;
-        this.textColor = null;
-        this.whiteSpace = null;
-        this.fontSize = null;
-        this.fontFamily = null;
-    };
-    
-    var AxisLabel = function() {
-        this.textColor = null;
-        this.whiteSpace = null;
-        this.fontSize = null;
-        this.fontFamily = null;
-        this.fontWeight = null;
-    };
-    
-    var LineSeriesProperties = function() {
-        this.color=null;
-        this.lineWidth=null;
-        this.linePattern=null;
-        this.shadow=null;
-        this.fillColor=null;
-        this.showMarker=null;
-        this.markerOptions = new MarkerOptions();
-    };
-    
-    var MarkerOptions = function() {
-        this.show = null;
-        this.style = null;
-        this.lineWidth = null;
-        this.size = null;
-        this.color = null;
-        this.shadow = null;
-    };
-    
-    var BarSeriesProperties = function() {
-        this.color=null;
-        this.seriesColors=null;
-        this.lineWidth=null;
-        this.shadow=null;
-        this.barPadding=null;
-        this.barMargin=null;
-        this.barWidth=null;
-        this.highlightColors=null;
-    };
-    
-    var PieSeriesProperties = function() {
-        this.seriesColors=null;
-        this.padding=null;
-        this.sliceMargin=null;
-        this.fill=null;
-        this.shadow=null;
-        this.startAngle=null;
-        this.lineWidth=null;
-        this.highlightColors=null;
-    };
-    
-    var DonutSeriesProperties = function() {
-        this.seriesColors=null;
-        this.padding=null;
-        this.sliceMargin=null;
-        this.fill=null;
-        this.shadow=null;
-        this.startAngle=null;
-        this.lineWidth=null;
-        this.innerDiameter=null;
-        this.thickness=null;
-        this.ringMargin=null;
-        this.highlightColors=null;
-    };
-    
-    var FunnelSeriesProperties = function() {
-        this.color=null;
-        this.lineWidth=null;
-        this.shadow=null;
-        this.padding=null;
-        this.sectionMargin=null;
-        this.seriesColors=null;
-        this.highlightColors=null;
-    };
-    
-    var MeterSeriesProperties = function() {
-        this.padding=null;
-        this.backgroundColor=null;
-        this.ringColor=null;
-        this.tickColor=null;
-        this.ringWidth=null;
-        this.intervalColors=null;
-        this.intervalInnerRadius=null;
-        this.intervalOuterRadius=null;
-        this.hubRadius=null;
-        this.needleThickness=null;
-        this.needlePad=null;
-    };
-        
-
-
-
-    $.fn.jqplotChildText = function() {
-        return $(this).contents().filter(function() {
-            return this.nodeType == 3;  // Node.TEXT_NODE not defined in I7
-        }).text();
-    };
-
-    // Returns font style as abbreviation for "font" property.
-    $.fn.jqplotGetComputedFontStyle = function() {
-        var css = window.getComputedStyle ?  window.getComputedStyle(this[0]) : this[0].currentStyle;
-        var attrs = css['font-style'] ? ['font-style', 'font-weight', 'font-size', 'font-family'] : ['fontStyle', 'fontWeight', 'fontSize', 'fontFamily'];
-        var style = [];
-
-        for (var i=0 ; i < attrs.length; ++i) {
-            var attr = String(css[attrs[i]]);
-
-            if (attr && attr != 'normal') {
-                style.push(attr);
-            }
-        }
-        return style.join(' ');
-    };
-
-    /**
-     * Namespace: $.fn
-     * jQuery namespace to attach functions to jQuery elements.
-     *  
-     */
-
-    $.fn.jqplotToImageCanvas = function(options) {
-
-        options = options || {};
-        var x_offset = (options.x_offset == null) ? 0 : options.x_offset;
-        var y_offset = (options.y_offset == null) ? 0 : options.y_offset;
-        var backgroundColor = (options.backgroundColor == null) ? 'rgb(255,255,255)' : options.backgroundColor;
-
-        if ($(this).width() == 0 || $(this).height() == 0) {
-            return null;
-        }
-
-        // excanvas and hence IE < 9 do not support toDataURL and cannot export images.
-        if (!$.jqplot.support_canvas) {
-            return null;
-        }
-        
-        var newCanvas = document.createElement("canvas");
-        var h = $(this).outerHeight(true);
-        var w = $(this).outerWidth(true);
-        var offs = $(this).offset();
-        var plotleft = offs.left;
-        var plottop = offs.top;
-        var transx = 0, transy = 0;
-
-        // have to check if any elements are hanging outside of plot area before rendering,
-        // since changing width of canvas will erase canvas.
-
-        var clses = ['jqplot-table-legend', 'jqplot-xaxis-tick', 'jqplot-x2axis-tick', 'jqplot-yaxis-tick', 'jqplot-y2axis-tick', 'jqplot-y3axis-tick', 
-        'jqplot-y4axis-tick', 'jqplot-y5axis-tick', 'jqplot-y6axis-tick', 'jqplot-y7axis-tick', 'jqplot-y8axis-tick', 'jqplot-y9axis-tick',
-        'jqplot-xaxis-label', 'jqplot-x2axis-label', 'jqplot-yaxis-label', 'jqplot-y2axis-label', 'jqplot-y3axis-label', 'jqplot-y4axis-label', 
-        'jqplot-y5axis-label', 'jqplot-y6axis-label', 'jqplot-y7axis-label', 'jqplot-y8axis-label', 'jqplot-y9axis-label' ];
-
-        var temptop, templeft, tempbottom, tempright;
-
-        for (var i in clses) {
-            $(this).find('.'+clses[i]).each(function() {
-                temptop = $(this).offset().top - plottop;
-                templeft = $(this).offset().left - plotleft;
-                tempright = templeft + $(this).outerWidth(true) + transx;
-                tempbottom = temptop + $(this).outerHeight(true) + transy;
-                if (templeft < -transx) {
-                    w = w - transx - templeft;
-                    transx = -templeft;
-                }
-                if (temptop < -transy) {
-                    h = h - transy - temptop;
-                    transy = - temptop;
-                }
-                if (tempright > w) {
-                    w = tempright;
-                }
-                if (tempbottom > h) {
-                    h =  tempbottom;
-                }
-            });
-        }
-
-        newCanvas.width = w + Number(x_offset);
-        newCanvas.height = h + Number(y_offset);
-
-        var newContext = newCanvas.getContext("2d"); 
-
-        newContext.save();
-        newContext.fillStyle = backgroundColor;
-        newContext.fillRect(0,0, newCanvas.width, newCanvas.height);
-        newContext.restore();
-
-        newContext.translate(transx, transy);
-        newContext.textAlign = 'left';
-        newContext.textBaseline = 'top';
-
-        function getLineheight(el) {
-            var lineheight = parseInt($(el).css('line-height'));
-
-            if (isNaN(lineheight)) {
-                lineheight = parseInt($(el).css('font-size')) * 1.2;
-            }
-            return lineheight;
-        }
-
-        function writeWrappedText (el, context, text, left, top, canvasWidth) {
-            var lineheight = getLineheight(el);
-            var tagwidth = $(el).innerWidth();
-            var tagheight = $(el).innerHeight();
-            var words = text.split(/\s+/);
-            var wl = words.length;
-            var w = '';
-            var breaks = [];
-            var temptop = top;
-            var templeft = left;
-
-            for (var i=0; i<wl; i++) {
-                w += words[i];
-                if (context.measureText(w).width > tagwidth) {
-                    breaks.push(i);
-                    w = '';
-                }   
-            }
-            if (breaks.length === 0) {
-                // center text if necessary
-                if ($(el).css('textAlign') === 'center') {
-                    templeft = left + (canvasWidth - context.measureText(w).width)/2  - transx;
-                }
-                context.fillText(text, templeft, top);
-            }
-            else {
-                w = words.slice(0, breaks[0]).join(' ');
-                // center text if necessary
-                if ($(el).css('textAlign') === 'center') {
-                    templeft = left + (canvasWidth - context.measureText(w).width)/2  - transx;
-                }
-                context.fillText(w, templeft, temptop);
-                temptop += lineheight;
-                for (var i=1, l=breaks.length; i<l; i++) {
-                    w = words.slice(breaks[i-1], breaks[i]).join(' ');
-                    // center text if necessary
-                    if ($(el).css('textAlign') === 'center') {
-                        templeft = left + (canvasWidth - context.measureText(w).width)/2  - transx;
-                    }
-                    context.fillText(w, templeft, temptop);
-                    temptop += lineheight;
-                }
-                w = words.slice(breaks[i-1], words.length).join(' ');
-                // center text if necessary
-                if ($(el).css('textAlign') === 'center') {
-                    templeft = left + (canvasWidth - context.measureText(w).width)/2  - transx;
-                }
-                context.fillText(w, templeft, temptop);
-            }
-
-        }
-
-        function _jqpToImage(el, x_offset, y_offset) {
-            var tagname = el.tagName.toLowerCase();
-            var p = $(el).position();
-            var css = window.getComputedStyle ?  window.getComputedStyle(el) : el.currentStyle; // for IE < 9
-            var left = x_offset + p.left + parseInt(css.marginLeft) + parseInt(css.borderLeftWidth) + parseInt(css.paddingLeft);
-            var top = y_offset + p.top + parseInt(css.marginTop) + parseInt(css.borderTopWidth)+ parseInt(css.paddingTop);
-            var w = newCanvas.width;
-            // var left = x_offset + p.left + $(el).css('marginLeft') + $(el).css('borderLeftWidth') 
-
-            if ((tagname == 'div' || tagname == 'span') && !$(el).hasClass('jqplot-highlighter-tooltip')) {
-                $(el).children().each(function() {
-                    _jqpToImage(this, left, top);
-                });
-                var text = $(el).jqplotChildText();
-
-                if (text) {
-                    newContext.font = $(el).jqplotGetComputedFontStyle();
-                    newContext.fillStyle = $(el).css('color');
-
-                    writeWrappedText(el, newContext, text, left, top, w);
-                }
-            }
-
-            // handle the standard table legend
-
-            else if (tagname === 'table' && $(el).hasClass('jqplot-table-legend')) {
-                newContext.strokeStyle = $(el).css('border-top-color');
-                newContext.fillStyle = $(el).css('background-color');
-                newContext.fillRect(left, top, $(el).innerWidth(), $(el).innerHeight());
-                if (parseInt($(el).css('border-top-width')) > 0) {
-                    newContext.strokeRect(left, top, $(el).innerWidth(), $(el).innerHeight());
-                }
-
-                // find all the swatches
-                $(el).find('div.jqplot-table-legend-swatch-outline').each(function() {
-                    // get the first div and stroke it
-                    var elem = $(this);
-                    newContext.strokeStyle = elem.css('border-top-color');
-                    var l = left + elem.position().left;
-                    var t = top + elem.position().top;
-                    newContext.strokeRect(l, t, elem.innerWidth(), elem.innerHeight());
-
-                    // now fill the swatch
-                    
-                    l += parseInt(elem.css('padding-left'));
-                    t += parseInt(elem.css('padding-top'));
-                    var h = elem.innerHeight() - 2 * parseInt(elem.css('padding-top'));
-                    var w = elem.innerWidth() - 2 * parseInt(elem.css('padding-left'));
-
-                    var swatch = elem.children('div.jqplot-table-legend-swatch');
-                    newContext.fillStyle = swatch.css('background-color');
-                    newContext.fillRect(l, t, w, h);
-                });
-
-                // now add text
-
-                $(el).find('td.jqplot-table-legend-label').each(function(){
-                    var elem = $(this);
-                    var l = left + elem.position().left;
-                    var t = top + elem.position().top + parseInt(elem.css('padding-top'));
-                    newContext.font = elem.jqplotGetComputedFontStyle();
-                    newContext.fillStyle = elem.css('color');
-                    newContext.fillText(elem.text(), l, t);
-                });
-
-                var elem = null;
-            }
-
-            else if (tagname == 'canvas') {
-                newContext.drawImage(el, left, top);
-            }
-        }
-        $(this).children().each(function() {
-            _jqpToImage(this, x_offset, y_offset);
-        });
-        return newCanvas;
-    };
-
-    $.fn.jqplotToImageStr = function(options) {
-        var imgCanvas = $(this).jqplotToImageCanvas(options);
-        if (imgCanvas) {
-            return imgCanvas.toDataURL("image/png");
-        }
-        else {
-            return null;
-        }
-    };
-
-    // create an <img> element and return it.
-    // Should work on canvas supporting browsers.
-    $.fn.jqplotToImageElem = function(options) {
-        var elem = document.createElement("img");
-        var str = $(this).jqplotToImageStr(options);
-        elem.src = str;
-        return elem;
-    };
-
-    // create an <img> element and return it.
-    // Should work on canvas supporting browsers.
-    $.fn.jqplotToImageElemStr = function(options) {
-        var str = '<img src='+$(this).jqplotToImageStr(options)+' />';
-        return str;
-    };
-
-    // Not gauranteed to work, even on canvas supporting browsers due to 
-    // limitations with location.href and browser support.
-    $.fn.jqplotSaveImage = function() {
-        var imgData = $(this).jqplotToImageStr({});
-        if (imgData) {
-            window.location.href = imgData.replace("image/png", "image/octet-stream");
-        }
-
-    };
-
-    // Not gauranteed to work, even on canvas supporting browsers due to
-    // limitations with window.open and arbitrary data.
-    $.fn.jqplotViewImage = function() {
-        var imgStr = $(this).jqplotToImageElemStr({});
-        var imgData = $(this).jqplotToImageStr({});
-        if (imgStr) {
-            var w = window.open('');
-            w.document.open("image/png");
-            w.document.write(imgStr);
-            w.document.close();
-            w = null;
-        }
-    };
-    
-
-
-    /** 
-     * @description
-     * <p>Object with extended date parsing and formatting capabilities.
-     * This library borrows many concepts and ideas from the Date Instance 
-     * Methods by Ken Snyder along with some parts of Ken's actual code.</p>
-     *
-     * <p>jsDate takes a different approach by not extending the built-in 
-     * Date Object, improving date parsing, allowing for multiple formatting 
-     * syntaxes and multiple and more easily expandable localization.</p>
-     * 
-     * @author Chris Leonello
-     * @date #date#
-     * @version #VERSION#
-     * @copyright (c) 2010 Chris Leonello
-     * jsDate is currently available for use in all personal or commercial projects 
-     * under both the MIT and GPL version 2.0 licenses. This means that you can 
-     * choose the license that best suits your project and use it accordingly.
-     * 
-     * <p>Ken's origianl Date Instance Methods and copyright notice:</p>
-     * <pre>
-     * Ken Snyder (ken d snyder at gmail dot com)
-     * 2008-09-10
-     * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
-     * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
-     * </pre>
-     * 
-     * @class
-     * @name jsDate
-     * @param  {String | Number | Array | Date&nbsp;Object | Options&nbsp;Object} arguments Optional arguments, either a parsable date/time string,
-     * a JavaScript timestamp, an array of numbers of form [year, month, day, hours, minutes, seconds, milliseconds],
-     * a Date object, or an options object of form {syntax: "perl", date:some Date} where all options are optional.
-     */
-     
-    var jsDate = function () {
-    
-        this.syntax = jsDate.config.syntax;
-        this._type = "jsDate";
-        this.utcOffset = new Date().getTimezoneOffset * 60000;
-        this.proxy = new Date();
-        this.options = {};
-        this.locale = jsDate.regional.getLocale();
-        this.formatString = '';
-        this.defaultCentury = jsDate.config.defaultCentury;
-
-        switch ( arguments.length ) {
-            case 0:
-                break;
-            case 1:
-                // other objects either won't have a _type property or,
-                // if they do, it shouldn't be set to "jsDate", so
-                // assume it is an options argument.
-                if (get_type(arguments[0]) == "[object Object]" && arguments[0]._type != "jsDate") {
-                    var opts = this.options = arguments[0];
-                    this.syntax = opts.syntax || this.syntax;
-                    this.defaultCentury = opts.defaultCentury || this.defaultCentury;
-                    this.proxy = jsDate.createDate(opts.date);
-                }
-                else {
-                    this.proxy = jsDate.createDate(arguments[0]);
-                }
-                break;
-            default:
-                var a = [];
-                for ( var i=0; i<arguments.length; i++ ) {
-                    a.push(arguments[i]);
-                }
-                this.proxy = new Date( this.utcOffset );
-                this.proxy.setFullYear.apply( this.proxy, a.slice(0,3) );
-                if ( a.slice(3).length ) {
-                    this.proxy.setHours.apply( this.proxy, a.slice(3) );
-                }
-                break;
-        }
-    };
-    
-    /**
-     * @namespace Configuration options that will be used as defaults for all instances on the page.
-     * @property {String} defaultLocale The default locale to use [en].
-     * @property {String} syntax The default syntax to use [perl].
-     */
-    jsDate.config = {
-        defaultLocale: 'en',
-        syntax: 'perl',
-        defaultCentury: 1900
-    };
-        
-    /**
-     * Add an arbitrary amount to the currently stored date
-     * 
-     * @param {Number} number      
-     * @param {String} unit
-     * @returns {jsDate}       
-     */
-     
-    jsDate.prototype.add = function(number, unit) {
-        var factor = multipliers[unit] || multipliers.day;
-        if (typeof factor == 'number') {
-            this.proxy.setTime(this.proxy.getTime() + (factor * number));
-        } else {
-            factor.add(this, number);
-        }
-        return this;
-    };
-        
-    /**
-     * Create a new jqplot.date object with the same date
-     * 
-     * @returns {jsDate}
-     */  
-     
-    jsDate.prototype.clone = function() {
-            return new jsDate(this.proxy.getTime());
-    };
-
-    /**
-     * Find the difference between this jsDate and another date.
-     * 
-     * @param {String| Number| Array| jsDate&nbsp;Object| Date&nbsp;Object} dateObj
-     * @param {String} unit
-     * @param {Boolean} allowDecimal
-     * @returns {Number} Number of units difference between dates.
-     */
-     
-    jsDate.prototype.diff = function(dateObj, unit, allowDecimal) {
-        // ensure we have a Date object
-        dateObj = new jsDate(dateObj);
-        if (dateObj === null) {
-            return null;
-        }
-        // get the multiplying factor integer or factor function
-        var factor = multipliers[unit] || multipliers.day;
-        if (typeof factor == 'number') {
-            // multiply
-            var unitDiff = (this.proxy.getTime() - dateObj.proxy.getTime()) / factor;
-        } else {
-            // run function
-            var unitDiff = factor.diff(this.proxy, dateObj.proxy);
-        }
-        // if decimals are not allowed, round toward zero
-        return (allowDecimal ? unitDiff : Math[unitDiff > 0 ? 'floor' : 'ceil'](unitDiff));          
-    };
-    
-    /**
-     * Get the abbreviated name of the current week day
-     * 
-     * @returns {String}
-     */   
-     
-    jsDate.prototype.getAbbrDayName = function() {
-        return jsDate.regional[this.locale]["dayNamesShort"][this.proxy.getDay()];
-    };
-    
-    /**
-     * Get the abbreviated name of the current month
-     * 
-     * @returns {String}
-     */
-     
-    jsDate.prototype.getAbbrMonthName = function() {
-        return jsDate.regional[this.locale]["monthNamesShort"][this.proxy.getMonth()];
-    };
-    
-    /**
-     * Get UPPER CASE AM or PM for the current time
-     * 
-     * @returns {String}
-     */
-     
-    jsDate.prototype.getAMPM = function() {
-        return this.proxy.getHours() >= 12 ? 'PM' : 'AM';
-    };
-    
-    /**
-     * Get lower case am or pm for the current time
-     * 
-     * @returns {String}
-     */
-     
-    jsDate.prototype.getAmPm = function() {
-        return this.proxy.getHours() >= 12 ? 'pm' : 'am';
-    };
-    
-    /**
-     * Get the century (19 for 20th Century)
-     *
-     * @returns {Integer} Century (19 for 20th century).
-     */
-    jsDate.prototype.getCentury = function() { 
-        return parseInt(this.proxy.getFullYear()/100, 10);
-    };
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getDate = function() {
-        return this.proxy.getDate();
-    };
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getDay = function() {
-        return this.proxy.getDay();
-    };
-    
-    /**
-     * Get the Day of week 1 (Monday) thru 7 (Sunday)
-     * 
-     * @returns {Integer} Day of week 1 (Monday) thru 7 (Sunday)
-     */
-    jsDate.prototype.getDayOfWeek = function() { 
-        var dow = this.proxy.getDay(); 
-        return dow===0?7:dow; 
-    };
-    
-    /**
-     * Get the day of the year
-     * 
-     * @returns {Integer} 1 - 366, day of the year
-     */
-    jsDate.prototype.getDayOfYear = function() {
-        var d = this.proxy;
-        var ms = d - new Date('' + d.getFullYear() + '/1/1 GMT');
-        ms += d.getTimezoneOffset()*60000;
-        d = null;
-        return parseInt(ms/60000/60/24, 10)+1;
-    };
-    
-    /**
-     * Get the name of the current week day
-     * 
-     * @returns {String}
-     */  
-     
-    jsDate.prototype.getDayName = function() {
-        return jsDate.regional[this.locale]["dayNames"][this.proxy.getDay()];
-    };
-    
-    /**
-     * Get the week number of the given year, starting with the first Sunday as the first week
-     * @returns {Integer} Week number (13 for the 13th full week of the year).
-     */
-    jsDate.prototype.getFullWeekOfYear = function() {
-        var d = this.proxy;
-        var doy = this.getDayOfYear();
-        var rdow = 6-d.getDay();
-        var woy = parseInt((doy+rdow)/7, 10);
-        return woy;
-    };
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getFullYear = function() {
-        return this.proxy.getFullYear();
-    };
-    
-    /**
-     * Get the GMT offset in hours and minutes (e.g. +06:30)
-     * 
-     * @returns {String}
-     */
-     
-    jsDate.prototype.getGmtOffset = function() {
-        // divide the minutes offset by 60
-        var hours = this.proxy.getTimezoneOffset() / 60;
-        // decide if we are ahead of or behind GMT
-        var prefix = hours < 0 ? '+' : '-';
-        // remove the negative sign if any
-        hours = Math.abs(hours);
-        // add the +/- to the padded number of hours to : to the padded minutes
-        return prefix + addZeros(Math.floor(hours), 2) + ':' + addZeros((hours % 1) * 60, 2);
-    };
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getHours = function() {
-        return this.proxy.getHours();
-    };
-    
-    /**
-     * Get the current hour on a 12-hour scheme
-     * 
-     * @returns {Integer}
-     */
-     
-    jsDate.prototype.getHours12  = function() {
-        var hours = this.proxy.getHours();
-        return hours > 12 ? hours - 12 : (hours == 0 ? 12 : hours);
-    };
-    
-    
-    jsDate.prototype.getIsoWeek = function() {
-        var d = this.proxy;
-        var woy = d.getWeekOfYear();
-        var dow1_1 = (new Date('' + d.getFullYear() + '/1/1')).getDay();
-        // First week is 01 and not 00 as in the case of %U and %W,
-        // so we add 1 to the final result except if day 1 of the year
-        // is a Monday (then %W returns 01).
-        // We also need to subtract 1 if the day 1 of the year is 
-        // Friday-Sunday, so the resulting equation becomes:
-        var idow = woy + (dow1_1 > 4 || dow1_1 <= 1 ? 0 : 1);
-        if(idow == 53 && (new Date('' + d.getFullYear() + '/12/31')).getDay() < 4)
-        {
-            idow = 1;
-        }
-        else if(idow === 0)
-        {
-            d = new jsDate(new Date('' + (d.getFullYear()-1) + '/12/31'));
-            idow = d.getIsoWeek();
-        }
-        d = null;
-        return idow;
-    };
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getMilliseconds = function() {
-        return this.proxy.getMilliseconds();
-    };
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getMinutes = function() {
-        return this.proxy.getMinutes();
-    };
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getMonth = function() {
-        return this.proxy.getMonth();
-    };
-    
-    /**
-     * Get the name of the current month
-     * 
-     * @returns {String}
-     */
-     
-    jsDate.prototype.getMonthName = function() {
-        return jsDate.regional[this.locale]["monthNames"][this.proxy.getMonth()];
-    };
-    
-    /**
-     * Get the number of the current month, 1-12
-     * 
-     * @returns {Integer}
-     */
-     
-    jsDate.prototype.getMonthNumber = function() {
-        return this.proxy.getMonth() + 1;
-    };
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getSeconds = function() {
-        return this.proxy.getSeconds();
-    };
-    
-    /**
-     * Return a proper two-digit year integer
-     * 
-     * @returns {Integer}
-     */
-     
-    jsDate.prototype.getShortYear = function() {
-        return this.proxy.getYear() % 100;
-    };
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getTime = function() {
-        return this.proxy.getTime();
-    };
-    
-    /**
-     * Get the timezone abbreviation
-     *
-     * @returns {String} Abbreviation for the timezone
-     */
-    jsDate.prototype.getTimezoneAbbr = function() {
-        return this.proxy.toString().replace(/^.*\(([^)]+)\)$/, '$1'); 
-    };
-    
-    /**
-     * Get the browser-reported name for the current timezone (e.g. MDT, Mountain Daylight Time)
-     * 
-     * @returns {String}
-     */
-    jsDate.prototype.getTimezoneName = function() {
-        var match = /(?:\((.+)\)$| ([A-Z]{3}) )/.exec(this.toString());
-        return match[1] || match[2] || 'GMT' + this.getGmtOffset();
-    }; 
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getTimezoneOffset = function() {
-        return this.proxy.getTimezoneOffset();
-    };
-    
-    
-    /**
-     * Get the week number of the given year, starting with the first Monday as the first week
-     * @returns {Integer} Week number (13 for the 13th week of the year).
-     */
-    jsDate.prototype.getWeekOfYear = function() {
-        var doy = this.getDayOfYear();
-        var rdow = 7 - this.getDayOfWeek();
-        var woy = parseInt((doy+rdow)/7, 10);
-        return woy;
-    };
-    
-    /**
-     * Get the current date as a Unix timestamp
-     * 
-     * @returns {Integer}
-     */
-     
-    jsDate.prototype.getUnix = function() {
-        return Math.round(this.proxy.getTime() / 1000, 0);
-    }; 
-    
-    /**
-     * Implements Date functionality
-     */
-    jsDate.prototype.getYear = function() {
-        return this.proxy.getYear();
-    };
-    
-    /**
-     * Return a date one day ahead (or any other unit)
-     * 
-     * @param {String} unit Optional, year | month | day | week | hour | minute | second | millisecond
-     * @returns {jsDate}
-     */
-     
-    jsDate.prototype.next = function(unit) {
-        unit = unit || 'day';
-        return this.clone().add(1, unit);
-    };
-    
-    /**
-     * Set the jsDate instance to a new date.
-     *
-     * @param  {String | Number | Array | Date Object | jsDate Object | Options Object} arguments Optional arguments, 
-     * either a parsable date/time string,
-     * a JavaScript timestamp, an array of numbers of form [year, month, day, hours, minutes, seconds, milliseconds],
-     * a Date object, jsDate Object or an options object of form {syntax: "perl", date:some Date} where all options are optional.
-     */
-    jsDate.prototype.set = function() {
-        switch ( arguments.length ) {
-            case 0:
-                this.proxy = new Date();
-                break;
-            case 1:
-                // other objects either won't have a _type property or,
-                // if they do, it shouldn't be set to "jsDate", so
-                // assume it is an options argument.
-                if (get_type(arguments[0]) == "[object Object]" && arguments[0]._type != "jsDate") {
-                    var opts = this.options = arguments[0];
-                    this.syntax = opts.syntax || this.syntax;
-                    this.defaultCentury = opts.defaultCentury || this.defaultCentury;
-                    this.proxy = jsDate.createDate(opts.date);
-                }
-                else {
-                    this.proxy = jsDate.createDate(arguments[0]);
-                }
-                break;
-            default:
-                var a = [];
-                for ( var i=0; i<arguments.length; i++ ) {
-                    a.push(arguments[i]);
-                }
-                this.proxy = new Date( this.utcOffset );
-                this.proxy.setFullYear.apply( this.proxy, a.slice(0,3) );
-                if ( a.slice(3).length ) {
-                    this.proxy.setHours.apply( this.proxy, a.slice(3) );
-                }
-                break;
-        }
-    };
-    
-    /**
-     * Sets the day of the month for a specified date according to local time.
-     * @param {Integer} dayValue An integer from 1 to 31, representing the day of the month. 
-     */
-    jsDate.prototype.setDate = function(n) {
-        return this.proxy.setDate(n);
-    };
-    
-    /**
-     * Sets the full year for a specified date according to local time.
-     * @param {Integer} yearValue The numeric value of the year, for example, 1995.  
-     * @param {Integer} monthValue Optional, between 0 and 11 representing the months January through December.  
-     * @param {Integer} dayValue Optional, between 1 and 31 representing the day of the month. If you specify the dayValue parameter, you must also specify the monthValue. 
-     */
-    jsDate.prototype.setFullYear = function() {
-        return this.proxy.setFullYear.apply(this.proxy, arguments);
-    };
-    
-    /**
-     * Sets the hours for a specified date according to local time.
-     * 
-     * @param {Integer} hoursValue An integer between 0 and 23, representing the hour.  
-     * @param {Integer} minutesValue Optional, An integer between 0 and 59, representing the minutes.  
-     * @param {Integer} secondsValue Optional, An integer between 0 and 59, representing the seconds. 
-     * If you specify the secondsValue parameter, you must also specify the minutesValue.  
-     * @param {Integer} msValue Optional, A number between 0 and 999, representing the milliseconds. 
-     * If you specify the msValue parameter, you must also specify the minutesValue and secondsValue. 
-     */
-    jsDate.prototype.setHours = function() {
-        return this.proxy.setHours.apply(this.proxy, arguments);
-    };
-    
-    /**
-     * Implements Date functionality
-     */ 
-    jsDate.prototype.setMilliseconds = function(n) {
-        return this.proxy.setMilliseconds(n);
-    };
-    
-    /**
-     * Implements Date functionality
-     */ 
-    jsDate.prototype.setMinutes = function() {
-        return this.proxy.setMinutes.apply(this.proxy, arguments);
-    };
-    
-    /**
-     * Implements Date functionality
-     */ 
-    jsDate.prototype.setMonth = function() {
-        return this.proxy.setMonth.apply(this.proxy, arguments);
-    };
-    
-    /**
-     * Implements Date functionality
-     */ 
-    jsDate.prototype.setSeconds = function() {
-        return this.proxy.setSeconds.apply(this.proxy, arguments);
-    };
-    
-    /**
-     * Implements Date functionality
-     */ 
-    jsDate.prototype.setTime = function(n) {
-        return this.proxy.setTime(n);
-    };
-    
-    /**
-     * Implements Date functionality
-     */ 
-    jsDate.prototype.setYear = function() {
-        return this.proxy.setYear.apply(this.proxy, arguments);
-    };
-    
-    /**
-     * Provide a formatted string representation of this date.
-     * 
-     * @param {String} formatString A format string.  
-     * See: {@link jsDate.formats}.
-     * @returns {String} Date String.
-     */
-            
-    jsDate.prototype.strftime = function(formatString) {
-        formatString = formatString || this.formatString || jsDate.regional[this.locale]['formatString'];
-        return jsDate.strftime(this, formatString, this.syntax);
-    };
-        
-    /**
-     * Return a String representation of this jsDate object.
-     * @returns {String} Date string.
-     */
-    
-    jsDate.prototype.toString = function() {
-        return this.proxy.toString();
-    };
-        
-    /**
-     * Convert the current date to an 8-digit integer (%Y%m%d)
-     * 
-     * @returns {Integer}
-     */
-     
-    jsDate.prototype.toYmdInt = function() {
-        return (this.proxy.getFullYear() * 10000) + (this.getMonthNumber() * 100) + this.proxy.getDate();
-    };
-    
-    /**
-     * @namespace Holds localizations for month/day names.
-     * <p>jsDate attempts to detect locale when loaded and defaults to 'en'.
-     * If a localization is detected which is not available, jsDate defaults to 'en'.
-     * Additional localizations can be added after jsDate loads.  After adding a localization,
-     * call the jsDate.regional.getLocale() method.  Currently, en, fr and de are defined.</p>
-     * 
-     * <p>Localizations must be an object and have the following properties defined:  monthNames, monthNamesShort, dayNames, dayNamesShort and Localizations are added like:</p>
-     * <pre class="code">
-     * jsDate.regional['en'] = {
-     * monthNames      : 'January February March April May June July August September October November December'.split(' '),
-     * monthNamesShort : 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' '),
-     * dayNames        : 'Sunday Monday Tuesday Wednesday Thursday Friday Saturday'.split(' '),
-     * dayNamesShort   : 'Sun Mon Tue Wed Thu Fri Sat'.split(' ')
-     * };
-     * </pre>
-     * <p>After adding localizations, call <code>jsDate.regional.getLocale();</code> to update the locale setting with the
-     * new localizations.</p>
-     */
-     
-    jsDate.regional = {
-        'en': {
-            monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'],
-            monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun','Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
-            dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
-            dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
-            formatString: '%Y-%m-%d %H:%M:%S'
-        },
-        
-        'fr': {
-            monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
-            monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun','Jul','Aoû','Sep','Oct','Nov','Déc'],
-            dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
-            dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
-            formatString: '%Y-%m-%d %H:%M:%S'
-        },
-        
-        'de': {
-            monthNames: ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
-            monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'],
-            dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
-            dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
-            formatString: '%Y-%m-%d %H:%M:%S'
-        },
-        
-        'es': {
-            monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio', 'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
-            monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun', 'Jul','Ago','Sep','Oct','Nov','Dic'],
-            dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
-            dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacute;b'],
-            formatString: '%Y-%m-%d %H:%M:%S'
-        },
-        
-        'ru': {
-            monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
-            monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн','Июл','Авг','Сен','Окт','Ноя','Дек'],
-            dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'],
-            dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'],
-            formatString: '%Y-%m-%d %H:%M:%S'
-        },
-        
-        'ar': {
-            monthNames: ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'آذار', 'حزيران','تموز', 'آب', 'أيلول',   'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
-            monthNamesShort: ['1','2','3','4','5','6','7','8','9','10','11','12'],
-            dayNames: ['السبت', 'الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة'],
-            dayNamesShort: ['سبت', 'أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة'],
-            formatString: '%Y-%m-%d %H:%M:%S'
-        },
-        
-        'pt': {
-            monthNames: ['Janeiro','Fevereiro','Mar&ccedil;o','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
-            monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
-            dayNames: ['Domingo','Segunda-feira','Ter&ccedil;a-feira','Quarta-feira','Quinta-feira','Sexta-feira','S&aacute;bado'],
-            dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','S&aacute;b'],
-            formatString: '%Y-%m-%d %H:%M:%S'   
-        },
-        
-        'pt-BR': {
-            monthNames: ['Janeiro','Fevereiro','Mar&ccedil;o','Abril','Maio','Junho', 'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
-            monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
-            dayNames: ['Domingo','Segunda-feira','Ter&ccedil;a-feira','Quarta-feira','Quinta-feira','Sexta-feira','S&aacute;bado'],
-            dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','S&aacute;b'],
-            formatString: '%Y-%m-%d %H:%M:%S'
-        }
-        
-    
-    };
-    
-    // Set english variants to 'en'
-    jsDate.regional['en-US'] = jsDate.regional['en-GB'] = jsDate.regional['en'];
-    
-    /**
-     * Try to determine the users locale based on the lang attribute of the html page.  Defaults to 'en'
-     * if it cannot figure out a locale of if the locale does not have a localization defined.
-     * @returns {String} locale
-     */
-     
-    jsDate.regional.getLocale = function () {
-        var l = jsDate.config.defaultLocale;
-        
-        if ( document && document.getElementsByTagName('html') && document.getElementsByTagName('html')[0].lang ) {
-            l = document.getElementsByTagName('html')[0].lang;
-            if (!jsDate.regional.hasOwnProperty(l)) {
-                l = jsDate.config.defaultLocale;
-            }
-        }
-        
-        return l;
-    };
-    
-    // ms in day
-    var day = 24 * 60 * 60 * 1000;
-    
-    // padd a number with zeros
-    var addZeros = function(num, digits) {
-        num = String(num);
-        var i = digits - num.length;
-        var s = String(Math.pow(10, i)).slice(1);
-        return s.concat(num);
-    };
-
-    // representations used for calculating differences between dates.
-    // This borrows heavily from Ken Snyder's work.
-    var multipliers = {
-        millisecond: 1,
-        second: 1000,
-        minute: 60 * 1000,
-        hour: 60 * 60 * 1000,
-        day: day,
-        week: 7 * day,
-        month: {
-            // add a number of months
-            add: function(d, number) {
-                // add any years needed (increments of 12)
-                multipliers.year.add(d, Math[number > 0 ? 'floor' : 'ceil'](number / 12));
-                // ensure that we properly wrap betwen December and January
-                var prevMonth = d.getMonth() + (number % 12);
-                if (prevMonth == 12) {
-                    prevMonth = 0;
-                    d.setYear(d.getFullYear() + 1);
-                } else if (prevMonth == -1) {
-                    prevMonth = 11;
-                    d.setYear(d.getFullYear() - 1);
-                }
-                d.setMonth(prevMonth);
-            },
-            // get the number of months between two Date objects (decimal to the nearest day)
-            diff: function(d1, d2) {
-                // get the number of years
-                var diffYears = d1.getFullYear() - d2.getFullYear();
-                // get the number of remaining months
-                var diffMonths = d1.getMonth() - d2.getMonth() + (diffYears * 12);
-                // get the number of remaining days
-                var diffDays = d1.getDate() - d2.getDate();
-                // return the month difference with the days difference as a decimal
-                return diffMonths + (diffDays / 30);
-            }
-        },
-        year: {
-            // add a number of years
-            add: function(d, number) {
-                d.setYear(d.getFullYear() + Math[number > 0 ? 'floor' : 'ceil'](number));
-            },
-            // get the number of years between two Date objects (decimal to the nearest day)
-            diff: function(d1, d2) {
-                return multipliers.month.diff(d1, d2) / 12;
-            }
-        }        
-    };
-    //
-    // Alias each multiplier with an 's' to allow 'year' and 'years' for example.
-    // This comes from Ken Snyders work.
-    //
-    for (var unit in multipliers) {
-        if (unit.substring(unit.length - 1) != 's') { // IE will iterate newly added properties :|
-            multipliers[unit + 's'] = multipliers[unit];
-        }
-    }
-    
-    //
-    // take a jsDate instance and a format code and return the formatted value.
-    // This is a somewhat modified version of Ken Snyder's method.
-    //
-    var format = function(d, code, syntax) {
-        // if shorcut codes are used, recursively expand those.
-        if (jsDate.formats[syntax]["shortcuts"][code]) {
-            return jsDate.strftime(d, jsDate.formats[syntax]["shortcuts"][code], syntax);
-        } else {
-            // get the format code function and addZeros() argument
-            var getter = (jsDate.formats[syntax]["codes"][code] || '').split('.');
-            var nbr = d['get' + getter[0]] ? d['get' + getter[0]]() : '';
-            if (getter[1]) {
-                nbr = addZeros(nbr, getter[1]);
-            }
-            return nbr;
-        }       
-    };
-    
-    /**
-     * @static
-     * Static function for convert a date to a string according to a given format.  Also acts as namespace for strftime format codes.
-     * <p>strftime formatting can be accomplished without creating a jsDate object by calling jsDate.strftime():</p>
-     * <pre class="code">
-     * var formattedDate = jsDate.strftime('Feb 8, 2006 8:48:32', '%Y-%m-%d %H:%M:%S');
-     * </pre>
-     * @param {String | Number | Array | jsDate&nbsp;Object | Date&nbsp;Object} date A parsable date string, JavaScript time stamp, Array of form [year, month, day, hours, minutes, seconds, milliseconds], jsDate Object or Date object.
-     * @param {String} formatString String with embedded date formatting codes.  
-     * See: {@link jsDate.formats}. 
-     * @param {String} syntax Optional syntax to use [default perl].
-     * @param {String} locale Optional locale to use.
-     * @returns {String} Formatted representation of the date.
-    */
-    //
-    // Logic as implemented here is very similar to Ken Snyder's Date Instance Methods.
-    //
-    jsDate.strftime = function(d, formatString, syntax, locale) {
-        var syn = 'perl';
-        var loc = jsDate.regional.getLocale();
-        
-        // check if syntax and locale are available or reversed
-        if (syntax && jsDate.formats.hasOwnProperty(syntax)) {
-            syn = syntax;
-        }
-        else if (syntax && jsDate.regional.hasOwnProperty(syntax)) {
-            loc = syntax;
-        }
-        
-        if (locale && jsDate.formats.hasOwnProperty(locale)) {
-            syn = locale;
-        }
-        else if (locale && jsDate.regional.hasOwnProperty(locale)) {
-            loc = locale;
-        }
-        
-        if (get_type(d) != "[object Object]" || d._type != "jsDate") {
-            d = new jsDate(d);
-            d.locale = loc;
-        }
-        if (!formatString) {
-            formatString = d.formatString || jsDate.regional[loc]['formatString'];
-        }
-        // default the format string to year-month-day
-        var source = formatString || '%Y-%m-%d', 
-            result = '', 
-            match;
-        // replace each format code
-        while (source.length > 0) {
-            if (match = source.match(jsDate.formats[syn].codes.matcher)) {
-                result += source.slice(0, match.index);
-                result += (match[1] || '') + format(d, match[2], syn);
-                source = source.slice(match.index + match[0].length);
-            } else {
-                result += source;
-                source = '';
-            }
-        }
-        return result;
-    };
-    
-    /**
-     * @namespace
-     * Namespace to hold format codes and format shortcuts.  "perl" and "php" format codes 
-     * and shortcuts are defined by default.  Additional codes and shortcuts can be
-     * added like:
-     * 
-     * <pre class="code">
-     * jsDate.formats["perl"] = {
-     *     "codes": {
-     *         matcher: /someregex/,
-     *         Y: "fullYear",  // name of "get" method without the "get",
-     *         ...,            // more codes
-     *     },
-     *     "shortcuts": {
-     *         F: '%Y-%m-%d',
-     *         ...,            // more shortcuts
-     *     }
-     * };
-     * </pre>
-     * 
-     * <p>Additionally, ISO and SQL shortcuts are defined and can be accesses via:
-     * <code>jsDate.formats.ISO</code> and <code>jsDate.formats.SQL</code>
-     */
-    
-    jsDate.formats = {
-        ISO:'%Y-%m-%dT%H:%M:%S.%N%G',
-        SQL:'%Y-%m-%d %H:%M:%S'
-    };
-    
-    /**
-     * Perl format codes and shortcuts for strftime.
-     * 
-     * A hash (object) of codes where each code must be an array where the first member is 
-     * the name of a Date.prototype or jsDate.prototype function to call
-     * and optionally a second member indicating the number to pass to addZeros()
-     * 
-     * <p>The following format codes are defined:</p>
-     * 
-     * <pre class="code">
-     * Code    Result                    Description
-     * == Years ==           
-     * %Y      2008                      Four-digit year
-     * %y      08                        Two-digit year
-     * 
-     * == Months ==          
-     * %m      09                        Two-digit month
-     * %#m     9                         One or two-digit month
-     * %B      September                 Full month name
-     * %b      Sep                       Abbreviated month name
-     * 
-     * == Days ==            
-     * %d      05                        Two-digit day of month
-     * %#d     5                         One or two-digit day of month
-     * %e      5                         One or two-digit day of month
-     * %A      Sunday                    Full name of the day of the week
-     * %a      Sun                       Abbreviated name of the day of the week
-     * %w      0                         Number of the day of the week (0 = Sunday, 6 = Saturday)
-     * 
-     * == Hours ==           
-     * %H      23                        Hours in 24-hour format (two digits)
-     * %#H     3                         Hours in 24-hour integer format (one or two digits)
-     * %I      11                        Hours in 12-hour format (two digits)
-     * %#I     3                         Hours in 12-hour integer format (one or two digits)
-     * %p      PM                        AM or PM
-     * 
-     * == Minutes ==         
-     * %M      09                        Minutes (two digits)
-     * %#M     9                         Minutes (one or two digits)
-     * 
-     * == Seconds ==         
-     * %S      02                        Seconds (two digits)
-     * %#S     2                         Seconds (one or two digits)
-     * %s      1206567625723             Unix timestamp (Seconds past 1970-01-01 00:00:00)
-     * 
-     * == Milliseconds ==    
-     * %N      008                       Milliseconds (three digits)
-     * %#N     8                         Milliseconds (one to three digits)
-     * 
-     * == Timezone ==        
-     * %O      360                       difference in minutes between local time and GMT
-     * %Z      Mountain Standard Time    Name of timezone as reported by browser
-     * %G      06:00                     Hours and minutes between GMT
-     * 
-     * == Shortcuts ==       
-     * %F      2008-03-26                %Y-%m-%d
-     * %T      05:06:30                  %H:%M:%S
-     * %X      05:06:30                  %H:%M:%S
-     * %x      03/26/08                  %m/%d/%y
-     * %D      03/26/08                  %m/%d/%y
-     * %#c     Wed Mar 26 15:31:00 2008  %a %b %e %H:%M:%S %Y
-     * %v      3-Sep-2008                %e-%b-%Y
-     * %R      15:31                     %H:%M
-     * %r      03:31:00 PM               %I:%M:%S %p
-     * 
-     * == Characters ==      
-     * %n      \n                        Newline
-     * %t      \t                        Tab
-     * %%      %                         Percent Symbol
-     * </pre>
-     * 
-     * <p>Formatting shortcuts that will be translated into their longer version.
-     * Be sure that format shortcuts do not refer to themselves: this will cause an infinite loop.</p>
-     * 
-     * <p>Format codes and format shortcuts can be redefined after the jsDate
-     * module is imported.</p>
-     * 
-     * <p>Note that if you redefine the whole hash (object), you must supply a "matcher"
-     * regex for the parser.  The default matcher is:</p>
-     * 
-     * <code>/()%(#?(%|[a-z]))/i</code>
-     * 
-     * <p>which corresponds to the Perl syntax used by default.</p>
-     * 
-     * <p>By customizing the matcher and format codes, nearly any strftime functionality is possible.</p>
-     */
-     
-    jsDate.formats.perl = {
-        codes: {
-            //
-            // 2-part regex matcher for format codes
-            //
-            // first match must be the character before the code (to account for escaping)
-            // second match must be the format code character(s)
-            //
-            matcher: /()%(#?(%|[a-z]))/i,
-            // year
-            Y: 'FullYear',
-            y: 'ShortYear.2',
-            // month
-            m: 'MonthNumber.2',
-            '#m': 'MonthNumber',
-            B: 'MonthName',
-            b: 'AbbrMonthName',
-            // day
-            d: 'Date.2',
-            '#d': 'Date',
-            e: 'Date',
-            A: 'DayName',
-            a: 'AbbrDayName',
-            w: 'Day',
-            // hours
-            H: 'Hours.2',
-            '#H': 'Hours',
-            I: 'Hours12.2',
-            '#I': 'Hours12',
-            p: 'AMPM',
-            // minutes
-            M: 'Minutes.2',
-            '#M': 'Minutes',
-            // seconds
-            S: 'Seconds.2',
-            '#S': 'Seconds',
-            s: 'Unix',
-            // milliseconds
-            N: 'Milliseconds.3',
-            '#N': 'Milliseconds',
-            // timezone
-            O: 'TimezoneOffset',
-            Z: 'TimezoneName',
-            G: 'GmtOffset'  
-        },
-        
-        shortcuts: {
-            // date
-            F: '%Y-%m-%d',
-            // time
-            T: '%H:%M:%S',
-            X: '%H:%M:%S',
-            // local format date
-            x: '%m/%d/%y',
-            D: '%m/%d/%y',
-            // local format extended
-            '#c': '%a %b %e %H:%M:%S %Y',
-            // local format short
-            v: '%e-%b-%Y',
-            R: '%H:%M',
-            r: '%I:%M:%S %p',
-            // tab and newline
-            t: '\t',
-            n: '\n',
-            '%': '%'
-        }
-    };
-    
-    /**
-     * PHP format codes and shortcuts for strftime.
-     * 
-     * A hash (object) of codes where each code must be an array where the first member is 
-     * the name of a Date.prototype or jsDate.prototype function to call
-     * and optionally a second member indicating the number to pass to addZeros()
-     * 
-     * <p>The following format codes are defined:</p>
-     * 
-     * <pre class="code">
-     * Code    Result                    Description
-     * === Days ===        
-     * %a      Sun through Sat           An abbreviated textual representation of the day
-     * %A      Sunday - Saturday         A full textual representation of the day
-     * %d      01 to 31                  Two-digit day of the month (with leading zeros)
-     * %e      1 to 31                   Day of the month, with a space preceding single digits.
-     * %j      001 to 366                Day of the year, 3 digits with leading zeros
-     * %u      1 - 7 (Mon - Sun)         ISO-8601 numeric representation of the day of the week
-     * %w      0 - 6 (Sun - Sat)         Numeric representation of the day of the week
-     *                                  
-     * === Week ===                     
-     * %U      13                        Full Week number, starting with the first Sunday as the first week
-     * %V      01 through 53             ISO-8601:1988 week number, starting with the first week of the year 
-     *                                   with at least 4 weekdays, with Monday being the start of the week
-     * %W      46                        A numeric representation of the week of the year, 
-     *                                   starting with the first Monday as the first week
-     * === Month ===                    
-     * %b      Jan through Dec           Abbreviated month name, based on the locale
-     * %B      January - December        Full month name, based on the locale
-     * %h      Jan through Dec           Abbreviated month name, based on the locale (an alias of %b)
-     * %m      01 - 12 (Jan - Dec)       Two digit representation of the month
-     * 
-     * === Year ===                     
-     * %C      19                        Two digit century (year/100, truncated to an integer)
-     * %y      09 for 2009               Two digit year
-     * %Y      2038                      Four digit year
-     * 
-     * === Time ===                     
-     * %H      00 through 23             Two digit representation of the hour in 24-hour format
-     * %I      01 through 12             Two digit representation of the hour in 12-hour format
-     * %l      1 through 12              Hour in 12-hour format, with a space preceeding single digits
-     * %M      00 through 59             Two digit representation of the minute
-     * %p      AM/PM                     UPPER-CASE 'AM' or 'PM' based on the given time
-     * %P      am/pm                     lower-case 'am' or 'pm' based on the given time
-     * %r      09:34:17 PM               Same as %I:%M:%S %p
-     * %R      00:35                     Same as %H:%M
-     * %S      00 through 59             Two digit representation of the second
-     * %T      21:34:17                  Same as %H:%M:%S
-     * %X      03:59:16                  Preferred time representation based on locale, without the date
-     * %z      -0500 or EST              Either the time zone offset from UTC or the abbreviation
-     * %Z      -0500 or EST              The time zone offset/abbreviation option NOT given by %z
-     * 
-     * === Time and Date ===            
-     * %D      02/05/09                  Same as %m/%d/%y
-     * %F      2009-02-05                Same as %Y-%m-%d (commonly used in database datestamps)
-     * %s      305815200                 Unix Epoch Time timestamp (same as the time() function)
-     * %x      02/05/09                  Preferred date representation, without the time
-     * 
-     * === Miscellaneous ===            
-     * %n        ---                     A newline character (\n)
-     * %t        ---                     A Tab character (\t)
-     * %%        ---                     A literal percentage character (%)
-     * </pre>
-     */
- 
-    jsDate.formats.php = {
-        codes: {
-            //
-            // 2-part regex matcher for format codes
-            //
-            // first match must be the character before the code (to account for escaping)
-            // second match must be the format code character(s)
-            //
-            matcher: /()%((%|[a-z]))/i,
-            // day
-            a: 'AbbrDayName',
-            A: 'DayName',
-            d: 'Date.2',
-            e: 'Date',
-            j: 'DayOfYear.3',
-            u: 'DayOfWeek',
-            w: 'Day',
-            // week
-            U: 'FullWeekOfYear.2',
-            V: 'IsoWeek.2',
-            W: 'WeekOfYear.2',
-            // month
-            b: 'AbbrMonthName',
-            B: 'MonthName',
-            m: 'MonthNumber.2',
-            h: 'AbbrMonthName',
-            // year
-            C: 'Century.2',
-            y: 'ShortYear.2',
-            Y: 'FullYear',
-            // time
-            H: 'Hours.2',
-            I: 'Hours12.2',
-            l: 'Hours12',
-            p: 'AMPM',
-            P: 'AmPm',
-            M: 'Minutes.2',
-            S: 'Seconds.2',
-            s: 'Unix',
-            O: 'TimezoneOffset',
-            z: 'GmtOffset',
-            Z: 'TimezoneAbbr'
-        },
-        
-        shortcuts: {
-            D: '%m/%d/%y',
-            F: '%Y-%m-%d',
-            T: '%H:%M:%S',
-            X: '%H:%M:%S',
-            x: '%m/%d/%y',
-            R: '%H:%M',
-            r: '%I:%M:%S %p',
-            t: '\t',
-            n: '\n',
-            '%': '%'
-        }
-    };   
-    //
-    // Conceptually, the logic implemented here is similar to Ken Snyder's Date Instance Methods.
-    // I use his idea of a set of parsers which can be regular expressions or functions,
-    // iterating through those, and then seeing if Date.parse() will create a date.
-    // The parser expressions and functions are a little different and some bugs have been
-    // worked out.  Also, a lot of "pre-parsing" is done to fix implementation
-    // variations of Date.parse() between browsers.
-    //
-    jsDate.createDate = function(date) {
-        // if passing in multiple arguments, try Date constructor
-        if (date == null) {
-            return new Date();
-        }
-        // If the passed value is already a date object, return it
-        if (date instanceof Date) {
-            return date;
-        }
-        // if (typeof date == 'number') return new Date(date * 1000);
-        // If the passed value is an integer, interpret it as a javascript timestamp
-        if (typeof date == 'number') {
-            return new Date(date);
-        }
-        
-        // Before passing strings into Date.parse(), have to normalize them for certain conditions.
-        // If strings are not formatted staccording to the EcmaScript spec, results from Date parse will be implementation dependent.  
-        // 
-        // For example: 
-        //  * FF and Opera assume 2 digit dates are pre y2k, Chome assumes <50 is pre y2k, 50+ is 21st century.  
-        //  * Chrome will correctly parse '1984-1-25' into localtime, FF and Opera will not parse.
-        //  * Both FF, Chrome and Opera will parse '1984/1/25' into localtime.
-        
-        // remove leading and trailing spaces
-        var parsable = String(date).replace(/^\s*(.+)\s*$/g, '$1');
-        
-        // replace dahses (-) with slashes (/) in dates like n[nnn]/n[n]/n[nnn]
-        parsable = parsable.replace(/^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,4})/, "$1/$2/$3");
-        
-        /////////
-        // Need to check for '15-Dec-09' also.
-        // FF will not parse, but Chrome will.
-        // Chrome will set date to 2009 as well.
-        /////////
-        
-        // first check for 'dd-mmm-yyyy' or 'dd/mmm/yyyy' like '15-Dec-2010'
-        parsable = parsable.replace(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{4})/i, "$1 $2 $3");
-        
-        // Now check for 'dd-mmm-yy' or 'dd/mmm/yy' and normalize years to default century.
-        var match = parsable.match(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{2})\D*/i);
-        if (match && match.length > 3) {
-            var m3 = parseFloat(match[3]);
-            var ny = jsDate.config.defaultCentury + m3;
-            ny = String(ny);
-            
-            // now replace 2 digit year with 4 digit year
-            parsable = parsable.replace(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{2})\D*/i, match[1] +' '+ match[2] +' '+ ny);
-            
-        }
-        
-        // Check for '1/19/70 8:14PM'
-        // where starts with mm/dd/yy or yy/mm/dd and have something after
-        // Check if 1st postiion is greater than 31, assume it is year.
-        // Assme all 2 digit years are 1900's.
-        // Finally, change them into US style mm/dd/yyyy representations.
-        match = parsable.match(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})[^0-9]/);
-        
-        function h1(parsable, match) {
-            var m1 = parseFloat(match[1]);
-            var m2 = parseFloat(match[2]);
-            var m3 = parseFloat(match[3]);
-            var cent = jsDate.config.defaultCentury;
-            var ny, nd, nm, str;
-            
-            if (m1 > 31) { // first number is a year
-                nd = m3;
-                nm = m2;
-                ny = cent + m1;
-            }
-            
-            else { // last number is the year
-                nd = m2;
-                nm = m1;
-                ny = cent + m3;
-            }
-            
-            str = nm+'/'+nd+'/'+ny;
-            
-            // now replace 2 digit year with 4 digit year
-            return  parsable.replace(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})/, str);
-        
-        }
-        
-        if (match && match.length > 3) {
-            parsable = h1(parsable, match);
-        }
-        
-        // Now check for '1/19/70' with nothing after and do as above
-        var match = parsable.match(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})$/);
-        
-        if (match && match.length > 3) {
-            parsable = h1(parsable, match);
-        }
-                
-        
-        var i = 0;
-        var length = jsDate.matchers.length;
-        var pattern,
-            ms,
-            current = parsable,
-            obj;
-        while (i < length) {
-            ms = Date.parse(current);
-            if (!isNaN(ms)) {
-                return new Date(ms);
-            }
-            pattern = jsDate.matchers[i];
-            if (typeof pattern == 'function') {
-                obj = pattern.call(jsDate, current);
-                if (obj instanceof Date) {
-                    return obj;
-                }
-            } else {
-                current = parsable.replace(pattern[0], pattern[1]);
-            }
-            i++;
-        }
-        return NaN;
-    };
-    
-
-    /**
-     * @static
-     * Handy static utility function to return the number of days in a given month.
-     * @param {Integer} year Year
-     * @param {Integer} month Month (1-12)
-     * @returns {Integer} Number of days in the month.
-    */
-    //
-    // handy utility method Borrowed right from Ken Snyder's Date Instance Mehtods.
-    // 
-    jsDate.daysInMonth = function(year, month) {
-        if (month == 2) {
-            return new Date(year, 1, 29).getDate() == 29 ? 29 : 28;
-        }
-        return [undefined,31,undefined,31,30,31,30,31,31,30,31,30,31][month];
-    };
-
-
-    //
-    // An Array of regular expressions or functions that will attempt to match the date string.
-    // Functions are called with scope of a jsDate instance.
-    //
-    jsDate.matchers = [
-        // convert dd.mmm.yyyy to mm/dd/yyyy (world date to US date).
-        [/(3[01]|[0-2]\d)\s*\.\s*(1[0-2]|0\d)\s*\.\s*([1-9]\d{3})/, '$2/$1/$3'],
-        // convert yyyy-mm-dd to mm/dd/yyyy (ISO date to US date).
-        [/([1-9]\d{3})\s*-\s*(1[0-2]|0\d)\s*-\s*(3[01]|[0-2]\d)/, '$2/$3/$1'],
-        // Handle 12 hour or 24 hour time with milliseconds am/pm and optional date part.
-        function(str) { 
-            var match = str.match(/^(?:(.+)\s+)?([012]?\d)(?:\s*\:\s*(\d\d))?(?:\s*\:\s*(\d\d(\.\d*)?))?\s*(am|pm)?\s*$/i);
-            //                   opt. date      hour       opt. minute     opt. second       opt. msec   opt. am or pm
-            if (match) {
-                if (match[1]) {
-                    var d = this.createDate(match[1]);
-                    if (isNaN(d)) {
-                        return;
-                    }
-                } else {
-                    var d = new Date();
-                    d.setMilliseconds(0);
-                }
-                var hour = parseFloat(match[2]);
-                if (match[6]) {
-                    hour = match[6].toLowerCase() == 'am' ? (hour == 12 ? 0 : hour) : (hour == 12 ? 12 : hour + 12);
-                }
-                d.setHours(hour, parseInt(match[3] || 0, 10), parseInt(match[4] || 0, 10), ((parseFloat(match[5] || 0)) || 0)*1000);
-                return d;
-            }
-            else {
-                return str;
-            }
-        },
-        // Handle ISO timestamp with time zone.
-        function(str) {
-            var match = str.match(/^(?:(.+))[T|\s+]([012]\d)(?:\:(\d\d))(?:\:(\d\d))(?:\.\d+)([\+\-]\d\d\:\d\d)$/i);
-            if (match) {
-                if (match[1]) {
-                    var d = this.createDate(match[1]);
-                    if (isNaN(d)) {
-                        return;
-                    }
-                } else {
-                    var d = new Date();
-                    d.setMilliseconds(0);
-                }
-                var hour = parseFloat(match[2]);
-                d.setHours(hour, parseInt(match[3], 10), parseInt(match[4], 10), parseFloat(match[5])*1000);
-                return d;
-            }
-            else {
-                    return str;
-            }
-        },
-        // Try to match ambiguous strings like 12/8/22.
-        // Use FF date assumption that 2 digit years are 20th century (i.e. 1900's).
-        // This may be redundant with pre processing of date already performed.
-        function(str) {
-            var match = str.match(/^([0-3]?\d)\s*[-\/.\s]{1}\s*([a-zA-Z]{3,9})\s*[-\/.\s]{1}\s*([0-3]?\d)$/);
-            if (match) {
-                var d = new Date();
-                var cent = jsDate.config.defaultCentury;
-                var m1 = parseFloat(match[1]);
-                var m3 = parseFloat(match[3]);
-                var ny, nd, nm;
-                if (m1 > 31) { // first number is a year
-                    nd = m3;
-                    ny = cent + m1;
-                }
-                
-                else { // last number is the year
-                    nd = m1;
-                    ny = cent + m3;
-                }
-                
-                var nm = inArray(match[2], jsDate.regional[jsDate.regional.getLocale()]["monthNamesShort"]);
-                
-                if (nm == -1) {
-                    nm = inArray(match[2], jsDate.regional[jsDate.regional.getLocale()]["monthNames"]);
-                }
-            
-                d.setFullYear(ny, nm, nd);
-                d.setHours(0,0,0,0);
-                return d;
-            }
-            
-            else {
-                return str;
-            }
-        }      
-    ];
-
-    //
-    // I think John Reisig published this method on his blog, ejohn.
-    //
-    function inArray( elem, array ) {
-        if ( array.indexOf ) {
-            return array.indexOf( elem );
-        }
-
-        for ( var i = 0, length = array.length; i < length; i++ ) {
-            if ( array[ i ] === elem ) {
-                return i;
-            }
-        }
-
-        return -1;
-    }
-    
-    //
-    // Thanks to Kangax, Christian Sciberras and Stack Overflow for this method.
-    //
-    function get_type(thing){
-        if(thing===null) return "[object Null]"; // special case
-        return Object.prototype.toString.call(thing);
-    }
-    
-    $.jsDate = jsDate;
-
-      
-    /**
-     * JavaScript printf/sprintf functions.
-     * 
-     * This code has been adapted from the publicly available sprintf methods
-     * by Ash Searle. His original header follows:
-     *
-     *     This code is unrestricted: you are free to use it however you like.
-     *     
-     *     The functions should work as expected, performing left or right alignment,
-     *     truncating strings, outputting numbers with a required precision etc.
-     *
-     *     For complex cases, these functions follow the Perl implementations of
-     *     (s)printf, allowing arguments to be passed out-of-order, and to set the
-     *     precision or length of the output based on arguments instead of fixed
-     *     numbers.
-     *
-     *     See http://perldoc.perl.org/functions/sprintf.html for more information.
-     *
-     *     Implemented:
-     *     - zero and space-padding
-     *     - right and left-alignment,
-     *     - base X prefix (binary, octal and hex)
-     *     - positive number prefix
-     *     - (minimum) width
-     *     - precision / truncation / maximum width
-     *     - out of order arguments
-     *
-     *     Not implemented (yet):
-     *     - vector flag
-     *     - size (bytes, words, long-words etc.)
-     *     
-     *     Will not implement:
-     *     - %n or %p (no pass-by-reference in JavaScript)
-     *
-     *     @version 2007.04.27
-     *     @author Ash Searle 
-     * 
-     * You can see the original work and comments on his blog:
-     * http://hexmen.com/blog/2007/03/printf-sprintf/
-     * http://hexmen.com/js/sprintf.js
-     */
-     
-     /**
-      * @Modifications 2009.05.26
-      * @author Chris Leonello
-      * 
-      * Added %p %P specifier
-      * Acts like %g or %G but will not add more significant digits to the output than present in the input.
-      * Example:
-      * Format: '%.3p', Input: 0.012, Output: 0.012
-      * Format: '%.3g', Input: 0.012, Output: 0.0120
-      * Format: '%.4p', Input: 12.0, Output: 12.0
-      * Format: '%.4g', Input: 12.0, Output: 12.00
-      * Format: '%.4p', Input: 4.321e-5, Output: 4.321e-5
-      * Format: '%.4g', Input: 4.321e-5, Output: 4.3210e-5
-      * 
-      * Example:
-      * >>> $.jqplot.sprintf('%.2f, %d', 23.3452, 43.23)
-      * "23.35, 43"
-      * >>> $.jqplot.sprintf("no value: %n, decimal with thousands separator: %'d", 23.3452, 433524)
-      * "no value: , decimal with thousands separator: 433,524"
-      */
-    $.jqplot.sprintf = function() {
-        function pad(str, len, chr, leftJustify) {
-            var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr);
-            return leftJustify ? str + padding : padding + str;
-
-        }
-
-        function thousand_separate(value) {
-            var value_str = new String(value);
-            for (var i=10; i>0; i--) {
-                if (value_str == (value_str = value_str.replace(/^(\d+)(\d{3})/, "$1"+$.jqplot.sprintf.thousandsSeparator+"$2"))) break;
-            }
-            return value_str; 
-        }
-
-        function justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace) {
-            var diff = minWidth - value.length;
-            if (diff > 0) {
-                var spchar = ' ';
-                if (htmlSpace) { spchar = '&nbsp;'; }
-                if (leftJustify || !zeroPad) {
-                    value = pad(value, minWidth, spchar, leftJustify);
-                } else {
-                    value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
-                }
-            }
-            return value;
-        }
-
-        function formatBaseX(value, base, prefix, leftJustify, minWidth, precision, zeroPad, htmlSpace) {
-            // Note: casts negative numbers to positive ones
-            var number = value >>> 0;
-            prefix = prefix && number && {'2': '0b', '8': '0', '16': '0x'}[base] || '';
-            value = prefix + pad(number.toString(base), precision || 0, '0', false);
-            return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace);
-        }
-
-        function formatString(value, leftJustify, minWidth, precision, zeroPad, htmlSpace) {
-            if (precision != null) {
-                value = value.slice(0, precision);
-            }
-            return justify(value, '', leftJustify, minWidth, zeroPad, htmlSpace);
-        }
-
-        var a = arguments, i = 0, format = a[i++];
-
-        return format.replace($.jqplot.sprintf.regex, function(substring, valueIndex, flags, minWidth, _, precision, type) {
-            if (substring == '%%') { return '%'; }
-
-            // parse flags
-            var leftJustify = false, positivePrefix = '', zeroPad = false, prefixBaseX = false, htmlSpace = false, thousandSeparation = false;
-            for (var j = 0; flags && j < flags.length; j++) switch (flags.charAt(j)) {
-                case ' ': positivePrefix = ' '; break;
-                case '+': positivePrefix = '+'; break;
-                case '-': leftJustify = true; break;
-                case '0': zeroPad = true; break;
-                case '#': prefixBaseX = true; break;
-                case '&': htmlSpace = true; break;
-                case '\'': thousandSeparation = true; break;
-            }
-
-            // parameters may be null, undefined, empty-string or real valued
-            // we want to ignore null, undefined and empty-string values
-
-            if (!minWidth) {
-                minWidth = 0;
-            } 
-            else if (minWidth == '*') {
-                minWidth = +a[i++];
-            } 
-            else if (minWidth.charAt(0) == '*') {
-                minWidth = +a[minWidth.slice(1, -1)];
-            } 
-            else {
-                minWidth = +minWidth;
-            }
-
-            // Note: undocumented perl feature:
-            if (minWidth < 0) {
-                minWidth = -minWidth;
-                leftJustify = true;
-            }
-
-            if (!isFinite(minWidth)) {
-                throw new Error('$.jqplot.sprintf: (minimum-)width must be finite');
-            }
-
-            if (!precision) {
-                precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : void(0);
-            } 
-            else if (precision == '*') {
-                precision = +a[i++];
-            } 
-            else if (precision.charAt(0) == '*') {
-                precision = +a[precision.slice(1, -1)];
-            } 
-            else {
-                precision = +precision;
-            }
-
-            // grab value using valueIndex if required?
-            var value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++];
-
-            switch (type) {
-            case 's': {
-                if (value == null) {
-                    return '';
-                }
-                return formatString(String(value), leftJustify, minWidth, precision, zeroPad, htmlSpace);
-            }
-            case 'c': return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad, htmlSpace);
-            case 'b': return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad,htmlSpace);
-            case 'o': return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
-            case 'x': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
-            case 'X': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace).toUpperCase();
-            case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
-            case 'i': {
-              var number = parseInt(+value, 10);
-              if (isNaN(number)) {
-                return '';
-              }
-              var prefix = number < 0 ? '-' : positivePrefix;
-              var number_str = thousandSeparation ? thousand_separate(String(Math.abs(number))): String(Math.abs(number));
-              value = prefix + pad(number_str, precision, '0', false);
-              //value = prefix + pad(String(Math.abs(number)), precision, '0', false);
-              return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace);
-                  }
-            case 'd': {
-              var number = Math.round(+value);
-              if (isNaN(number)) {
-                return '';
-              }
-              var prefix = number < 0 ? '-' : positivePrefix;
-              var number_str = thousandSeparation ? thousand_separate(String(Math.abs(number))): String(Math.abs(number));
-              value = prefix + pad(number_str, precision, '0', false);
-              return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace);
-                  }
-            case 'e':
-            case 'E':
-            case 'f':
-            case 'F':
-            case 'g':
-            case 'G':
-                      {
-                      var number = +value;
-                      if (isNaN(number)) {
-                          return '';
-                      }
-                      var prefix = number < 0 ? '-' : positivePrefix;
-                      var method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())];
-                      var textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2];
-                      var number_str = Math.abs(number)[method](precision);
-                      number_str = thousandSeparation ? thousand_separate(number_str): number_str;
-                      value = prefix + number_str;
-                      return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace)[textTransform]();
-                  }
-            case 'p':
-            case 'P':
-            {
-                // make sure number is a number
-                var number = +value;
-                if (isNaN(number)) {
-                    return '';
-                }
-                var prefix = number < 0 ? '-' : positivePrefix;
-
-                var parts = String(Number(Math.abs(number)).toExponential()).split(/e|E/);
-                var sd = (parts[0].indexOf('.') != -1) ? parts[0].length - 1 : parts[0].length;
-                var zeros = (parts[1] < 0) ? -parts[1] - 1 : 0;
-                
-                if (Math.abs(number) < 1) {
-                    if (sd + zeros  <= precision) {
-                        value = prefix + Math.abs(number).toPrecision(sd);
-                    }
-                    else {
-                        if (sd  <= precision - 1) {
-                            value = prefix + Math.abs(number).toExponential(sd-1);
-                        }
-                        else {
-                            value = prefix + Math.abs(number).toExponential(precision-1);
-                        }
-                    }
-                }
-                else {
-                    var prec = (sd <= precision) ? sd : precision;
-                    value = prefix + Math.abs(number).toPrecision(prec);
-                }
-                var textTransform = ['toString', 'toUpperCase']['pP'.indexOf(type) % 2];
-                return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace)[textTransform]();
-            }
-            case 'n': return '';
-            default: return substring;
-            }
-        });
-    };
-
-    $.jqplot.sprintf.thousandsSeparator = ',';
-    
-    $.jqplot.sprintf.regex = /%%|%(\d+\$)?([-+#0&\' ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([nAscboxXuidfegpEGP])/g;
-
-    $.jqplot.getSignificantFigures = function(number) {
-        var parts = String(Number(Math.abs(number)).toExponential()).split(/e|E/);
-        // total significant digits
-        var sd = (parts[0].indexOf('.') != -1) ? parts[0].length - 1 : parts[0].length;
-        var zeros = (parts[1] < 0) ? -parts[1] - 1 : 0;
-        // exponent
-        var expn = parseInt(parts[1]);
-        // digits to the left of the decimal place
-        var dleft = (expn + 1 > 0) ? expn + 1 : 0;
-        // digits to the right of the decimal place
-        var dright = (sd <= dleft) ? 0 : sd - expn - 1;
-        return {significantDigits: sd, digitsLeft: dleft, digitsRight: dright, zeros: zeros, exponent: expn} ;
-    };
-
-    $.jqplot.getPrecision = function(number) {
-        var arr = $.jqplot.getSignificantFigures(number);
-        var p = arr[1] - 1 - parseInt(arr[0][1]);
-        return p;
-    };
-
-})(jQuery);  
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.min.css b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.min.css
deleted file mode 100644
index f98d913..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.min.css
+++ /dev/null
@@ -1 +0,0 @@
-.jqplot-target{position:relative;color:#666;font-family:"Trebuchet MS",Arial,Helvetica,sans-serif;font-size:1em;}.jqplot-axis{font-size:.75em;}.jqplot-xaxis{margin-top:10px;}.jqplot-x2axis{margin-bottom:10px;}.jqplot-yaxis{margin-right:10px;}.jqplot-y2axis,.jqplot-y3axis,.jqplot-y4axis,.jqplot-y5axis,.jqplot-y6axis,.jqplot-y7axis,.jqplot-y8axis,.jqplot-y9axis,.jqplot-yMidAxis{margin-left:10px;margin-right:10px;}.jqplot-axis-tick,.jqplot-xaxis-tick,.jqplot-yaxis-tick,.jqplot-x2axis-tick,.jqplot-y2axis-tick,.jqplot-y3axis-tick,.jqplot-y4axis-tick,.jqplot-y5axis-tick,.jqplot-y6axis-tick,.jqplot-y7axis-tick,.jqplot-y8axis-tick,.jqplot-y9axis-tick,.jqplot-yMidAxis-tick{position:absolute;}.jqplot-xaxis-tick{top:0;left:15px;vertical-align:top;}.jqplot-x2axis-tick{bottom:0;left:15px;vertical-align:bottom;}.jqplot-yaxis-tick{right:0;top:15px;text-align:right;}.jqplot-yaxis-tick.jqplot-breakTick{right:-20px;margin-right:0;padding:1px 5px 1px 5px;z-index:2;font-size:1.5em;}.jqplot-y2axis-tick,.jqplot-y3axis-tick,.jqplot-y4axis-tick,.jqplot-y5axis-tick,.jqplot-y6axis-tick,.jqplot-y7axis-tick,.jqplot-y8axis-tick,.jqplot-y9axis-tick{left:0;top:15px;text-align:left;}.jqplot-yMidAxis-tick{text-align:center;white-space:nowrap;}.jqplot-xaxis-label{margin-top:10px;font-size:11pt;position:absolute;}.jqplot-x2axis-label{margin-bottom:10px;font-size:11pt;position:absolute;}.jqplot-yaxis-label{margin-right:10px;font-size:11pt;position:absolute;}.jqplot-yMidAxis-label{font-size:11pt;position:absolute;}.jqplot-y2axis-label,.jqplot-y3axis-label,.jqplot-y4axis-label,.jqplot-y5axis-label,.jqplot-y6axis-label,.jqplot-y7axis-label,.jqplot-y8axis-label,.jqplot-y9axis-label{font-size:11pt;margin-left:10px;position:absolute;}.jqplot-meterGauge-tick{font-size:.75em;color:#999;}.jqplot-meterGauge-label{font-size:1em;color:#999;}table.jqplot-table-legend{margin-top:12px;margin-bottom:12px;margin-left:12px;margin-right:12px;}table.jqplot-table-legend,table.jqplot-cursor-legend{background-color:rgba(255,255,255,0.6);border:1px solid #ccc;position:absolute;font-size:.75em;}td.jqplot-table-legend{vertical-align:middle;}td.jqplot-seriesToggle:hover,td.jqplot-seriesToggle:active{cursor:pointer;}.jqplot-table-legend .jqplot-series-hidden{text-decoration:line-through;}div.jqplot-table-legend-swatch-outline{border:1px solid #ccc;padding:1px;}div.jqplot-table-legend-swatch{width:0;height:0;border-top-width:5px;border-bottom-width:5px;border-left-width:6px;border-right-width:6px;border-top-style:solid;border-bottom-style:solid;border-left-style:solid;border-right-style:solid;}.jqplot-title{top:0;left:0;padding-bottom:.5em;font-size:1.2em;}table.jqplot-cursor-tooltip{border:1px solid #ccc;font-size:.75em;}.jqplot-cursor-tooltip{border:1px solid #ccc;font-size:.75em;white-space:nowrap;background:rgba(208,208,208,0.5);padding:1px;}.jqplot-highlighter-tooltip,.jqplot-canvasOverlay-tooltip{border:1px solid #ccc;font-size:.75em;white-space:nowrap;background:rgba(208,208,208,0.5);padding:1px;}.jqplot-point-label{font-size:.75em;z-index:2;}td.jqplot-cursor-legend-swatch{vertical-align:middle;text-align:center;}div.jqplot-cursor-legend-swatch{width:1.2em;height:.7em;}.jqplot-error{text-align:center;}.jqplot-error-message{position:relative;top:46%;display:inline-block;}div.jqplot-bubble-label{font-size:.8em;padding-left:2px;padding-right:2px;color:rgb(20%,20%,20%);}div.jqplot-bubble-label.jqplot-bubble-label-highlight{background:rgba(90%,90%,90%,0.7);}div.jqplot-noData-container{text-align:center;background-color:rgba(96%,96%,96%,0.3);}
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.min.js
deleted file mode 100644
index 844bb0e..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.jqplot.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(G){var q;G.fn.emptyForce=function(){for(var aa=0,ab;(ab=G(this)[aa])!=null;aa++){if(ab.nodeType===1){jQuery.cleanData(ab.getElementsByTagName("*"))}if(G.jqplot_use_excanvas){ab.outerHTML=""}else{while(ab.firstChild){ab.removeChild(ab.firstChild)}}ab=null}return G(this)};G.fn.removeChildForce=function(aa){while(aa.firstChild){this.removeChildForce(aa.firstChild);aa.removeChild(aa.firstChild)}};G.jqplot=function(ag,ad,ab){var ac,aa;if(ab==null){if(jQuery.isArray(ad)){ac=ad;aa=null}else{if(typeof(ad)==="object"){ac=null;aa=ad}}}else{ac=ad;aa=ab}var af=new M();G("#"+ag).removeClass("jqplot-error");if(G.jqplot.config.catchErrors){try{af.init(ag,ac,aa);af.draw();af.themeEngine.init.call(af);return af}catch(ae){var ah=G.jqplot.config.errorMessage||ae.message;G("#"+ag).append('<div class="jqplot-error-message">'+ah+"</div>");G("#"+ag).addClass("jqplot-error");document.getElementById(ag).style.background=G.jqplot.config.errorBackground;document.getElementById(ag).style.border=G.jqplot.config.errorBorder;document.getElementById(ag).style.fontFamily=G.jqplot.config.errorFontFamily;document.getElementById(ag).style.fontSize=G.jqplot.config.errorFontSize;document.getElementById(ag).style.fontStyle=G.jqplot.config.errorFontStyle;document.getElementById(ag).style.fontWeight=G.jqplot.config.errorFontWeight}}else{af.init(ag,ac,aa);af.draw();af.themeEngine.init.call(af);return af}};G.jqplot.version="1.0.0b2_r947";G.jqplot.CanvasManager=function(){if(typeof G.jqplot.CanvasManager.canvases=="undefined"){G.jqplot.CanvasManager.canvases=[];G.jqplot.CanvasManager.free=[]}var aa=[];this.getCanvas=function(){var ad;var ac=true;if(!G.jqplot.use_excanvas){for(var ae=0,ab=G.jqplot.CanvasManager.canvases.length;ae<ab;ae++){if(G.jqplot.CanvasManager.free[ae]===true){ac=false;ad=G.jqplot.CanvasManager.canvases[ae];G.jqplot.CanvasManager.free[ae]=false;aa.push(ae);break}}}if(ac){ad=document.createElement("canvas");aa.push(G.jqplot.CanvasManager.canvases.length);G.jqplot.CanvasManager.canvases.push(ad);G.jqplot.CanvasManager.free.push(false)}return ad};this.initCanvas=function(ab){if(G.jqplot.use_excanvas){return window.G_vmlCanvasManager.initElement(ab)}return ab};this.freeAllCanvases=function(){for(var ac=0,ab=aa.length;ac<ab;ac++){this.freeCanvas(aa[ac])}aa=[]};this.freeCanvas=function(ab){if(G.jqplot.use_excanvas&&window.G_vmlCanvasManager.uninitElement!==q){window.G_vmlCanvasManager.uninitElement(G.jqplot.CanvasManager.canvases[ab]);G.jqplot.CanvasManager.canvases[ab]=null}else{var ac=G.jqplot.CanvasManager.canvases[ab];ac.getContext("2d").clearRect(0,0,ac.width,ac.height);G(ac).unbind().removeAttr("class").removeAttr("style");G(ac).css({left:"",top:"",position:""});ac.width=0;ac.height=0;G.jqplot.CanvasManager.free[ab]=true}}};G.jqplot.log=function(){if(window.console){window.console.log.apply(window.console,arguments)}};G.jqplot.config={enablePlugins:false,defaultHeight:300,defaultWidth:400,UTCAdjust:false,timezoneOffset:new Date(new Date().getTimezoneOffset()*60000),errorMessage:"",errorBackground:"",errorBorder:"",errorFontFamily:"",errorFontSize:"",errorFontStyle:"",errorFontWeight:"",catchErrors:false,defaultTickFormatString:"%.1f",defaultColors:["#4bb2c5","#EAA228","#c5b47f","#579575","#839557","#958c12","#953579","#4b5de4","#d8b83f","#ff5800","#0085cc","#c747a3","#cddf54","#FBD178","#26B4E3","#bd70c7"],defaultNegativeColors:["#498991","#C08840","#9F9274","#546D61","#646C4A","#6F6621","#6E3F5F","#4F64B0","#A89050","#C45923","#187399","#945381","#959E5C","#C7AF7B","#478396","#907294"],dashLength:4,gapLength:4,dotGapLength:2.5,srcLocation:"jqplot/src/",pluginLocation:"jqplot/src/plugins/"};G.jqplot.arrayMax=function(aa){return Math.max.apply(Math,aa)};G.jqplot.arrayMin=function(aa){return Math.min.apply(Math,aa)};G.jqplot.enablePlugins=G.jqplot.config.enablePlugins;G.jqplot.support_canvas=function(){if(typeof G.jqplot.support_canvas.result=="undefined"){G.jqplot.support_canvas.result=!!document.createElement("canvas").getContext}return G.jqplot.support_canvas.result};G.jqplot.support_canvas_text=function(){if(typeof G.jqplot.support_canvas_text.result=="undefined"){if(window.G_vmlCanvasManager!==q&&window.G_vmlCanvasManager._version>887){G.jqplot.support_canvas_text.result=true}else{G.jqplot.support_canvas_text.result=!!(document.createElement("canvas").getContext&&typeof document.createElement("canvas").getContext("2d").fillText=="function")}}return G.jqplot.support_canvas_text.result};G.jqplot.use_excanvas=(G.browser.msie&&!G.jqplot.support_canvas())?true:false;G.jqplot.preInitHooks=[];G.jqplot.postInitHooks=[];G.jqplot.preParseOptionsHooks=[];G.jqplot.postParseOptionsHooks=[];G.jqplot.preDrawHooks=[];G.jqplot.postDrawHooks=[];G.jqplot.preDrawSeriesHooks=[];G.jqplot.postDrawSeriesHooks=[];G.jqplot.preDrawLegendHooks=[];G.jqplot.addLegendRowHooks=[];G.jqplot.preSeriesInitHooks=[];G.jqplot.postSeriesInitHooks=[];G.jqplot.preParseSeriesOptionsHooks=[];G.jqplot.postParseSeriesOptionsHooks=[];G.jqplot.eventListenerHooks=[];G.jqplot.preDrawSeriesShadowHooks=[];G.jqplot.postDrawSeriesShadowHooks=[];G.jqplot.ElemContainer=function(){this._elem;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null}};G.jqplot.ElemContainer.prototype.createElement=function(ad,af,ab,ac,ag){this._offsets=af;var aa=ab||"jqplot";var ae=document.createElement(ad);this._elem=G(ae);this._elem.addClass(aa);this._elem.css(ac);this._elem.attr(ag);ae=null;return this._elem};G.jqplot.ElemContainer.prototype.getWidth=function(){if(this._elem){return this._elem.outerWidth(true)}else{return null}};G.jqplot.ElemContainer.prototype.getHeight=function(){if(this._elem){return this._elem.outerHeight(true)}else{return null}};G.jqplot.ElemContainer.prototype.getPosition=function(){if(this._elem){return this._elem.position()}else{return{top:null,left:null,bottom:null,right:null}}};G.jqplot.ElemContainer.prototype.getTop=function(){return this.getPosition().top};G.jqplot.ElemContainer.prototype.getLeft=function(){return this.getPosition().left};G.jqplot.ElemContainer.prototype.getBottom=function(){return this._elem.css("bottom")};G.jqplot.ElemContainer.prototype.getRight=function(){return this._elem.css("right")};function r(aa){G.jqplot.ElemContainer.call(this);this.name=aa;this._series=[];this.show=false;this.tickRenderer=G.jqplot.AxisTickRenderer;this.tickOptions={};this.labelRenderer=G.jqplot.AxisLabelRenderer;this.labelOptions={};this.label=null;this.showLabel=true;this.min=null;this.max=null;this.autoscale=false;this.pad=1.2;this.padMax=null;this.padMin=null;this.ticks=[];this.numberTicks;this.tickInterval;this.renderer=G.jqplot.LinearAxisRenderer;this.rendererOptions={};this.showTicks=true;this.showTickMarks=true;this.showMinorTicks=true;this.drawMajorGridlines=true;this.drawMinorGridlines=false;this.drawMajorTickMarks=true;this.drawMinorTickMarks=true;this.useSeriesColor=false;this.borderWidth=null;this.borderColor=null;this._dataBounds={min:null,max:null};this._intervalStats=[];this._offsets={min:null,max:null};this._ticks=[];this._label=null;this.syncTicks=null;this.tickSpacing=75;this._min=null;this._max=null;this._tickInterval=null;this._numberTicks=null;this.__ticks=null;this._options={}}r.prototype=new G.jqplot.ElemContainer();r.prototype.constructor=r;r.prototype.init=function(){this.renderer=new this.renderer();this.tickOptions.axis=this.name;if(this.tickOptions.showMark==null){this.tickOptions.showMark=this.showTicks}if(this.tickOptions.showMark==null){this.tickOptions.showMark=this.showTickMarks}if(this.tickOptions.showLabel==null){this.tickOptions.showLabel=this.showTicks}if(this.label==null||this.label==""){this.showLabel=false}else{this.labelOptions.label=this.label}if(this.showLabel==false){this.labelOptions.show=false}if(this.pad==0){this.pad=1}if(this.padMax==0){this.padMax=1}if(this.padMin==0){this.padMin=1}if(this.padMax==null){this.padMax=(this.pad-1)/2+1}if(this.padMin==null){this.padMin=(this.pad-1)/2+1}this.pad=this.padMax+this.padMin-1;if(this.min!=null||this.max!=null){this.autoscale=false}if(this.syncTicks==null&&this.name.indexOf("y")>-1){this.syncTicks=true}else{if(this.syncTicks==null){this.syncTicks=false}}this.renderer.init.call(this,this.rendererOptions)};r.prototype.draw=function(aa,ab){if(this.__ticks){this.__ticks=null}return this.renderer.draw.call(this,aa,ab)};r.prototype.set=function(){this.renderer.set.call(this)};r.prototype.pack=function(ab,aa){if(this.show){this.renderer.pack.call(this,ab,aa)}if(this._min==null){this._min=this.min;this._max=this.max;this._tickInterval=this.tickInterval;this._numberTicks=this.numberTicks;this.__ticks=this._ticks}};r.prototype.reset=function(){this.renderer.reset.call(this)};r.prototype.resetScale=function(aa){G.extend(true,this,{min:null,max:null,numberTicks:null,tickInterval:null,_ticks:[],ticks:[]},aa);this.resetDataBounds()};r.prototype.resetDataBounds=function(){var ah=this._dataBounds;ah.min=null;ah.max=null;var ab,ai,af;var ac=(this.show)?true:false;for(var ae=0;ae<this._series.length;ae++){ai=this._series[ae];af=ai._plotData;if(ai._type==="line"&&ai.renderer.bands.show&&this.name.charAt(0)!=="x"){af=[[0,ai.renderer.bands._min],[1,ai.renderer.bands._max]]}var aa=1,ag=1;if(ai._type!=null&&ai._type=="ohlc"){aa=3;ag=2}for(var ad=0,ab=af.length;ad<ab;ad++){if(this.name=="xaxis"||this.name=="x2axis"){if((af[ad][0]!=null&&af[ad][0]<ah.min)||ah.min==null){ah.min=af[ad][0]}if((af[ad][0]!=null&&af[ad][0]>ah.max)||ah.max==null){ah.max=af[ad][0]}}else{if((af[ad][aa]!=null&&af[ad][aa]<ah.min)||ah.min==null){ah.min=af[ad][aa]}if((af[ad][ag]!=null&&af[ad][ag]>ah.max)||ah.max==null){ah.max=af[ad][ag]}}}if(ac&&ai.renderer.constructor!==G.jqplot.BarRenderer){ac=false}else{if(ac&&this._options.hasOwnProperty("forceTickAt0")&&this._options.forceTickAt0==false){ac=false}else{if(ac&&ai.renderer.constructor===G.jqplot.BarRenderer){if(ai.barDirection=="vertical"&&this.name!="xaxis"&&this.name!="x2axis"){if(this._options.pad!=null||this._options.padMin!=null){ac=false}}else{if(ai.barDirection=="horizontal"&&(this.name=="xaxis"||this.name=="x2axis")){if(this._options.pad!=null||this._options.padMin!=null){ac=false}}}}}}}if(ac&&this.renderer.constructor===G.jqplot.LinearAxisRenderer&&ah.min>=0){this.padMin=1;this.forceTickAt0=true}};function m(aa){G.jqplot.ElemContainer.call(this);this.show=false;this.location="ne";this.labels=[];this.showLabels=true;this.showSwatches=true;this.placement="insideGrid";this.xoffset=0;this.yoffset=0;this.border;this.background;this.textColor;this.fontFamily;this.fontSize;this.rowSpacing="0.5em";this.renderer=G.jqplot.TableLegendRenderer;this.rendererOptions={};this.preDraw=false;this.marginTop=null;this.marginRight=null;this.marginBottom=null;this.marginLeft=null;this.escapeHtml=false;this._series=[];G.extend(true,this,aa)}m.prototype=new G.jqplot.ElemContainer();m.prototype.constructor=m;m.prototype.setOptions=function(aa){G.extend(true,this,aa);if(this.placement=="inside"){this.placement="insideGrid"}if(this.xoffset>0){if(this.placement=="insideGrid"){switch(this.location){case"nw":case"w":case"sw":if(this.marginLeft==null){this.marginLeft=this.xoffset+"px"}this.marginRight="0px";break;case"ne":case"e":case"se":default:if(this.marginRight==null){this.marginRight=this.xoffset+"px"}this.marginLeft="0px";break}}else{if(this.placement=="outside"){switch(this.location){case"nw":case"w":case"sw":if(this.marginRight==null){this.marginRight=this.xoffset+"px"}this.marginLeft="0px";break;case"ne":case"e":case"se":default:if(this.marginLeft==null){this.marginLeft=this.xoffset+"px"}this.marginRight="0px";break}}}this.xoffset=0}if(this.yoffset>0){if(this.placement=="outside"){switch(this.location){case"sw":case"s":case"se":if(this.marginTop==null){this.marginTop=this.yoffset+"px"}this.marginBottom="0px";break;case"ne":case"n":case"nw":default:if(this.marginBottom==null){this.marginBottom=this.yoffset+"px"}this.marginTop="0px";break}}else{if(this.placement=="insideGrid"){switch(this.location){case"sw":case"s":case"se":if(this.marginBottom==null){this.marginBottom=this.yoffset+"px"}this.marginTop="0px";break;case"ne":case"n":case"nw":default:if(this.marginTop==null){this.marginTop=this.yoffset+"px"}this.marginBottom="0px";break}}}this.yoffset=0}};m.prototype.init=function(){this.renderer=new this.renderer();this.renderer.init.call(this,this.rendererOptions)};m.prototype.draw=function(ab){for(var aa=0;aa<G.jqplot.preDrawLegendHooks.length;aa++){G.jqplot.preDrawLegendHooks[aa].call(this,ab)}return this.renderer.draw.call(this,ab)};m.prototype.pack=function(aa){this.renderer.pack.call(this,aa)};function t(aa){G.jqplot.ElemContainer.call(this);this.text=aa;this.show=true;this.fontFamily;this.fontSize;this.textAlign;this.textColor;this.renderer=G.jqplot.DivTitleRenderer;this.rendererOptions={};this.escapeHtml=false}t.prototype=new G.jqplot.ElemContainer();t.prototype.constructor=t;t.prototype.init=function(){this.renderer=new this.renderer();this.renderer.init.call(this,this.rendererOptions)};t.prototype.draw=function(aa){return this.renderer.draw.call(this,aa)};t.prototype.pack=function(){this.renderer.pack.call(this)};function N(){G.jqplot.ElemContainer.call(this);this.show=true;this.xaxis="xaxis";this._xaxis;this.yaxis="yaxis";this._yaxis;this.gridBorderWidth=2;this.renderer=G.jqplot.LineRenderer;this.rendererOptions={};this.data=[];this.gridData=[];this.label="";this.showLabel=true;this.color;this.negativeColor;this.lineWidth=2.5;this.lineJoin="round";this.lineCap="round";this.linePattern="solid";this.shadow=true;this.shadowAngle=45;this.shadowOffset=1.25;this.shadowDepth=3;this.shadowAlpha="0.1";this.breakOnNull=false;this.markerRenderer=G.jqplot.MarkerRenderer;this.markerOptions={};this.showLine=true;this.showMarker=true;this.index;this.fill=false;this.fillColor;this.fillAlpha;this.fillAndStroke=false;this.disableStack=false;this._stack=false;this.neighborThreshold=4;this.fillToZero=false;this.fillToValue=0;this.fillAxis="y";this.useNegativeColors=true;this._stackData=[];this._plotData=[];this._plotValues={x:[],y:[]};this._intervals={x:{},y:{}};this._prevPlotData=[];this._prevGridData=[];this._stackAxis="y";this._primaryAxis="_xaxis";this.canvas=new G.jqplot.GenericCanvas();this.shadowCanvas=new G.jqplot.GenericCanvas();this.plugins={};this._sumy=0;this._sumx=0;this._type=""}N.prototype=new G.jqplot.ElemContainer();N.prototype.constructor=N;N.prototype.init=function(ac,ag,ae){this.index=ac;this.gridBorderWidth=ag;var af=this.data;var ab=[],ad;for(ad=0;ad<af.length;ad++){if(!this.breakOnNull){if(af[ad]==null||af[ad][0]==null||af[ad][1]==null){continue}else{ab.push(af[ad])}}else{ab.push(af[ad])}}this.data=ab;if(!this.color&&this.show){this.color=ae.colorGenerator.get(this.index)}if(!this.negativeColor&&this.show){this.negativeColor=ae.negativeColorGenerator.get(this.index)}if(!this.fillColor){this.fillColor=this.color}if(this.fillAlpha){var aa=G.jqplot.normalize2rgb(this.fillColor);var aa=G.jqplot.getColorComponents(aa);this.fillColor="rgba("+aa[0]+","+aa[1]+","+aa[2]+","+this.fillAlpha+")"}this.renderer=new this.renderer();this.renderer.init.call(this,this.rendererOptions,ae);this.markerRenderer=new this.markerRenderer();if(!this.markerOptions.color){this.markerOptions.color=this.color}if(this.markerOptions.show==null){this.markerOptions.show=this.showMarker}this.showMarker=this.markerOptions.show;this.markerRenderer.init(this.markerOptions)};N.prototype.draw=function(ag,ad,af){var ab=(ad==q)?{}:ad;ag=(ag==q)?this.canvas._ctx:ag;var aa,ae,ac;for(aa=0;aa<G.jqplot.preDrawSeriesHooks.length;aa++){G.jqplot.preDrawSeriesHooks[aa].call(this,ag,ab)}if(this.show){this.renderer.setGridData.call(this,af);if(!ab.preventJqPlotSeriesDrawTrigger){G(ag.canvas).trigger("jqplotSeriesDraw",[this.data,this.gridData])}ae=[];if(ab.data){ae=ab.data}else{if(!this._stack){ae=this.data}else{ae=this._plotData}}ac=ab.gridData||this.renderer.makeGridData.call(this,ae,af);if(this._type==="line"&&this.renderer.smooth&&this.renderer._smoothedData.length){ac=this.renderer._smoothedData}this.renderer.draw.call(this,ag,ac,ab,af)}for(aa=0;aa<G.jqplot.postDrawSeriesHooks.length;aa++){G.jqplot.postDrawSeriesHooks[aa].call(this,ag,ab)}ag=ad=af=aa=ae=ac=null};N.prototype.drawShadow=function(ag,ad,af){var ab=(ad==q)?{}:ad;ag=(ag==q)?this.shadowCanvas._ctx:ag;var aa,ae,ac;for(aa=0;aa<G.jqplot.preDrawSeriesShadowHooks.length;aa++){G.jqplot.preDrawSeriesShadowHooks[aa].call(this,ag,ab)}if(this.shadow){this.renderer.setGridData.call(this,af);ae=[];if(ab.data){ae=ab.data}else{if(!this._stack){ae=this.data}else{ae=this._plotData}}ac=ab.gridData||this.renderer.makeGridData.call(this,ae,af);this.renderer.drawShadow.call(this,ag,ac,ab)}for(aa=0;aa<G.jqplot.postDrawSeriesShadowHooks.length;aa++){G.jqplot.postDrawSeriesShadowHooks[aa].call(this,ag,ab)}ag=ad=af=aa=ae=ac=null};N.prototype.toggleDisplay=function(ab){var aa,ac;if(ab.data.series){aa=ab.data.series}else{aa=this}if(ab.data.speed){ac=ab.data.speed}if(ac){if(aa.canvas._elem.is(":hidden")){aa.canvas._elem.removeClass("jqplot-series-hidden");if(aa.shadowCanvas._elem){aa.shadowCanvas._elem.fadeIn(ac)}aa.canvas._elem.fadeIn(ac);aa.canvas._elem.nextAll(".jqplot-point-label.jqplot-series-"+aa.index).fadeIn(ac)}else{aa.canvas._elem.addClass("jqplot-series-hidden");if(aa.shadowCanvas._elem){aa.shadowCanvas._elem.fadeOut(ac)}aa.canvas._elem.fadeOut(ac);aa.canvas._elem.nextAll(".jqplot-point-label.jqplot-series-"+aa.index).fadeOut(ac)}}else{if(aa.canvas._elem.is(":hidden")){aa.canvas._elem.removeClass("jqplot-series-hidden");if(aa.shadowCanvas._elem){aa.shadowCanvas._elem.show()}aa.canvas._elem.show();aa.canvas._elem.nextAll(".jqplot-point-label.jqplot-series-"+aa.index).show()}else{aa.canvas._elem.addClass("jqplot-series-hidden");if(aa.shadowCanvas._elem){aa.shadowCanvas._elem.hide()}aa.canvas._elem.hide();aa.canvas._elem.nextAll(".jqplot-point-label.jqplot-series-"+aa.index).hide()}}};function H(){G.jqplot.ElemContainer.call(this);this.drawGridlines=true;this.gridLineColor="#cccccc";this.gridLineWidth=1;this.background="#fffdf6";this.borderColor="#999999";this.borderWidth=2;this.drawBorder=true;this.shadow=true;this.shadowAngle=45;this.shadowOffset=1.5;this.shadowWidth=3;this.shadowDepth=3;this.shadowColor=null;this.shadowAlpha="0.07";this._left;this._top;this._right;this._bottom;this._width;this._height;this._axes=[];this.renderer=G.jqplot.CanvasGridRenderer;this.rendererOptions={};this._offsets={top:null,bottom:null,left:null,right:null}}H.prototype=new G.jqplot.ElemContainer();H.prototype.constructor=H;H.prototype.init=function(){this.renderer=new this.renderer();this.renderer.init.call(this,this.rendererOptions)};H.prototype.createElement=function(aa,ab){this._offsets=aa;return this.renderer.createElement.call(this,ab)};H.prototype.draw=function(){this.renderer.draw.call(this)};G.jqplot.GenericCanvas=function(){G.jqplot.ElemContainer.call(this);this._ctx};G.jqplot.GenericCanvas.prototype=new G.jqplot.ElemContainer();G.jqplot.GenericCanvas.prototype.constructor=G.jqplot.GenericCanvas;G.jqplot.GenericCanvas.prototype.createElement=function(ae,ac,ab,af){this._offsets=ae;var aa="jqplot";if(ac!=q){aa=ac}var ad;ad=af.canvasManager.getCanvas();if(ab!=null){this._plotDimensions=ab}ad.width=this._plotDimensions.width-this._offsets.left-this._offsets.right;ad.height=this._plotDimensions.height-this._offsets.top-this._offsets.bottom;this._elem=G(ad);this._elem.css({position:"absolute",left:this._offsets.left,top:this._offsets.top});this._elem.addClass(aa);ad=af.canvasManager.initCanvas(ad);ad=null;return this._elem};G.jqplot.GenericCanvas.prototype.setContext=function(){this._ctx=this._elem.get(0).getContext("2d");return this._ctx};G.jqplot.GenericCanvas.prototype.resetCanvas=function(){if(this._elem){if(G.jqplot.use_excanvas&&window.G_vmlCanvasManager.uninitElement!==q){window.G_vmlCanvasManager.uninitElement(this._elem.get(0))}this._elem.emptyForce()}this._ctx=null};G.jqplot.HooksManager=function(){this.hooks=[]};G.jqplot.HooksManager.prototype.addOnce=function(ab){var ac=false,aa;for(aa=0;aa<this.hooks.length;aa++){if(this.hooks[aa][0]==ab){ac=true}}if(!ac){this.hooks.push(ab)}};G.jqplot.HooksManager.prototype.add=function(aa){this.hooks.push(aa)};G.jqplot.EventListenerManager=function(){this.hooks=[]};G.jqplot.EventListenerManager.prototype.addOnce=function(ad,ac){var ae=false,ab,aa;for(aa=0;aa<this.hooks.length;aa++){ab=this.hooks[aa];if(ab[0]==ad&&ab[1]==ac){ae=true}}if(!ae){this.hooks.push([ad,ac])}};G.jqplot.EventListenerManager.prototype.add=function(ab,aa){this.hooks.push([ab,aa])};var P=["yMidAxis","xaxis","yaxis","x2axis","y2axis","y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis"];function M(){this.data=[];this.dataRenderer;this.dataRendererOptions;this.noDataIndicator={show:false,indicator:"Loading Data...",axes:{xaxis:{min:0,max:10,tickInterval:2,show:true},yaxis:{min:0,max:12,tickInterval:3,show:true}}};this.targetId=null;this.target=null;this.defaults={axesDefaults:{},axes:{xaxis:{},yaxis:{},x2axis:{},y2axis:{},y3axis:{},y4axis:{},y5axis:{},y6axis:{},y7axis:{},y8axis:{},y9axis:{},yMidAxis:{}},seriesDefaults:{},series:[]};this.series=[];this.axes={xaxis:new r("xaxis"),yaxis:new r("yaxis"),x2axis:new r("x2axis"),y2axis:new r("y2axis"),y3axis:new r("y3axis"),y4axis:new r("y4axis"),y5axis:new r("y5axis"),y6axis:new r("y6axis"),y7axis:new r("y7axis"),y8axis:new r("y8axis"),y9axis:new r("y9axis"),yMidAxis:new r("yMidAxis")};this.grid=new H();this.legend=new m();this.baseCanvas=new G.jqplot.GenericCanvas();this.seriesStack=[];this.previousSeriesStack=[];this.eventCanvas=new G.jqplot.GenericCanvas();this._width=null;this._height=null;this._plotDimensions={height:null,width:null};this._gridPadding={top:null,right:null,bottom:null,left:null};this._defaultGridPadding={top:10,right:10,bottom:23,left:10};this.syncXTicks=true;this.syncYTicks=true;this.seriesColors=G.jqplot.config.defaultColors;this.negativeSeriesColors=G.jqplot.config.defaultNegativeColors;this.sortData=true;var ac=0;this.textColor;this.fontFamily;this.fontSize;this.title=new t();this.options={};this.stackSeries=false;this.defaultAxisStart=1;this._stackData=[];this._plotData=[];this.plugins={};this._drawCount=0;this.drawIfHidden=false;this.captureRightClick=false;this.themeEngine=new G.jqplot.ThemeEngine();this._sumy=0;this._sumx=0;this.preInitHooks=new G.jqplot.HooksManager();this.postInitHooks=new G.jqplot.HooksManager();this.preParseOptionsHooks=new G.jqplot.HooksManager();this.postParseOptionsHooks=new G.jqplot.HooksManager();this.preDrawHooks=new G.jqplot.HooksManager();this.postDrawHooks=new G.jqplot.HooksManager();this.preDrawSeriesHooks=new G.jqplot.HooksManager();this.postDrawSeriesHooks=new G.jqplot.HooksManager();this.preDrawLegendHooks=new G.jqplot.HooksManager();this.addLegendRowHooks=new G.jqplot.HooksManager();this.preSeriesInitHooks=new G.jqplot.HooksManager();this.postSeriesInitHooks=new G.jqplot.HooksManager();this.preParseSeriesOptionsHooks=new G.jqplot.HooksManager();this.postParseSeriesOptionsHooks=new G.jqplot.HooksManager();this.eventListenerHooks=new G.jqplot.EventListenerManager();this.preDrawSeriesShadowHooks=new G.jqplot.HooksManager();this.postDrawSeriesShadowHooks=new G.jqplot.HooksManager();this.colorGenerator=new G.jqplot.ColorGenerator();this.negativeColorGenerator=new G.jqplot.ColorGenerator();this.canvasManager=new G.jqplot.CanvasManager();this.init=function(ak,ah,am){am=am||{};for(var ai=0;ai<G.jqplot.preInitHooks.length;ai++){G.jqplot.preInitHooks[ai].call(this,ak,ah,am)}for(var ai=0;ai<this.preInitHooks.hooks.length;ai++){this.preInitHooks.hooks[ai].call(this,ak,ah,am)}this.targetId="#"+ak;this.target=G("#"+ak);this.target.removeClass("jqplot-error");if(!this.target.get(0)){throw"No plot target specified"}if(this.target.css("position")=="static"){this.target.css("position","relative")}if(!this.target.hasClass("jqplot-target")){this.target.addClass("jqplot-target")}if(!this.target.height()){var aj;if(am&&am.height){aj=parseInt(am.height,10)}else{if(this.target.attr("data-height")){aj=parseInt(this.target.attr("data-height"),10)}else{aj=parseInt(G.jqplot.config.defaultHeight,10)}}this._height=aj;this.target.css("height",aj+"px")}else{this._height=aj=this.target.height()}if(!this.target.width()){var al;if(am&&am.width){al=parseInt(am.width,10)}else{if(this.target.attr("data-width")){al=parseInt(this.target.attr("data-width"),10)}else{al=parseInt(G.jqplot.config.defaultWidth,10)}}this._width=al;this.target.css("width",al+"px")}else{this._width=al=this.target.width()}this._plotDimensions.height=this._height;this._plotDimensions.width=this._width;this.grid._plotDimensions=this._plotDimensions;this.title._plotDimensions=this._plotDimensions;this.baseCanvas._plotDimensions=this._plotDimensions;this.eventCanvas._plotDimensions=this._plotDimensions;this.legend._plotDimensions=this._plotDimensions;if(this._height<=0||this._width<=0||!this._height||!this._width){throw"Canvas dimension not set"}if(am.dataRenderer&&jQuery.isFunction(am.dataRenderer)){if(am.dataRendererOptions){this.dataRendererOptions=am.dataRendererOptions}this.dataRenderer=am.dataRenderer;ah=this.dataRenderer(ah,this,this.dataRendererOptions)}if(am.noDataIndicator&&jQuery.isPlainObject(am.noDataIndicator)){G.extend(true,this.noDataIndicator,am.noDataIndicator)}if(ah==null||jQuery.isArray(ah)==false||ah.length==0||jQuery.isArray(ah[0])==false||ah[0].length==0){if(this.noDataIndicator.show==false){throw {name:"DataError",message:"No data to plot."}}else{for(var ae in this.noDataIndicator.axes){for(var af in this.noDataIndicator.axes[ae]){this.axes[ae][af]=this.noDataIndicator.axes[ae][af]}}this.postDrawHooks.add(function(){var at=this.eventCanvas.getHeight();var ap=this.eventCanvas.getWidth();var ao=G('<div class="jqplot-noData-container" style="position:absolute;"></div>');this.target.append(ao);ao.height(at);ao.width(ap);ao.css("top",this.eventCanvas._offsets.top);ao.css("left",this.eventCanvas._offsets.left);var ar=G('<div class="jqplot-noData-contents" style="text-align:center; position:relative; margin-left:auto; margin-right:auto;"></div>');ao.append(ar);ar.html(this.noDataIndicator.indicator);var aq=ar.height();var an=ar.width();ar.height(aq);ar.width(an);ar.css("top",(at-aq)/2+"px")})}}this.data=ah;this.parseOptions(am);if(this.textColor){this.target.css("color",this.textColor)}if(this.fontFamily){this.target.css("font-family",this.fontFamily)}if(this.fontSize){this.target.css("font-size",this.fontSize)}this.title.init();this.legend.init();this._sumy=0;this._sumx=0;for(var ai=0;ai<this.series.length;ai++){this.seriesStack.push(ai);this.previousSeriesStack.push(ai);this.series[ai].shadowCanvas._plotDimensions=this._plotDimensions;this.series[ai].canvas._plotDimensions=this._plotDimensions;for(var ag=0;ag<G.jqplot.preSeriesInitHooks.length;ag++){G.jqplot.preSeriesInitHooks[ag].call(this.series[ai],ak,ah,this.options.seriesDefaults,this.options.series[ai],this)}for(var ag=0;ag<this.preSeriesInitHooks.hooks.length;ag++){this.preSeriesInitHooks.hooks[ag].call(this.series[ai],ak,ah,this.options.seriesDefaults,this.options.series[ai],this)}this.populatePlotData(this.series[ai],ai);this.series[ai]._plotDimensions=this._plotDimensions;this.series[ai].init(ai,this.grid.borderWidth,this);for(var ag=0;ag<G.jqplot.postSeriesInitHooks.length;ag++){G.jqplot.postSeriesInitHooks[ag].call(this.series[ai],ak,ah,this.options.seriesDefaults,this.options.series[ai],this)}for(var ag=0;ag<this.postSeriesInitHooks.hooks.length;ag++){this.postSeriesInitHooks.hooks[ag].call(this.series[ai],ak,ah,this.options.seriesDefaults,this.options.series[ai],this)}this._sumy+=this.series[ai]._sumy;this._sumx+=this.series[ai]._sumx}for(var ai=0;ai<12;ai++){name=P[ai];this.axes[name]._plotDimensions=this._plotDimensions;this.axes[name].init();if(this.axes[name].borderColor==null){if(name.charAt(0)!=="x"&&this.axes[name].useSeriesColor===true&&this.axes[name].show){this.axes[name].borderColor=this.axes[name]._series[0].color}else{this.axes[name].borderColor=this.grid.borderColor}}}if(this.sortData){aa(this.series)}this.grid.init();this.grid._axes=this.axes;this.legend._series=this.series;for(var ai=0;ai<G.jqplot.postInitHooks.length;ai++){G.jqplot.postInitHooks[ai].call(this,ak,ah,am)}for(var ai=0;ai<this.postInitHooks.hooks.length;ai++){this.postInitHooks.hooks[ai].call(this,ak,ah,am)}};this.resetAxesScale=function(aj,af){var ah=af||{};var ai=aj||this.axes;if(ai===true){ai=this.axes}if(jQuery.isArray(ai)){for(var ag=0;ag<ai.length;ag++){this.axes[ai[ag]].resetScale(ah[ai[ag]])}}else{if(typeof(ai)==="object"){for(var ae in ai){this.axes[ae].resetScale(ah[ae])}}}};this.reInitialize=function(){this._height=this.target.height();this._width=this.target.width();if(this._height<=0||this._width<=0||!this._height||!this._width){throw"Target dimension not set"}this._plotDimensions.height=this._height;this._plotDimensions.width=this._width;this.grid._plotDimensions=this._plotDimensions;this.title._plotDimensions=this._plotDimensions;this.baseCanvas._plotDimensions=this._plotDimensions;this.eventCanvas._plotDimensions=this._plotDimensions;this.legend._plotDimensions=this._plotDimensions;for(var ai in this.axes){this.axes[ai]._plotWidth=this._width;this.axes[ai]._plotHeight=this._height}this.title._plotWidth=this._width;if(this.textColor){this.target.css("color",this.textColor)}if(this.fontFamily){this.target.css("font-family",this.fontFamily)}if(this.fontSize){this.target.css("font-size",this.fontSize)}this._sumy=0;this._sumx=0;for(var ag=0;ag<this.series.length;ag++){this.populatePlotData(this.series[ag],ag);if(this.series[ag]._type==="line"&&this.series[ag].renderer.bands.show){this.series[ag].renderer.initBands.call(this.series[ag],this.series[ag].renderer.options,this)}this.series[ag]._plotDimensions=this._plotDimensions;this.series[ag].canvas._plotDimensions=this._plotDimensions;this._sumy+=this.series[ag]._sumy;this._sumx+=this.series[ag]._sumx}for(var ae=0;ae<12;ae++){name=P[ae];var af=this.axes[name]._ticks;for(var ag=0;ag<af.length;ag++){var ah=af[ag]._elem;if(ah){if(G.jqplot.use_excanvas&&window.G_vmlCanvasManager.uninitElement!==q){window.G_vmlCanvasManager.uninitElement(ah.get(0))}ah.emptyForce();ah=null;af._elem=null}}af=null;this.axes[name]._plotDimensions=this._plotDimensions;this.axes[name]._ticks=[]}if(this.sortData){aa(this.series)}this.grid._axes=this.axes;this.legend._series=this.series};function aa(ai){var am,an,ao,ae,al;for(var aj=0;aj<ai.length;aj++){var af;var ak=[ai[aj].data,ai[aj]._stackData,ai[aj]._plotData,ai[aj]._prevPlotData];for(var ag=0;ag<4;ag++){af=true;am=ak[ag];if(ai[aj]._stackAxis=="x"){for(var ah=0;ah<am.length;ah++){if(typeof(am[ah][1])!="number"){af=false;break}}if(af){am.sort(function(aq,ap){return aq[1]-ap[1]})}}else{for(var ah=0;ah<am.length;ah++){if(typeof(am[ah][0])!="number"){af=false;break}}if(af){am.sort(function(aq,ap){return aq[0]-ap[0]})}}}}}this.populatePlotData=function(ai,aj){this._plotData=[];this._stackData=[];ai._stackData=[];ai._plotData=[];var am={x:[],y:[]};if(this.stackSeries&&!ai.disableStack){ai._stack=true;var ak=ai._stackAxis=="x"?0:1;var al=ak?0:1;var an=G.extend(true,[],ai.data);var ao=G.extend(true,[],ai.data);for(var ag=0;ag<aj;ag++){var ae=this.series[ag].data;for(var af=0;af<ae.length;af++){an[af][0]+=ae[af][0];an[af][1]+=ae[af][1];ao[af][ak]+=ae[af][ak]}}for(var ah=0;ah<ao.length;ah++){am.x.push(ao[ah][0]);am.y.push(ao[ah][1])}this._plotData.push(ao);this._stackData.push(an);ai._stackData=an;ai._plotData=ao;ai._plotValues=am}else{for(var ah=0;ah<ai.data.length;ah++){am.x.push(ai.data[ah][0]);am.y.push(ai.data[ah][1])}this._stackData.push(ai.data);this.series[aj]._stackData=ai.data;this._plotData.push(ai.data);ai._plotData=ai.data;ai._plotValues=am}if(aj>0){ai._prevPlotData=this.series[aj-1]._plotData}ai._sumy=0;ai._sumx=0;for(ah=ai.data.length-1;ah>-1;ah--){ai._sumy+=ai.data[ah][1];ai._sumx+=ai.data[ah][0]}};this.getNextSeriesColor=(function(af){var ae=0;var ag=af.seriesColors;return function(){if(ae<ag.length){return ag[ae++]}else{ae=0;return ag[ae++]}}})(this);this.parseOptions=function(am){for(var ai=0;ai<this.preParseOptionsHooks.hooks.length;ai++){this.preParseOptionsHooks.hooks[ai].call(this,am)}for(var ai=0;ai<G.jqplot.preParseOptionsHooks.length;ai++){G.jqplot.preParseOptionsHooks[ai].call(this,am)}this.options=G.extend(true,{},this.defaults,am);this.stackSeries=this.options.stackSeries;if(this.options.seriesColors){this.seriesColors=this.options.seriesColors}if(this.options.negativeSeriesColors){this.negativeSeriesColors=this.options.negativeSeriesColors}if(this.options.captureRightClick){this.captureRightClick=this.options.captureRightClick}this.defaultAxisStart=(am&&am.defaultAxisStart!=null)?am.defaultAxisStart:this.defaultAxisStart;this.colorGenerator.setColors(this.seriesColors);this.negativeColorGenerator.setColors(this.negativeSeriesColors);G.extend(true,this._gridPadding,this.options.gridPadding);this.sortData=(this.options.sortData!=null)?this.options.sortData:this.sortData;for(var ai=0;ai<12;ai++){var ae=P[ai];var ag=this.axes[ae];ag._options=G.extend(true,{},this.options.axesDefaults,this.options.axes[ae]);G.extend(true,ag,this.options.axesDefaults,this.options.axes[ae]);ag._plotWidth=this._width;ag._plotHeight=this._height}var ak=function(aq,ao,ar){var an=[];var ap;ao=ao||"vertical";if(!jQuery.isArray(aq[0])){for(ap=0;ap<aq.length;ap++){if(ao=="vertical"){an.push([ar+ap,aq[ap]])}else{an.push([aq[ap],ar+ap])}}}else{G.extend(true,an,aq)}return an};var aj=0;for(var ai=0;ai<this.data.length;ai++){var al=new N();for(var ah=0;ah<G.jqplot.preParseSeriesOptionsHooks.length;ah++){G.jqplot.preParseSeriesOptionsHooks[ah].call(al,this.options.seriesDefaults,this.options.series[ai])}for(var ah=0;ah<this.preParseSeriesOptionsHooks.hooks.length;ah++){this.preParseSeriesOptionsHooks.hooks[ah].call(al,this.options.seriesDefaults,this.options.series[ai])}G.extend(true,al,{seriesColors:this.seriesColors,negativeSeriesColors:this.negativeSeriesColors},this.options.seriesDefaults,this.options.series[ai]);var af="vertical";if(al.renderer===G.jqplot.BarRenderer&&al.rendererOptions&&al.rendererOptions.barDirection=="horizontal"&&al.transposeData===true){af="horizontal"}al.data=ak(this.data[ai],af,this.defaultAxisStart);switch(al.xaxis){case"xaxis":al._xaxis=this.axes.xaxis;break;case"x2axis":al._xaxis=this.axes.x2axis;break;default:break}al._yaxis=this.axes[al.yaxis];al._xaxis._series.push(al);al._yaxis._series.push(al);if(al.show){al._xaxis.show=true;al._yaxis.show=true}if(!al.label){al.label="Series "+(ai+1).toString()}this.series.push(al);for(var ah=0;ah<G.jqplot.postParseSeriesOptionsHooks.length;ah++){G.jqplot.postParseSeriesOptionsHooks[ah].call(this.series[ai],this.options.seriesDefaults,this.options.series[ai])}for(var ah=0;ah<this.postParseSeriesOptionsHooks.hooks.length;ah++){this.postParseSeriesOptionsHooks.hooks[ah].call(this.series[ai],this.options.seriesDefaults,this.options.series[ai])}}G.extend(true,this.grid,this.options.grid);for(var ai=0;ai<12;ai++){var ae=P[ai];var ag=this.axes[ae];if(ag.borderWidth==null){ag.borderWidth=this.grid.borderWidth}}if(typeof this.options.title=="string"){this.title.text=this.options.title}else{if(typeof this.options.title=="object"){G.extend(true,this.title,this.options.title)}}this.title._plotWidth=this._width;this.legend.setOptions(this.options.legend);for(var ai=0;ai<G.jqplot.postParseOptionsHooks.length;ai++){G.jqplot.postParseOptionsHooks[ai].call(this,am)}for(var ai=0;ai<this.postParseOptionsHooks.hooks.length;ai++){this.postParseOptionsHooks.hooks[ai].call(this,am)}};this.destroy=function(){this.canvasManager.freeAllCanvases();if(this.eventCanvas&&this.eventCanvas._elem){this.eventCanvas._elem.unbind()}this.target.empty();this.target[0].innerHTML=""};this.replot=function(af){var ag=af||{};var ae=ag.clear||true;var ah=ag.resetAxes||false;this.target.trigger("jqplotPreReplot");if(ae){this.destroy()}this.reInitialize();if(ah){this.resetAxesScale(ah,ag.axes)}this.draw();this.target.trigger("jqplotPostReplot")};this.redraw=function(ae){ae=(ae!=null)?ae:true;this.target.trigger("jqplotPreRedraw");if(ae){this.canvasManager.freeAllCanvases();this.eventCanvas._elem.unbind();this.target.empty()}for(var ag in this.axes){this.axes[ag]._ticks=[]}for(var af=0;af<this.series.length;af++){this.populatePlotData(this.series[af],af)}this._sumy=0;this._sumx=0;for(af=0;af<this.series.length;af++){this._sumy+=this.series[af]._sumy;this._sumx+=this.series[af]._sumx}this.draw();this.target.trigger("jqplotPostRedraw")};this.draw=function(){if(this.drawIfHidden||this.target.is(":visible")){this.target.trigger("jqplotPreDraw");var al,aj;for(al=0;al<G.jqplot.preDrawHooks.length;al++){G.jqplot.preDrawHooks[al].call(this)}for(al=0;al<this.preDrawHooks.hooks.length;al++){this.preDrawHooks.hooks[al].call(this)}this.target.append(this.baseCanvas.createElement({left:0,right:0,top:0,bottom:0},"jqplot-base-canvas",null,this));this.baseCanvas.setContext();this.target.append(this.title.draw());this.title.pack({top:0,left:0});var au=this.legend.draw();var aq={top:0,left:0,bottom:0,right:0};if(this.legend.placement=="outsideGrid"){this.target.append(au);switch(this.legend.location){case"n":aq.top+=this.legend.getHeight();break;case"s":aq.bottom+=this.legend.getHeight();break;case"ne":case"e":case"se":aq.right+=this.legend.getWidth();break;case"nw":case"w":case"sw":aq.left+=this.legend.getWidth();break;default:aq.right+=this.legend.getWidth();break}au=au.detach()}var ae=this.axes;for(al=0;al<12;al++){name=P[al];this.target.append(ae[name].draw(this.baseCanvas._ctx,this));ae[name].set()}if(ae.yaxis.show){aq.left+=ae.yaxis.getWidth()}var ah=["y2axis","y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis"];var af=[0,0,0,0,0,0,0,0];var an=0;var ai;for(ai=0;ai<8;ai++){if(ae[ah[ai]].show){an+=ae[ah[ai]].getWidth();af[ai]=an}}aq.right+=an;if(ae.x2axis.show){aq.top+=ae.x2axis.getHeight()}if(this.title.show){aq.top+=this.title.getHeight()}if(ae.xaxis.show){aq.bottom+=ae.xaxis.getHeight()}if(this.options.gridDimensions&&G.isPlainObject(this.options.gridDimensions)){var ak=parseInt(this.options.gridDimensions.width,10)||0;var ag=parseInt(this.options.gridDimensions.height,10)||0;var ar=(this._width-aq.left-aq.right-ak)/2;var at=(this._height-aq.top-aq.bottom-ag)/2;if(at>=0&&ar>=0){aq.top+=at;aq.bottom+=at;aq.left+=ar;aq.right+=ar}}var am=["top","bottom","left","right"];for(var ai in am){if(this._gridPadding[am[ai]]==null&&aq[am[ai]]>0){this._gridPadding[am[ai]]=aq[am[ai]]}else{if(this._gridPadding[am[ai]]==null){this._gridPadding[am[ai]]=this._defaultGridPadding[am[ai]]}}}var ap=(this.legend.placement=="outsideGrid")?{top:this.title.getHeight(),left:0,right:0,bottom:0}:this._gridPadding;ae.xaxis.pack({position:"absolute",bottom:this._gridPadding.bottom-ae.xaxis.getHeight(),left:0,width:this._width},{min:this._gridPadding.left,max:this._width-this._gridPadding.right});ae.yaxis.pack({position:"absolute",top:0,left:this._gridPadding.left-ae.yaxis.getWidth(),height:this._height},{min:this._height-this._gridPadding.bottom,max:this._gridPadding.top});ae.x2axis.pack({position:"absolute",top:this._gridPadding.top-ae.x2axis.getHeight(),left:0,width:this._width},{min:this._gridPadding.left,max:this._width-this._gridPadding.right});for(al=8;al>0;al--){ae[ah[al-1]].pack({position:"absolute",top:0,right:this._gridPadding.right-af[al-1]},{min:this._height-this._gridPadding.bottom,max:this._gridPadding.top})}var ao=(this._width-this._gridPadding.left-this._gridPadding.right)/2+this._gridPadding.left-ae.yMidAxis.getWidth()/2;ae.yMidAxis.pack({position:"absolute",top:0,left:ao,zIndex:9,textAlign:"center"},{min:this._height-this._gridPadding.bottom,max:this._gridPadding.top});this.target.append(this.grid.createElement(this._gridPadding,this));this.grid.draw();for(al=0;al<this.series.length;al++){aj=this.seriesStack[al];this.target.append(this.series[aj].shadowCanvas.createElement(this._gridPadding,"jqplot-series-shadowCanvas",null,this));this.series[aj].shadowCanvas.setContext();this.series[aj].shadowCanvas._elem.data("seriesIndex",aj)}for(al=0;al<this.series.length;al++){aj=this.seriesStack[al];this.target.append(this.series[aj].canvas.createElement(this._gridPadding,"jqplot-series-canvas",null,this));this.series[aj].canvas.setContext();this.series[aj].canvas._elem.data("seriesIndex",aj)}this.target.append(this.eventCanvas.createElement(this._gridPadding,"jqplot-event-canvas",null,this));this.eventCanvas.setContext();this.eventCanvas._ctx.fillStyle="rgba(0,0,0,0)";this.eventCanvas._ctx.fillRect(0,0,this.eventCanvas._ctx.canvas.width,this.eventCanvas._ctx.canvas.height);this.bindCustomEvents();if(this.legend.preDraw){this.eventCanvas._elem.before(au);this.legend.pack(ap);if(this.legend._elem){this.drawSeries({legendInfo:{location:this.legend.location,placement:this.legend.placement,width:this.legend.getWidth(),height:this.legend.getHeight(),xoffset:this.legend.xoffset,yoffset:this.legend.yoffset}})}else{this.drawSeries()}}else{this.drawSeries();if(this.series.length){G(this.series[this.series.length-1].canvas._elem).after(au)}this.legend.pack(ap)}for(var al=0;al<G.jqplot.eventListenerHooks.length;al++){this.eventCanvas._elem.bind(G.jqplot.eventListenerHooks[al][0],{plot:this},G.jqplot.eventListenerHooks[al][1])}for(var al=0;al<this.eventListenerHooks.hooks.length;al++){this.eventCanvas._elem.bind(this.eventListenerHooks.hooks[al][0],{plot:this},this.eventListenerHooks.hooks[al][1])}for(var al=0;al<G.jqplot.postDrawHooks.length;al++){G.jqplot.postDrawHooks[al].call(this)}for(var al=0;al<this.postDrawHooks.hooks.length;al++){this.postDrawHooks.hooks[al].call(this)}if(this.target.is(":visible")){this._drawCount+=1}this.target.trigger("jqplotPostDraw",[this])}};this.bindCustomEvents=function(){this.eventCanvas._elem.bind("click",{plot:this},this.onClick);this.eventCanvas._elem.bind("dblclick",{plot:this},this.onDblClick);this.eventCanvas._elem.bind("mousedown",{plot:this},this.onMouseDown);this.eventCanvas._elem.bind("mousemove",{plot:this},this.onMouseMove);this.eventCanvas._elem.bind("mouseenter",{plot:this},this.onMouseEnter);this.eventCanvas._elem.bind("mouseleave",{plot:this},this.onMouseLeave);if(this.captureRightClick){this.eventCanvas._elem.bind("mouseup",{plot:this},this.onRightClick);this.eventCanvas._elem.get(0).oncontextmenu=function(){return false}}else{this.eventCanvas._elem.bind("mouseup",{plot:this},this.onMouseUp)}};function ab(am){var al=am.data.plot;var ah=al.eventCanvas._elem.offset();var ak={x:am.pageX-ah.left,y:am.pageY-ah.top};var ai={xaxis:null,yaxis:null,x2axis:null,y2axis:null,y3axis:null,y4axis:null,y5axis:null,y6axis:null,y7axis:null,y8axis:null,y9axis:null,yMidAxis:null};var aj=["xaxis","yaxis","x2axis","y2axis","y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis","yMidAxis"];var ae=al.axes;var af,ag;for(af=11;af>0;af--){ag=aj[af-1];if(ae[ag].show){ai[ag]=ae[ag].series_p2u(ak[ag.charAt(0)])}}return{offsets:ah,gridPos:ak,dataPos:ai}}function ad(ae,af){var aj=af.series;var aO,aN,aM,aH,aI,aC,aB,ao,am,ar,at,aD;var aL,aP,aJ,ak,aA,aF;var ag,aG;for(aM=af.seriesStack.length-1;aM>=0;aM--){aO=af.seriesStack[aM];aH=aj[aO];switch(aH.renderer.constructor){case G.jqplot.BarRenderer:case G.jqplot.PyramidRenderer:aC=ae.x;aB=ae.y;for(aN=0;aN<aH._barPoints.length;aN++){aA=aH._barPoints[aN];aJ=aH.gridData[aN];if(aC>aA[0][0]&&aC<aA[2][0]&&aB>aA[2][1]&&aB<aA[0][1]){return{seriesIndex:aH.index,pointIndex:aN,gridData:aJ,data:aH.data[aN],points:aH._barPoints[aN]}}}break;case G.jqplot.DonutRenderer:ar=aH.startAngle/180*Math.PI;aC=ae.x-aH._center[0];aB=ae.y-aH._center[1];aI=Math.sqrt(Math.pow(aC,2)+Math.pow(aB,2));if(aC>0&&-aB>=0){ao=2*Math.PI-Math.atan(-aB/aC)}else{if(aC>0&&-aB<0){ao=-Math.atan(-aB/aC)}else{if(aC<0){ao=Math.PI-Math.atan(-aB/aC)}else{if(aC==0&&-aB>0){ao=3*Math.PI/2}else{if(aC==0&&-aB<0){ao=Math.PI/2}else{if(aC==0&&aB==0){ao=0}}}}}}if(ar){ao-=ar;if(ao<0){ao+=2*Math.PI}else{if(ao>2*Math.PI){ao-=2*Math.PI}}}am=aH.sliceMargin/180*Math.PI;if(aI<aH._radius&&aI>aH._innerRadius){for(aN=0;aN<aH.gridData.length;aN++){at=(aN>0)?aH.gridData[aN-1][1]+am:am;aD=aH.gridData[aN][1];if(ao>at&&ao<aD){return{seriesIndex:aH.index,pointIndex:aN,gridData:aH.gridData[aN],data:aH.data[aN]}}}}break;case G.jqplot.PieRenderer:ar=aH.startAngle/180*Math.PI;aC=ae.x-aH._center[0];aB=ae.y-aH._center[1];aI=Math.sqrt(Math.pow(aC,2)+Math.pow(aB,2));if(aC>0&&-aB>=0){ao=2*Math.PI-Math.atan(-aB/aC)}else{if(aC>0&&-aB<0){ao=-Math.atan(-aB/aC)}else{if(aC<0){ao=Math.PI-Math.atan(-aB/aC)}else{if(aC==0&&-aB>0){ao=3*Math.PI/2}else{if(aC==0&&-aB<0){ao=Math.PI/2}else{if(aC==0&&aB==0){ao=0}}}}}}if(ar){ao-=ar;if(ao<0){ao+=2*Math.PI}else{if(ao>2*Math.PI){ao-=2*Math.PI}}}am=aH.sliceMargin/180*Math.PI;if(aI<aH._radius){for(aN=0;aN<aH.gridData.length;aN++){at=(aN>0)?aH.gridData[aN-1][1]+am:am;aD=aH.gridData[aN][1];if(ao>at&&ao<aD){return{seriesIndex:aH.index,pointIndex:aN,gridData:aH.gridData[aN],data:aH.data[aN]}}}}break;case G.jqplot.BubbleRenderer:aC=ae.x;aB=ae.y;var ay=null;if(aH.show){for(var aN=0;aN<aH.gridData.length;aN++){aJ=aH.gridData[aN];aP=Math.sqrt((aC-aJ[0])*(aC-aJ[0])+(aB-aJ[1])*(aB-aJ[1]));if(aP<=aJ[2]&&(aP<=aL||aL==null)){aL=aP;ay={seriesIndex:aO,pointIndex:aN,gridData:aJ,data:aH.data[aN]}}}if(ay!=null){return ay}}break;case G.jqplot.FunnelRenderer:aC=ae.x;aB=ae.y;var aE=aH._vertices,ai=aE[0],ah=aE[aE.length-1],al,ax,aq;function aK(aS,aU,aT){var aR=(aU[1]-aT[1])/(aU[0]-aT[0]);var aQ=aU[1]-aR*aU[0];var aV=aS+aU[1];return[(aV-aQ)/aR,aV]}al=aK(aB,ai[0],ah[3]);ax=aK(aB,ai[1],ah[2]);for(aN=0;aN<aE.length;aN++){aq=aE[aN];if(aB>=aq[0][1]&&aB<=aq[3][1]&&aC>=al[0]&&aC<=ax[0]){return{seriesIndex:aH.index,pointIndex:aN,gridData:null,data:aH.data[aN]}}}break;case G.jqplot.LineRenderer:aC=ae.x;aB=ae.y;aI=aH.renderer;if(aH.show){if((aH.fill||(aH.renderer.bands.show&&aH.renderer.bands.fill))&&(!af.plugins.highlighter||!af.plugins.highlighter.show)){var ap=false;if(aC>aH._boundingBox[0][0]&&aC<aH._boundingBox[1][0]&&aB>aH._boundingBox[1][1]&&aB<aH._boundingBox[0][1]){var aw=aH._areaPoints.length;var az;var aN=aw-1;for(var az=0;az<aw;az++){var av=[aH._areaPoints[az][0],aH._areaPoints[az][1]];var au=[aH._areaPoints[aN][0],aH._areaPoints[aN][1]];if(av[1]<aB&&au[1]>=aB||au[1]<aB&&av[1]>=aB){if(av[0]+(aB-av[1])/(au[1]-av[1])*(au[0]-av[0])<aC){ap=!ap}}aN=az}}if(ap){return{seriesIndex:aO,pointIndex:null,gridData:aH.gridData,data:aH.data,points:aH._areaPoints}}break}else{aG=aH.markerRenderer.size/2+aH.neighborThreshold;ag=(aG>0)?aG:0;for(var aN=0;aN<aH.gridData.length;aN++){aJ=aH.gridData[aN];if(aI.constructor==G.jqplot.OHLCRenderer){if(aI.candleStick){var an=aH._yaxis.series_u2p;if(aC>=aJ[0]-aI._bodyWidth/2&&aC<=aJ[0]+aI._bodyWidth/2&&aB>=an(aH.data[aN][2])&&aB<=an(aH.data[aN][3])){return{seriesIndex:aO,pointIndex:aN,gridData:aJ,data:aH.data[aN]}}}else{if(!aI.hlc){var an=aH._yaxis.series_u2p;if(aC>=aJ[0]-aI._tickLength&&aC<=aJ[0]+aI._tickLength&&aB>=an(aH.data[aN][2])&&aB<=an(aH.data[aN][3])){return{seriesIndex:aO,pointIndex:aN,gridData:aJ,data:aH.data[aN]}}}else{var an=aH._yaxis.series_u2p;if(aC>=aJ[0]-aI._tickLength&&aC<=aJ[0]+aI._tickLength&&aB>=an(aH.data[aN][1])&&aB<=an(aH.data[aN][2])){return{seriesIndex:aO,pointIndex:aN,gridData:aJ,data:aH.data[aN]}}}}}else{if(aJ[0]!=null&&aJ[1]!=null){aP=Math.sqrt((aC-aJ[0])*(aC-aJ[0])+(aB-aJ[1])*(aB-aJ[1]));if(aP<=ag&&(aP<=aL||aL==null)){aL=aP;return{seriesIndex:aO,pointIndex:aN,gridData:aJ,data:aH.data[aN]}}}}}}}break;default:aC=ae.x;aB=ae.y;aI=aH.renderer;if(aH.show){aG=aH.markerRenderer.size/2+aH.neighborThreshold;ag=(aG>0)?aG:0;for(var aN=0;aN<aH.gridData.length;aN++){aJ=aH.gridData[aN];if(aI.constructor==G.jqplot.OHLCRenderer){if(aI.candleStick){var an=aH._yaxis.series_u2p;if(aC>=aJ[0]-aI._bodyWidth/2&&aC<=aJ[0]+aI._bodyWidth/2&&aB>=an(aH.data[aN][2])&&aB<=an(aH.data[aN][3])){return{seriesIndex:aO,pointIndex:aN,gridData:aJ,data:aH.data[aN]}}}else{if(!aI.hlc){var an=aH._yaxis.series_u2p;if(aC>=aJ[0]-aI._tickLength&&aC<=aJ[0]+aI._tickLength&&aB>=an(aH.data[aN][2])&&aB<=an(aH.data[aN][3])){return{seriesIndex:aO,pointIndex:aN,gridData:aJ,data:aH.data[aN]}}}else{var an=aH._yaxis.series_u2p;if(aC>=aJ[0]-aI._tickLength&&aC<=aJ[0]+aI._tickLength&&aB>=an(aH.data[aN][1])&&aB<=an(aH.data[aN][2])){return{seriesIndex:aO,pointIndex:aN,gridData:aJ,data:aH.data[aN]}}}}}else{aP=Math.sqrt((aC-aJ[0])*(aC-aJ[0])+(aB-aJ[1])*(aB-aJ[1]));if(aP<=ag&&(aP<=aL||aL==null)){aL=aP;return{seriesIndex:aO,pointIndex:aN,gridData:aJ,data:aH.data[aN]}}}}}break}}return null}this.onClick=function(ag){var af=ab(ag);var ai=ag.data.plot;var ah=ad(af.gridPos,ai);var ae=jQuery.Event("jqplotClick");ae.pageX=ag.pageX;ae.pageY=ag.pageY;G(this).trigger(ae,[af.gridPos,af.dataPos,ah,ai])};this.onDblClick=function(ag){var af=ab(ag);var ai=ag.data.plot;var ah=ad(af.gridPos,ai);var ae=jQuery.Event("jqplotDblClick");ae.pageX=ag.pageX;ae.pageY=ag.pageY;G(this).trigger(ae,[af.gridPos,af.dataPos,ah,ai])};this.onMouseDown=function(ag){var af=ab(ag);var ai=ag.data.plot;var ah=ad(af.gridPos,ai);var ae=jQuery.Event("jqplotMouseDown");ae.pageX=ag.pageX;ae.pageY=ag.pageY;G(this).trigger(ae,[af.gridPos,af.dataPos,ah,ai])};this.onMouseUp=function(ag){var af=ab(ag);var ae=jQuery.Event("jqplotMouseUp");ae.pageX=ag.pageX;ae.pageY=ag.pageY;G(this).trigger(ae,[af.gridPos,af.dataPos,null,ag.data.plot])};this.onRightClick=function(ag){var af=ab(ag);var ai=ag.data.plot;var ah=ad(af.gridPos,ai);if(ai.captureRightClick){if(ag.which==3){var ae=jQuery.Event("jqplotRightClick");ae.pageX=ag.pageX;ae.pageY=ag.pageY;G(this).trigger(ae,[af.gridPos,af.dataPos,ah,ai])}else{var ae=jQuery.Event("jqplotMouseUp");ae.pageX=ag.pageX;ae.pageY=ag.pageY;G(this).trigger(ae,[af.gridPos,af.dataPos,ah,ai])}}};this.onMouseMove=function(ag){var af=ab(ag);var ai=ag.data.plot;var ah=ad(af.gridPos,ai);var ae=jQuery.Event("jqplotMouseMove");ae.pageX=ag.pageX;ae.pageY=ag.pageY;G(this).trigger(ae,[af.gridPos,af.dataPos,ah,ai])};this.onMouseEnter=function(ag){var af=ab(ag);var ah=ag.data.plot;var ae=jQuery.Event("jqplotMouseEnter");ae.pageX=ag.pageX;ae.pageY=ag.pageY;ae.relatedTarget=ag.relatedTarget;G(this).trigger(ae,[af.gridPos,af.dataPos,null,ah])};this.onMouseLeave=function(ag){var af=ab(ag);var ah=ag.data.plot;var ae=jQuery.Event("jqplotMouseLeave");ae.pageX=ag.pageX;ae.pageY=ag.pageY;ae.relatedTarget=ag.relatedTarget;G(this).trigger(ae,[af.gridPos,af.dataPos,null,ah])};this.drawSeries=function(ag,ae){var ai,ah,af;ae=(typeof(ag)==="number"&&ae==null)?ag:ae;ag=(typeof(ag)==="object")?ag:{};if(ae!=q){ah=this.series[ae];af=ah.shadowCanvas._ctx;af.clearRect(0,0,af.canvas.width,af.canvas.height);ah.drawShadow(af,ag,this);af=ah.canvas._ctx;af.clearRect(0,0,af.canvas.width,af.canvas.height);ah.draw(af,ag,this);if(ah.renderer.constructor==G.jqplot.BezierCurveRenderer){if(ae<this.series.length-1){this.drawSeries(ae+1)}}}else{for(ai=0;ai<this.series.length;ai++){ah=this.series[ai];af=ah.shadowCanvas._ctx;af.clearRect(0,0,af.canvas.width,af.canvas.height);ah.drawShadow(af,ag,this);af=ah.canvas._ctx;af.clearRect(0,0,af.canvas.width,af.canvas.height);ah.draw(af,ag,this)}}ag=ae=ai=ah=af=null};this.moveSeriesToFront=function(af){af=parseInt(af,10);var ai=G.inArray(af,this.seriesStack);if(ai==-1){return}if(ai==this.seriesStack.length-1){this.previousSeriesStack=this.seriesStack.slice(0);return}var ae=this.seriesStack[this.seriesStack.length-1];var ah=this.series[af].canvas._elem.detach();var ag=this.series[af].shadowCanvas._elem.detach();this.series[ae].shadowCanvas._elem.after(ag);this.series[ae].canvas._elem.after(ah);this.previousSeriesStack=this.seriesStack.slice(0);this.seriesStack.splice(ai,1);this.seriesStack.push(af)};this.moveSeriesToBack=function(af){af=parseInt(af,10);var ai=G.inArray(af,this.seriesStack);if(ai==0||ai==-1){return}var ae=this.seriesStack[0];var ah=this.series[af].canvas._elem.detach();var ag=this.series[af].shadowCanvas._elem.detach();this.series[ae].shadowCanvas._elem.before(ag);this.series[ae].canvas._elem.before(ah);this.previousSeriesStack=this.seriesStack.slice(0);this.seriesStack.splice(ai,1);this.seriesStack.unshift(af)};this.restorePreviousSeriesOrder=function(){var ak,aj,ai,ah,ag,ae,af;if(this.seriesStack==this.previousSeriesStack){return}for(ak=1;ak<this.previousSeriesStack.length;ak++){ae=this.previousSeriesStack[ak];af=this.previousSeriesStack[ak-1];ai=this.series[ae].canvas._elem.detach();ah=this.series[ae].shadowCanvas._elem.detach();this.series[af].shadowCanvas._elem.after(ah);this.series[af].canvas._elem.after(ai)}ag=this.seriesStack.slice(0);this.seriesStack=this.previousSeriesStack.slice(0);this.previousSeriesStack=ag};this.restoreOriginalSeriesOrder=function(){var ai,ah,ae=[],ag,af;for(ai=0;ai<this.series.length;ai++){ae.push(ai)}if(this.seriesStack==ae){return}this.previousSeriesStack=this.seriesStack.slice(0);this.seriesStack=ae;for(ai=1;ai<this.seriesStack.length;ai++){ag=this.series[ai].canvas._elem.detach();af=this.series[ai].shadowCanvas._elem.detach();this.series[ai-1].shadowCanvas._elem.after(af);this.series[ai-1].canvas._elem.after(ag)}};this.activateTheme=function(ae){this.themeEngine.activate(this,ae)}}G.jqplot.computeHighlightColors=function(ab){var ad;if(jQuery.isArray(ab)){ad=[];for(var af=0;af<ab.length;af++){var ae=G.jqplot.getColorComponents(ab[af]);var aa=[ae[0],ae[1],ae[2]];var ag=aa[0]+aa[1]+aa[2];for(var ac=0;ac<3;ac++){aa[ac]=(ag>660)?aa[ac]*0.85:0.73*aa[ac]+90;aa[ac]=parseInt(aa[ac],10);(aa[ac]>255)?255:aa[ac]}aa[3]=0.3+0.35*ae[3];ad.push("rgba("+aa[0]+","+aa[1]+","+aa[2]+","+aa[3]+")")}}else{var ae=G.jqplot.getColorComponents(ab);var aa=[ae[0],ae[1],ae[2]];var ag=aa[0]+aa[1]+aa[2];for(var ac=0;ac<3;ac++){aa[ac]=(ag>660)?aa[ac]*0.85:0.73*aa[ac]+90;aa[ac]=parseInt(aa[ac],10);(aa[ac]>255)?255:aa[ac]}aa[3]=0.3+0.35*ae[3];ad="rgba("+aa[0]+","+aa[1]+","+aa[2]+","+aa[3]+")"}return ad};G.jqplot.ColorGenerator=function(ab){ab=ab||G.jqplot.config.defaultColors;var aa=0;this.next=function(){if(aa<ab.length){return ab[aa++]}else{aa=0;return ab[aa++]}};this.previous=function(){if(aa>0){return ab[aa--]}else{aa=ab.length-1;return ab[aa]}};this.get=function(ad){var ac=ad-ab.length*Math.floor(ad/ab.length);return ab[ac]};this.setColors=function(ac){ab=ac};this.reset=function(){aa=0};this.getIndex=function(){return aa};this.setIndex=function(ac){aa=ac}};G.jqplot.hex2rgb=function(ac,aa){ac=ac.replace("#","");if(ac.length==3){ac=ac.charAt(0)+ac.charAt(0)+ac.charAt(1)+ac.charAt(1)+ac.charAt(2)+ac.charAt(2)}var ab;ab="rgba("+parseInt(ac.slice(0,2),16)+", "+parseInt(ac.slice(2,4),16)+", "+parseInt(ac.slice(4,6),16);if(aa){ab+=", "+aa}ab+=")";return ab};G.jqplot.rgb2hex=function(af){var ac=/rgba?\( *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *(?:, *[0-9.]*)?\)/;var aa=af.match(ac);var ae="#";for(var ad=1;ad<4;ad++){var ab;if(aa[ad].search(/%/)!=-1){ab=parseInt(255*aa[ad]/100,10).toString(16);if(ab.length==1){ab="0"+ab}}else{ab=parseInt(aa[ad],10).toString(16);if(ab.length==1){ab="0"+ab}}ae+=ab}return ae};G.jqplot.normalize2rgb=function(ab,aa){if(ab.search(/^ *rgba?\(/)!=-1){return ab}else{if(ab.search(/^ *#?[0-9a-fA-F]?[0-9a-fA-F]/)!=-1){return G.jqplot.hex2rgb(ab,aa)}else{throw"invalid color spec"}}};G.jqplot.getColorComponents=function(af){af=G.jqplot.colorKeywordMap[af]||af;var ad=G.jqplot.normalize2rgb(af);var ac=/rgba?\( *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *, *([0-9]{1,3}\.?[0-9]*%?) *,? *([0-9.]* *)?\)/;var aa=ad.match(ac);var ab=[];for(var ae=1;ae<4;ae++){if(aa[ae].search(/%/)!=-1){ab[ae-1]=parseInt(255*aa[ae]/100,10)}else{ab[ae-1]=parseInt(aa[ae],10)}}ab[3]=parseFloat(aa[4])?parseFloat(aa[4]):1;return ab};G.jqplot.colorKeywordMap={aliceblue:"rgb(240, 248, 255)",antiquewhite:"rgb(250, 235, 215)",aqua:"rgb( 0, 255, 255)",aquamarine:"rgb(127, 255, 212)",azure:"rgb(240, 255, 255)",beige:"rgb(245, 245, 220)",bisque:"rgb(255, 228, 196)",black:"rgb( 0, 0, 0)",blanchedalmond:"rgb(255, 235, 205)",blue:"rgb( 0, 0, 255)",blueviolet:"rgb(138, 43, 226)",brown:"rgb(165, 42, 42)",burlywood:"rgb(222, 184, 135)",cadetblue:"rgb( 95, 158, 160)",chartreuse:"rgb(127, 255, 0)",chocolate:"rgb(210, 105, 30)",coral:"rgb(255, 127, 80)",cornflowerblue:"rgb(100, 149, 237)",cornsilk:"rgb(255, 248, 220)",crimson:"rgb(220, 20, 60)",cyan:"rgb( 0, 255, 255)",darkblue:"rgb( 0, 0, 139)",darkcyan:"rgb( 0, 139, 139)",darkgoldenrod:"rgb(184, 134, 11)",darkgray:"rgb(169, 169, 169)",darkgreen:"rgb( 0, 100, 0)",darkgrey:"rgb(169, 169, 169)",darkkhaki:"rgb(189, 183, 107)",darkmagenta:"rgb(139, 0, 139)",darkolivegreen:"rgb( 85, 107, 47)",darkorange:"rgb(255, 140, 0)",darkorchid:"rgb(153, 50, 204)",darkred:"rgb(139, 0, 0)",darksalmon:"rgb(233, 150, 122)",darkseagreen:"rgb(143, 188, 143)",darkslateblue:"rgb( 72, 61, 139)",darkslategray:"rgb( 47, 79, 79)",darkslategrey:"rgb( 47, 79, 79)",darkturquoise:"rgb( 0, 206, 209)",darkviolet:"rgb(148, 0, 211)",deeppink:"rgb(255, 20, 147)",deepskyblue:"rgb( 0, 191, 255)",dimgray:"rgb(105, 105, 105)",dimgrey:"rgb(105, 105, 105)",dodgerblue:"rgb( 30, 144, 255)",firebrick:"rgb(178, 34, 34)",floralwhite:"rgb(255, 250, 240)",forestgreen:"rgb( 34, 139, 34)",fuchsia:"rgb(255, 0, 255)",gainsboro:"rgb(220, 220, 220)",ghostwhite:"rgb(248, 248, 255)",gold:"rgb(255, 215, 0)",goldenrod:"rgb(218, 165, 32)",gray:"rgb(128, 128, 128)",grey:"rgb(128, 128, 128)",green:"rgb( 0, 128, 0)",greenyellow:"rgb(173, 255, 47)",honeydew:"rgb(240, 255, 240)",hotpink:"rgb(255, 105, 180)",indianred:"rgb(205, 92, 92)",indigo:"rgb( 75, 0, 130)",ivory:"rgb(255, 255, 240)",khaki:"rgb(240, 230, 140)",lavender:"rgb(230, 230, 250)",lavenderblush:"rgb(255, 240, 245)",lawngreen:"rgb(124, 252, 0)",lemonchiffon:"rgb(255, 250, 205)",lightblue:"rgb(173, 216, 230)",lightcoral:"rgb(240, 128, 128)",lightcyan:"rgb(224, 255, 255)",lightgoldenrodyellow:"rgb(250, 250, 210)",lightgray:"rgb(211, 211, 211)",lightgreen:"rgb(144, 238, 144)",lightgrey:"rgb(211, 211, 211)",lightpink:"rgb(255, 182, 193)",lightsalmon:"rgb(255, 160, 122)",lightseagreen:"rgb( 32, 178, 170)",lightskyblue:"rgb(135, 206, 250)",lightslategray:"rgb(119, 136, 153)",lightslategrey:"rgb(119, 136, 153)",lightsteelblue:"rgb(176, 196, 222)",lightyellow:"rgb(255, 255, 224)",lime:"rgb( 0, 255, 0)",limegreen:"rgb( 50, 205, 50)",linen:"rgb(250, 240, 230)",magenta:"rgb(255, 0, 255)",maroon:"rgb(128, 0, 0)",mediumaquamarine:"rgb(102, 205, 170)",mediumblue:"rgb( 0, 0, 205)",mediumorchid:"rgb(186, 85, 211)",mediumpurple:"rgb(147, 112, 219)",mediumseagreen:"rgb( 60, 179, 113)",mediumslateblue:"rgb(123, 104, 238)",mediumspringgreen:"rgb( 0, 250, 154)",mediumturquoise:"rgb( 72, 209, 204)",mediumvioletred:"rgb(199, 21, 133)",midnightblue:"rgb( 25, 25, 112)",mintcream:"rgb(245, 255, 250)",mistyrose:"rgb(255, 228, 225)",moccasin:"rgb(255, 228, 181)",navajowhite:"rgb(255, 222, 173)",navy:"rgb( 0, 0, 128)",oldlace:"rgb(253, 245, 230)",olive:"rgb(128, 128, 0)",olivedrab:"rgb(107, 142, 35)",orange:"rgb(255, 165, 0)",orangered:"rgb(255, 69, 0)",orchid:"rgb(218, 112, 214)",palegoldenrod:"rgb(238, 232, 170)",palegreen:"rgb(152, 251, 152)",paleturquoise:"rgb(175, 238, 238)",palevioletred:"rgb(219, 112, 147)",papayawhip:"rgb(255, 239, 213)",peachpuff:"rgb(255, 218, 185)",peru:"rgb(205, 133, 63)",pink:"rgb(255, 192, 203)",plum:"rgb(221, 160, 221)",powderblue:"rgb(176, 224, 230)",purple:"rgb(128, 0, 128)",red:"rgb(255, 0, 0)",rosybrown:"rgb(188, 143, 143)",royalblue:"rgb( 65, 105, 225)",saddlebrown:"rgb(139, 69, 19)",salmon:"rgb(250, 128, 114)",sandybrown:"rgb(244, 164, 96)",seagreen:"rgb( 46, 139, 87)",seashell:"rgb(255, 245, 238)",sienna:"rgb(160, 82, 45)",silver:"rgb(192, 192, 192)",skyblue:"rgb(135, 206, 235)",slateblue:"rgb(106, 90, 205)",slategray:"rgb(112, 128, 144)",slategrey:"rgb(112, 128, 144)",snow:"rgb(255, 250, 250)",springgreen:"rgb( 0, 255, 127)",steelblue:"rgb( 70, 130, 180)",tan:"rgb(210, 180, 140)",teal:"rgb( 0, 128, 128)",thistle:"rgb(216, 191, 216)",tomato:"rgb(255, 99, 71)",turquoise:"rgb( 64, 224, 208)",violet:"rgb(238, 130, 238)",wheat:"rgb(245, 222, 179)",white:"rgb(255, 255, 255)",whitesmoke:"rgb(245, 245, 245)",yellow:"rgb(255, 255, 0)",yellowgreen:"rgb(154, 205, 50)"};G.jqplot.AxisLabelRenderer=function(aa){G.jqplot.ElemContainer.call(this);this.axis;this.show=true;this.label="";this.fontFamily=null;this.fontSize=null;this.textColor=null;this._elem;this.escapeHTML=false;G.extend(true,this,aa)};G.jqplot.AxisLabelRenderer.prototype=new G.jqplot.ElemContainer();G.jqplot.AxisLabelRenderer.prototype.constructor=G.jqplot.AxisLabelRenderer;G.jqplot.AxisLabelRenderer.prototype.init=function(aa){G.extend(true,this,aa)};G.jqplot.AxisLabelRenderer.prototype.draw=function(aa,ab){if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=G('<div style="position:absolute;" class="jqplot-'+this.axis+'-label"></div>');if(Number(this.label)){this._elem.css("white-space","nowrap")}if(!this.escapeHTML){this._elem.html(this.label)}else{this._elem.text(this.label)}if(this.fontFamily){this._elem.css("font-family",this.fontFamily)}if(this.fontSize){this._elem.css("font-size",this.fontSize)}if(this.textColor){this._elem.css("color",this.textColor)}return this._elem};G.jqplot.AxisLabelRenderer.prototype.pack=function(){};G.jqplot.AxisTickRenderer=function(aa){G.jqplot.ElemContainer.call(this);this.mark="outside";this.axis;this.showMark=true;this.showGridline=true;this.isMinorTick=false;this.size=4;this.markSize=6;this.show=true;this.showLabel=true;this.label=null;this.value=null;this._styles={};this.formatter=G.jqplot.DefaultTickFormatter;this.prefix="";this.formatString="";this.fontFamily;this.fontSize;this.textColor;this.escapeHTML=false;this._elem;this._breakTick=false;G.extend(true,this,aa)};G.jqplot.AxisTickRenderer.prototype.init=function(aa){G.extend(true,this,aa)};G.jqplot.AxisTickRenderer.prototype=new G.jqplot.ElemContainer();G.jqplot.AxisTickRenderer.prototype.constructor=G.jqplot.AxisTickRenderer;G.jqplot.AxisTickRenderer.prototype.setTick=function(aa,ac,ab){this.value=aa;this.axis=ac;if(ab){this.isMinorTick=true}return this};G.jqplot.AxisTickRenderer.prototype.draw=function(){if(this.label===null){this.label=this.prefix+this.formatter(this.formatString,this.value)}var ab={position:"absolute"};if(Number(this.label)){ab.whitSpace="nowrap"}if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=G(document.createElement("div"));this._elem.addClass("jqplot-"+this.axis+"-tick");if(!this.escapeHTML){this._elem.html(this.label)}else{this._elem.text(this.label)}this._elem.css(ab);for(var aa in this._styles){this._elem.css(aa,this._styles[aa])}if(this.fontFamily){this._elem.css("font-family",this.fontFamily)}if(this.fontSize){this._elem.css("font-size",this.fontSize)}if(this.textColor){this._elem.css("color",this.textColor)}if(this._breakTick){this._elem.addClass("jqplot-breakTick")}return this._elem};G.jqplot.DefaultTickFormatter=function(aa,ab){if(typeof ab=="number"){if(!aa){aa=G.jqplot.config.defaultTickFormatString}return G.jqplot.sprintf(aa,ab)}else{return String(ab)}};G.jqplot.AxisTickRenderer.prototype.pack=function(){};G.jqplot.CanvasGridRenderer=function(){this.shadowRenderer=new G.jqplot.ShadowRenderer()};G.jqplot.CanvasGridRenderer.prototype.init=function(ab){this._ctx;G.extend(true,this,ab);var aa={lineJoin:"miter",lineCap:"round",fill:false,isarc:false,angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,depth:this.shadowDepth,lineWidth:this.shadowWidth,closePath:false,strokeStyle:this.shadowColor};this.renderer.shadowRenderer.init(aa)};G.jqplot.CanvasGridRenderer.prototype.createElement=function(ad){var ac;if(this._elem){if(G.jqplot.use_excanvas&&window.G_vmlCanvasManager.uninitElement!==q){ac=this._elem.get(0);window.G_vmlCanvasManager.uninitElement(ac);ac=null}this._elem.emptyForce();this._elem=null}ac=ad.canvasManager.getCanvas();var aa=this._plotDimensions.width;var ab=this._plotDimensions.height;ac.width=aa;ac.height=ab;this._elem=G(ac);this._elem.addClass("jqplot-grid-canvas");this._elem.css({position:"absolute",left:0,top:0});ac=ad.canvasManager.initCanvas(ac);this._top=this._offsets.top;this._bottom=ab-this._offsets.bottom;this._left=this._offsets.left;this._right=aa-this._offsets.right;this._width=this._right-this._left;this._height=this._bottom-this._top;ac=null;return this._elem};G.jqplot.CanvasGridRenderer.prototype.draw=function(){this._ctx=this._elem.get(0).getContext("2d");var al=this._ctx;var ao=this._axes;al.save();al.clearRect(0,0,this._plotDimensions.width,this._plotDimensions.height);al.fillStyle=this.backgroundColor||this.background;al.fillRect(this._left,this._top,this._width,this._height);al.save();al.lineJoin="miter";al.lineCap="butt";al.lineWidth=this.gridLineWidth;al.strokeStyle=this.gridLineColor;var ar,aq,ai,aj;var af=["xaxis","yaxis","x2axis","y2axis"];for(var ap=4;ap>0;ap--){var av=af[ap-1];var aa=ao[av];var at=aa._ticks;var ak=at.length;if(aa.show){if(aa.drawBaseline){var au={};if(aa.baselineWidth!==null){au.lineWidth=aa.baselineWidth}if(aa.baselineColor!==null){au.strokeStyle=aa.baselineColor}switch(av){case"xaxis":ah(this._left,this._bottom,this._right,this._bottom,au);break;case"yaxis":ah(this._left,this._bottom,this._left,this._top,au);break;case"x2axis":ah(this._left,this._bottom,this._right,this._bottom,au);break;case"y2axis":ah(this._right,this._bottom,this._right,this._top,au);break}}for(var am=ak;am>0;am--){var ag=at[am-1];if(ag.show){var ad=Math.round(aa.u2p(ag.value))+0.5;switch(av){case"xaxis":if(ag.showGridline&&this.drawGridlines&&((!ag.isMinorTick&&aa.drawMajorGridlines)||(ag.isMinorTick&&aa.drawMinorGridlines))){ah(ad,this._top,ad,this._bottom)}if(ag.showMark&&ag.mark&&((!ag.isMinorTick&&aa.drawMajorTickMarks)||(ag.isMinorTick&&aa.drawMinorTickMarks))){ai=ag.markSize;aj=ag.mark;var ad=Math.round(aa.u2p(ag.value))+0.5;switch(aj){case"outside":ar=this._bottom;aq=this._bottom+ai;break;case"inside":ar=this._bottom-ai;aq=this._bottom;break;case"cross":ar=this._bottom-ai;aq=this._bottom+ai;break;default:ar=this._bottom;aq=this._bottom+ai;break}if(this.shadow){this.renderer.shadowRenderer.draw(al,[[ad,ar],[ad,aq]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}ah(ad,ar,ad,aq)}break;case"yaxis":if(ag.showGridline&&this.drawGridlines&&((!ag.isMinorTick&&aa.drawMajorGridlines)||(ag.isMinorTick&&aa.drawMinorGridlines))){ah(this._right,ad,this._left,ad)}if(ag.showMark&&ag.mark&&((!ag.isMinorTick&&aa.drawMajorTickMarks)||(ag.isMinorTick&&aa.drawMinorTickMarks))){ai=ag.markSize;aj=ag.mark;var ad=Math.round(aa.u2p(ag.value))+0.5;switch(aj){case"outside":ar=this._left-ai;aq=this._left;break;case"inside":ar=this._left;aq=this._left+ai;break;case"cross":ar=this._left-ai;aq=this._left+ai;break;default:ar=this._left-ai;aq=this._left;break}if(this.shadow){this.renderer.shadowRenderer.draw(al,[[ar,ad],[aq,ad]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}ah(ar,ad,aq,ad,{strokeStyle:aa.borderColor})}break;case"x2axis":if(ag.showGridline&&this.drawGridlines&&((!ag.isMinorTick&&aa.drawMajorGridlines)||(ag.isMinorTick&&aa.drawMinorGridlines))){ah(ad,this._bottom,ad,this._top)}if(ag.showMark&&ag.mark&&((!ag.isMinorTick&&aa.drawMajorTickMarks)||(ag.isMinorTick&&aa.drawMinorTickMarks))){ai=ag.markSize;aj=ag.mark;var ad=Math.round(aa.u2p(ag.value))+0.5;switch(aj){case"outside":ar=this._top-ai;aq=this._top;break;case"inside":ar=this._top;aq=this._top+ai;break;case"cross":ar=this._top-ai;aq=this._top+ai;break;default:ar=this._top-ai;aq=this._top;break}if(this.shadow){this.renderer.shadowRenderer.draw(al,[[ad,ar],[ad,aq]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}ah(ad,ar,ad,aq)}break;case"y2axis":if(ag.showGridline&&this.drawGridlines&&((!ag.isMinorTick&&aa.drawMajorGridlines)||(ag.isMinorTick&&aa.drawMinorGridlines))){ah(this._left,ad,this._right,ad)}if(ag.showMark&&ag.mark&&((!ag.isMinorTick&&aa.drawMajorTickMarks)||(ag.isMinorTick&&aa.drawMinorTickMarks))){ai=ag.markSize;aj=ag.mark;var ad=Math.round(aa.u2p(ag.value))+0.5;switch(aj){case"outside":ar=this._right;aq=this._right+ai;break;case"inside":ar=this._right-ai;aq=this._right;break;case"cross":ar=this._right-ai;aq=this._right+ai;break;default:ar=this._right;aq=this._right+ai;break}if(this.shadow){this.renderer.shadowRenderer.draw(al,[[ar,ad],[aq,ad]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}ah(ar,ad,aq,ad,{strokeStyle:aa.borderColor})}break;default:break}}}ag=null}aa=null;at=null}af=["y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis","yMidAxis"];for(var ap=7;ap>0;ap--){var aa=ao[af[ap-1]];var at=aa._ticks;if(aa.show){var ab=at[aa.numberTicks-1];var ae=at[0];var ac=aa.getLeft();var an=[[ac,ab.getTop()+ab.getHeight()/2],[ac,ae.getTop()+ae.getHeight()/2+1]];if(this.shadow){this.renderer.shadowRenderer.draw(al,an,{lineCap:"butt",fill:false,closePath:false})}ah(an[0][0],an[0][1],an[1][0],an[1][1],{lineCap:"butt",strokeStyle:aa.borderColor,lineWidth:aa.borderWidth});for(var am=at.length;am>0;am--){var ag=at[am-1];ai=ag.markSize;aj=ag.mark;var ad=Math.round(aa.u2p(ag.value))+0.5;if(ag.showMark&&ag.mark){switch(aj){case"outside":ar=ac;aq=ac+ai;break;case"inside":ar=ac-ai;aq=ac;break;case"cross":ar=ac-ai;aq=ac+ai;break;default:ar=ac;aq=ac+ai;break}an=[[ar,ad],[aq,ad]];if(this.shadow){this.renderer.shadowRenderer.draw(al,an,{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}ah(ar,ad,aq,ad,{strokeStyle:aa.borderColor})}ag=null}ae=null}aa=null;at=null}al.restore();function ah(aA,az,ax,aw,ay){al.save();ay=ay||{};if(ay.lineWidth==null||ay.lineWidth!=0){G.extend(true,al,ay);al.beginPath();al.moveTo(aA,az);al.lineTo(ax,aw);al.stroke();al.restore()}}if(this.shadow){var an=[[this._left,this._bottom],[this._right,this._bottom],[this._right,this._top]];this.renderer.shadowRenderer.draw(al,an)}if(this.borderWidth!=0&&this.drawBorder){ah(this._left,this._top,this._right,this._top,{lineCap:"round",strokeStyle:ao.x2axis.borderColor,lineWidth:ao.x2axis.borderWidth});ah(this._right,this._top,this._right,this._bottom,{lineCap:"round",strokeStyle:ao.y2axis.borderColor,lineWidth:ao.y2axis.borderWidth});ah(this._right,this._bottom,this._left,this._bottom,{lineCap:"round",strokeStyle:ao.xaxis.borderColor,lineWidth:ao.xaxis.borderWidth});ah(this._left,this._bottom,this._left,this._top,{lineCap:"round",strokeStyle:ao.yaxis.borderColor,lineWidth:ao.yaxis.borderWidth})}al.restore();al=null;ao=null};G.jqplot.DivTitleRenderer=function(){};G.jqplot.DivTitleRenderer.prototype.init=function(aa){G.extend(true,this,aa)};G.jqplot.DivTitleRenderer.prototype.draw=function(){if(this._elem){this._elem.emptyForce();this._elem=null}var ad=this.renderer;var ac=document.createElement("div");this._elem=G(ac);this._elem.addClass("jqplot-title");if(!this.text){this.show=false;this._elem.height(0);this._elem.width(0)}else{if(this.text){var aa;if(this.color){aa=this.color}else{if(this.textColor){aa=this.textColor}}var ab={position:"absolute",top:"0px",left:"0px"};if(this._plotWidth){ab.width=this._plotWidth+"px"}if(this.fontSize){ab.fontSize=this.fontSize}if(typeof this.textAlign==="string"){ab.textAlign=this.textAlign}else{ab.textAlign="center"}if(aa){ab.color=aa}if(this.paddingBottom){ab.paddingBottom=this.paddingBottom}if(this.fontFamily){ab.fontFamily=this.fontFamily}this._elem.css(ab);if(this.escapeHtml){this._elem.text(this.text)}else{this._elem.html(this.text)}}}ac=null;return this._elem};G.jqplot.DivTitleRenderer.prototype.pack=function(){};var n=0.1;G.jqplot.LinePattern=function(ao,aj){var ai={dotted:[n,G.jqplot.config.dotGapLength],dashed:[G.jqplot.config.dashLength,G.jqplot.config.gapLength],solid:null};if(typeof aj==="string"){if(aj[0]==="."||aj[0]==="-"){var ap=aj;aj=[];for(var ah=0,ae=ap.length;ah<ae;ah++){if(ap[ah]==="."){aj.push(n)}else{if(ap[ah]==="-"){aj.push(G.jqplot.config.dashLength)}else{continue}}aj.push(G.jqplot.config.gapLength)}}else{aj=ai[aj]}}if(!(aj&&aj.length)){return ao}var ad=0;var ak=aj[0];var am=0;var al=0;var ag=0;var aa=0;var an=function(aq,ar){ao.moveTo(aq,ar);am=aq;al=ar;ag=aq;aa=ar};var ac=function(aq,ax){var av=ao.lineWidth;var at=aq-am;var ar=ax-al;var au=Math.sqrt(at*at+ar*ar);if((au>0)&&(av>0)){at/=au;ar/=au;while(true){var aw=av*ak;if(aw<au){am+=aw*at;al+=aw*ar;if((ad&1)==0){ao.lineTo(am,al)}else{ao.moveTo(am,al)}au-=aw;ad++;if(ad>=aj.length){ad=0}ak=aj[ad]}else{am=aq;al=ax;if((ad&1)==0){ao.lineTo(am,al)}else{ao.moveTo(am,al)}ak-=au/av;break}}}};var ab=function(){ao.beginPath()};var af=function(){ac(ag,aa)};return{moveTo:an,lineTo:ac,beginPath:ab,closePath:af}};G.jqplot.LineRenderer=function(){this.shapeRenderer=new G.jqplot.ShapeRenderer();this.shadowRenderer=new G.jqplot.ShadowRenderer()};G.jqplot.LineRenderer.prototype.init=function(ab,ag){ab=ab||{};this._type="line";this.renderer.smooth=false;this.renderer.tension=null;this.renderer.constrainSmoothing=true;this.renderer._smoothedData=[];this.renderer._smoothedPlotData=[];this.renderer._hiBandGridData=[];this.renderer._lowBandGridData=[];this.renderer._hiBandSmoothedData=[];this.renderer._lowBandSmoothedData=[];this.renderer.bandData=[];this.renderer.bands={show:false,hiData:[],lowData:[],color:this.color,showLines:false,fill:true,fillColor:null,_min:null,_max:null,interval:"3%"};var ae={highlightMouseOver:ab.highlightMouseOver,highlightMouseDown:ab.highlightMouseDown,highlightColor:ab.highlightColor};delete (ab.highlightMouseOver);delete (ab.highlightMouseDown);delete (ab.highlightColor);G.extend(true,this.renderer,ab);this.renderer.options=ab;if(this.renderer.bandData.length>1&&(!ab.bands||ab.bands.show==null)){this.renderer.bands.show=true}else{if(ab.bands&&ab.bands.show==null&&ab.bands.interval!=null){this.renderer.bands.show=true}}if(this.fill){this.renderer.bands.show=false}if(this.renderer.bands.show){this.renderer.initBands.call(this,this.renderer.options,ag)}if(this._stack){this.renderer.smooth=false}var af={lineJoin:this.lineJoin,lineCap:this.lineCap,fill:this.fill,isarc:false,strokeStyle:this.color,fillStyle:this.fillColor,lineWidth:this.lineWidth,linePattern:this.linePattern,closePath:this.fill};this.renderer.shapeRenderer.init(af);var ac=ab.shadowOffset;if(ac==null){if(this.lineWidth>2.5){ac=1.25*(1+(Math.atan((this.lineWidth/2.5))/0.785398163-1)*0.6)}else{ac=1.25*Math.atan((this.lineWidth/2.5))/0.785398163}}var aa={lineJoin:this.lineJoin,lineCap:this.lineCap,fill:this.fill,isarc:false,angle:this.shadowAngle,offset:ac,alpha:this.shadowAlpha,depth:this.shadowDepth,lineWidth:this.lineWidth,linePattern:this.linePattern,closePath:this.fill};this.renderer.shadowRenderer.init(aa);this._areaPoints=[];this._boundingBox=[[],[]];if(!this.isTrendline&&this.fill||this.renderer.bands.show){this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColor=null;if(ae.highlightMouseDown&&ae.highlightMouseOver==null){ae.highlightMouseOver=false}G.extend(true,this,{highlightMouseOver:ae.highlightMouseOver,highlightMouseDown:ae.highlightMouseDown,highlightColor:ae.highlightColor});if(!this.highlightColor){var ad=(this.renderer.bands.show)?this.renderer.bands.fillColor:this.fillColor;this.highlightColor=G.jqplot.computeHighlightColors(ad)}if(this.highlighter){this.highlighter.show=false}}if(!this.isTrendline&&ag){ag.plugins.lineRenderer={};ag.postInitHooks.addOnce(u);ag.postDrawHooks.addOnce(Y);ag.eventListenerHooks.addOnce("jqplotMouseMove",f);ag.eventListenerHooks.addOnce("jqplotMouseDown",c);ag.eventListenerHooks.addOnce("jqplotMouseUp",X);ag.eventListenerHooks.addOnce("jqplotClick",e);ag.eventListenerHooks.addOnce("jqplotRightClick",o)}};G.jqplot.LineRenderer.prototype.initBands=function(ad,an){var ae=ad.bandData||[];var ag=this.renderer.bands;ag.hiData=[];ag.lowData=[];var au=this.data;ag._max=null;ag._min=null;if(ae.length==2){if(G.isArray(ae[0][0])){var ah;var aa=0,ak=0;for(var ao=0,al=ae[0].length;ao<al;ao++){ah=ae[0][ao];if((ah[1]!=null&&ah[1]>ag._max)||ag._max==null){ag._max=ah[1]}if((ah[1]!=null&&ah[1]<ag._min)||ag._min==null){ag._min=ah[1]}}for(var ao=0,al=ae[1].length;ao<al;ao++){ah=ae[1][ao];if((ah[1]!=null&&ah[1]>ag._max)||ag._max==null){ag._max=ah[1];ak=1}if((ah[1]!=null&&ah[1]<ag._min)||ag._min==null){ag._min=ah[1];aa=1}}if(ak===aa){ag.show=false}ag.hiData=ae[ak];ag.lowData=ae[aa]}else{if(ae[0].length===au.length&&ae[1].length===au.length){var ac=(ae[0][0]>ae[1][0])?0:1;var av=(ac)?0:1;for(var ao=0,al=au.length;ao<al;ao++){ag.hiData.push([au[ao][0],ae[ac][ao]]);ag.lowData.push([au[ao][0],ae[av][ao]])}}else{ag.show=false}}}else{if(ae.length>2&&!G.isArray(ae[0][0])){var ac=(ae[0][0]>ae[0][1])?0:1;var av=(ac)?0:1;for(var ao=0,al=ae.length;ao<al;ao++){ag.hiData.push([au[ao][0],ae[ao][ac]]);ag.lowData.push([au[ao][0],ae[ao][av]])}}else{var aj=ag.interval;var at=null;var ar=null;var ab=null;var am=null;if(G.isArray(aj)){at=aj[0];ar=aj[1]}else{at=aj}if(isNaN(at)){if(at.charAt(at.length-1)==="%"){ab="multiply";at=parseFloat(at)/100+1}}else{at=parseFloat(at);ab="add"}if(ar!==null&&isNaN(ar)){if(ar.charAt(ar.length-1)==="%"){am="multiply";ar=parseFloat(ar)/100+1}}else{if(ar!==null){ar=parseFloat(ar);am="add"}}if(at!==null){if(ar===null){ar=-at;am=ab;if(am==="multiply"){ar+=2}}if(at<ar){var ap=at;at=ar;ar=ap;ap=ab;ab=am;am=ap}for(var ao=0,al=au.length;ao<al;ao++){switch(ab){case"add":ag.hiData.push([au[ao][0],au[ao][1]+at]);break;case"multiply":ag.hiData.push([au[ao][0],au[ao][1]*at]);break}switch(am){case"add":ag.lowData.push([au[ao][0],au[ao][1]+ar]);break;case"multiply":ag.lowData.push([au[ao][0],au[ao][1]*ar]);break}}}else{ag.show=false}}}var af=ag.hiData;var ai=ag.lowData;for(var ao=0,al=af.length;ao<al;ao++){if((af[ao][1]!=null&&af[ao][1]>ag._max)||ag._max==null){ag._max=af[ao][1]}}for(var ao=0,al=ai.length;ao<al;ao++){if((ai[ao][1]!=null&&ai[ao][1]<ag._min)||ag._min==null){ag._min=ai[ao][1]}}if(ag.fillColor===null){var aq=G.jqplot.getColorComponents(ag.color);aq[3]=aq[3]*0.5;ag.fillColor="rgba("+aq[0]+", "+aq[1]+", "+aq[2]+", "+aq[3]+")"}};function F(ab,aa){return(3.4182054+aa)*Math.pow(ab,-0.3534992)}function j(ac,ab){var aa=Math.sqrt(Math.pow((ab[0]-ac[0]),2)+Math.pow((ab[1]-ac[1]),2));return 5.7648*Math.log(aa)+7.4456}function v(aa){var ab=(Math.exp(2*aa)-1)/(Math.exp(2*aa)+1);return ab}function E(aC){var al=this.renderer.smooth;var aw=this.canvas.getWidth();var ag=this._xaxis.series_p2u;var az=this._yaxis.series_p2u;var ay=null;var af=null;var ar=aC.length/aw;var ac=[];var aq=[];if(!isNaN(parseFloat(al))){ay=parseFloat(al)}else{ay=F(ar,0.5)}var ao=[];var ad=[];for(var ax=0,at=aC.length;ax<at;ax++){ao.push(aC[ax][1]);ad.push(aC[ax][0])}function an(aD,aE){if(aD-aE==0){return Math.pow(10,10)}else{return aD-aE}}var ap,ak,aj,ai;var aa=aC.length-1;for(var ae=1,au=aC.length;ae<au;ae++){var ab=[];var am=[];for(var av=0;av<2;av++){var ax=ae-1+av;if(ax==0||ax==aa){ab[av]=Math.pow(10,10)}else{if(ao[ax+1]-ao[ax]==0||ao[ax]-ao[ax-1]==0){ab[av]=0}else{if(((ad[ax+1]-ad[ax])/(ao[ax+1]-ao[ax])+(ad[ax]-ad[ax-1])/(ao[ax]-ao[ax-1]))==0){ab[av]=0}else{if((ao[ax+1]-ao[ax])*(ao[ax]-ao[ax-1])<0){ab[av]=0}else{ab[av]=2/(an(ad[ax+1],ad[ax])/(ao[ax+1]-ao[ax])+an(ad[ax],ad[ax-1])/(ao[ax]-ao[ax-1]))}}}}}if(ae==1){ab[0]=3/2*(ao[1]-ao[0])/an(ad[1],ad[0])-ab[1]/2}else{if(ae==aa){ab[1]=3/2*(ao[aa]-ao[aa-1])/an(ad[aa],ad[aa-1])-ab[0]/2}}am[0]=-2*(ab[1]+2*ab[0])/an(ad[ae],ad[ae-1])+6*(ao[ae]-ao[ae-1])/Math.pow(an(ad[ae],ad[ae-1]),2);am[1]=2*(2*ab[1]+ab[0])/an(ad[ae],ad[ae-1])-6*(ao[ae]-ao[ae-1])/Math.pow(an(ad[ae],ad[ae-1]),2);ai=1/6*(am[1]-am[0])/an(ad[ae],ad[ae-1]);aj=1/2*(ad[ae]*am[0]-ad[ae-1]*am[1])/an(ad[ae],ad[ae-1]);ak=(ao[ae]-ao[ae-1]-aj*(Math.pow(ad[ae],2)-Math.pow(ad[ae-1],2))-ai*(Math.pow(ad[ae],3)-Math.pow(ad[ae-1],3)))/an(ad[ae],ad[ae-1]);ap=ao[ae-1]-ak*ad[ae-1]-aj*Math.pow(ad[ae-1],2)-ai*Math.pow(ad[ae-1],3);var aB=(ad[ae]-ad[ae-1])/ay;var aA,ah;for(var av=0,at=ay;av<at;av++){aA=[];ah=ad[ae-1]+av*aB;aA.push(ah);aA.push(ap+ak*ah+aj*Math.pow(ah,2)+ai*Math.pow(ah,3));ac.push(aA);aq.push([ag(aA[0]),az(aA[1])])}}ac.push(aC[ax]);aq.push([ag(aC[ax][0]),az(aC[ax][1])]);return[ac,aq]}function A(ai){var ah=this.renderer.smooth;var aN=this.renderer.tension;var aa=this.canvas.getWidth();var aA=this._xaxis.series_p2u;var aj=this._yaxis.series_p2u;var aB=null;var aC=null;var aM=null;var aH=null;var aF=null;var al=null;var aK=null;var af=null;var aD,aE,aw,av,at,aq;var ad,ab,an,am;var au,ar,aG;var ao=[];var ac=[];var ae=ai.length/aa;var aL,ap,ay,az,ax;var ak=[];var ag=[];if(!isNaN(parseFloat(ah))){aB=parseFloat(ah)}else{aB=F(ae,0.5)}if(!isNaN(parseFloat(aN))){aN=parseFloat(aN)}for(var aJ=0,aI=ai.length-1;aJ<aI;aJ++){if(aN===null){al=Math.abs((ai[aJ+1][1]-ai[aJ][1])/(ai[aJ+1][0]-ai[aJ][0]));aL=0.3;ap=0.6;ay=(ap-aL)/2;az=2.5;ax=-1.4;af=al/az+ax;aH=ay*v(af)-ay*v(ax)+aL;if(aJ>0){aK=Math.abs((ai[aJ][1]-ai[aJ-1][1])/(ai[aJ][0]-ai[aJ-1][0]))}af=aK/az+ax;aF=ay*v(af)-ay*v(ax)+aL;aM=(aH+aF)/2}else{aM=aN}for(aD=0;aD<aB;aD++){aE=aD/aB;aw=(1+2*aE)*Math.pow((1-aE),2);av=aE*Math.pow((1-aE),2);at=Math.pow(aE,2)*(3-2*aE);aq=Math.pow(aE,2)*(aE-1);if(ai[aJ-1]){ad=aM*(ai[aJ+1][0]-ai[aJ-1][0]);ab=aM*(ai[aJ+1][1]-ai[aJ-1][1])}else{ad=aM*(ai[aJ+1][0]-ai[aJ][0]);ab=aM*(ai[aJ+1][1]-ai[aJ][1])}if(ai[aJ+2]){an=aM*(ai[aJ+2][0]-ai[aJ][0]);am=aM*(ai[aJ+2][1]-ai[aJ][1])}else{an=aM*(ai[aJ+1][0]-ai[aJ][0]);am=aM*(ai[aJ+1][1]-ai[aJ][1])}au=aw*ai[aJ][0]+at*ai[aJ+1][0]+av*ad+aq*an;ar=aw*ai[aJ][1]+at*ai[aJ+1][1]+av*ab+aq*am;aG=[au,ar];ak.push(aG);ag.push([aA(au),aj(ar)])}}ak.push(ai[aI]);ag.push([aA(ai[aI][0]),aj(ai[aI][1])]);return[ak,ag]}G.jqplot.LineRenderer.prototype.setGridData=function(ai){var ae=this._xaxis.series_u2p;var aa=this._yaxis.series_u2p;var af=this._plotData;var aj=this._prevPlotData;this.gridData=[];this._prevGridData=[];this.renderer._smoothedData=[];this.renderer._smoothedPlotData=[];this.renderer._hiBandGridData=[];this.renderer._lowBandGridData=[];this.renderer._hiBandSmoothedData=[];this.renderer._lowBandSmoothedData=[];var ad=this.renderer.bands;var ab=false;for(var ag=0,ac=this.data.length;ag<ac;ag++){if(af[ag][0]!=null&&af[ag][1]!=null){this.gridData.push([ae.call(this._xaxis,af[ag][0]),aa.call(this._yaxis,af[ag][1])])}else{if(af[ag][0]==null){ab=true;this.gridData.push([null,aa.call(this._yaxis,af[ag][1])])}else{if(af[ag][1]==null){ab=true;this.gridData.push([ae.call(this._xaxis,af[ag][0]),null])}}}if(aj[ag]!=null&&aj[ag][0]!=null&&aj[ag][1]!=null){this._prevGridData.push([ae.call(this._xaxis,aj[ag][0]),aa.call(this._yaxis,aj[ag][1])])}else{if(aj[ag]!=null&&aj[ag][0]==null){this._prevGridData.push([null,aa.call(this._yaxis,aj[ag][1])])}else{if(aj[ag]!=null&&aj[ag][0]!=null&&aj[ag][1]==null){this._prevGridData.push([ae.call(this._xaxis,aj[ag][0]),null])}}}}if(ab){this.renderer.smooth=false;if(this._type==="line"){ad.show=false}}if(this._type==="line"&&ad.show){for(var ag=0,ac=ad.hiData.length;ag<ac;ag++){this.renderer._hiBandGridData.push([ae.call(this._xaxis,ad.hiData[ag][0]),aa.call(this._yaxis,ad.hiData[ag][1])])}for(var ag=0,ac=ad.lowData.length;ag<ac;ag++){this.renderer._lowBandGridData.push([ae.call(this._xaxis,ad.lowData[ag][0]),aa.call(this._yaxis,ad.lowData[ag][1])])}}if(this._type==="line"&&this.renderer.smooth&&this.gridData.length>2){var ah;if(this.renderer.constrainSmoothing){ah=E.call(this,this.gridData);this.renderer._smoothedData=ah[0];this.renderer._smoothedPlotData=ah[1];if(ad.show){ah=E.call(this,this.renderer._hiBandGridData);this.renderer._hiBandSmoothedData=ah[0];ah=E.call(this,this.renderer._lowBandGridData);this.renderer._lowBandSmoothedData=ah[0]}ah=null}else{ah=A.call(this,this.gridData);this.renderer._smoothedData=ah[0];this.renderer._smoothedPlotData=ah[1];if(ad.show){ah=A.call(this,this.renderer._hiBandGridData);this.renderer._hiBandSmoothedData=ah[0];ah=A.call(this,this.renderer._lowBandGridData);this.renderer._lowBandSmoothedData=ah[0]}ah=null}}};G.jqplot.LineRenderer.prototype.makeGridData=function(ah,aj){var af=this._xaxis.series_u2p;var aa=this._yaxis.series_u2p;var ak=[];var ac=[];this.renderer._smoothedData=[];this.renderer._smoothedPlotData=[];this.renderer._hiBandGridData=[];this.renderer._lowBandGridData=[];this.renderer._hiBandSmoothedData=[];this.renderer._lowBandSmoothedData=[];var ae=this.renderer.bands;var ab=false;for(var ag=0;ag<ah.length;ag++){if(ah[ag][0]!=null&&ah[ag][1]!=null){ak.push([af.call(this._xaxis,ah[ag][0]),aa.call(this._yaxis,ah[ag][1])])}else{if(ah[ag][0]==null){ab=true;ak.push([null,aa.call(this._yaxis,ah[ag][1])])}else{if(ah[ag][1]==null){ab=true;ak.push([af.call(this._xaxis,ah[ag][0]),null])}}}}if(ab){this.renderer.smooth=false;if(this._type==="line"){ae.show=false}}if(this._type==="line"&&ae.show){for(var ag=0,ad=ae.hiData.length;ag<ad;ag++){this.renderer._hiBandGridData.push([af.call(this._xaxis,ae.hiData[ag][0]),aa.call(this._yaxis,ae.hiData[ag][1])])}for(var ag=0,ad=ae.lowData.length;ag<ad;ag++){this.renderer._lowBandGridData.push([af.call(this._xaxis,ae.lowData[ag][0]),aa.call(this._yaxis,ae.lowData[ag][1])])}}if(this._type==="line"&&this.renderer.smooth&&ak.length>2){var ai;if(this.renderer.constrainSmoothing){ai=E.call(this,ak);this.renderer._smoothedData=ai[0];this.renderer._smoothedPlotData=ai[1];if(ae.show){ai=E.call(this,this.renderer._hiBandGridData);this.renderer._hiBandSmoothedData=ai[0];ai=E.call(this,this.renderer._lowBandGridData);this.renderer._lowBandSmoothedData=ai[0]}ai=null}else{ai=A.call(this,ak);this.renderer._smoothedData=ai[0];this.renderer._smoothedPlotData=ai[1];if(ae.show){ai=A.call(this,this.renderer._hiBandGridData);this.renderer._hiBandSmoothedData=ai[0];ai=A.call(this,this.renderer._lowBandGridData);this.renderer._lowBandSmoothedData=ai[0]}ai=null}}return ak};G.jqplot.LineRenderer.prototype.draw=function(ap,aB,ab,au){var av;var aj=G.extend(true,{},ab);var ad=(aj.shadow!=q)?aj.shadow:this.shadow;var aC=(aj.showLine!=q)?aj.showLine:this.showLine;var at=(aj.fill!=q)?aj.fill:this.fill;var aa=(aj.fillAndStroke!=q)?aj.fillAndStroke:this.fillAndStroke;var ak,aq,an,ax;ap.save();if(aB.length){if(aC){if(at){if(this.fillToZero){var ay=this.negativeColor;if(!this.useNegativeColors){ay=aj.fillStyle}var ah=false;var ai=aj.fillStyle;if(aa){var aA=aB.slice(0)}if(this.index==0||!this._stack){var ao=[];var aE=(this.renderer.smooth)?this.renderer._smoothedPlotData:this._plotData;this._areaPoints=[];var az=this._yaxis.series_u2p(this.fillToValue);var ac=this._xaxis.series_u2p(this.fillToValue);aj.closePath=true;if(this.fillAxis=="y"){ao.push([aB[0][0],az]);this._areaPoints.push([aB[0][0],az]);for(var av=0;av<aB.length-1;av++){ao.push(aB[av]);this._areaPoints.push(aB[av]);if(aE[av][1]*aE[av+1][1]<0){if(aE[av][1]<0){ah=true;aj.fillStyle=ay}else{ah=false;aj.fillStyle=ai}var ag=aB[av][0]+(aB[av+1][0]-aB[av][0])*(az-aB[av][1])/(aB[av+1][1]-aB[av][1]);ao.push([ag,az]);this._areaPoints.push([ag,az]);if(ad){this.renderer.shadowRenderer.draw(ap,ao,aj)}this.renderer.shapeRenderer.draw(ap,ao,aj);ao=[[ag,az]]}}if(aE[aB.length-1][1]<0){ah=true;aj.fillStyle=ay}else{ah=false;aj.fillStyle=ai}ao.push(aB[aB.length-1]);this._areaPoints.push(aB[aB.length-1]);ao.push([aB[aB.length-1][0],az]);this._areaPoints.push([aB[aB.length-1][0],az])}if(ad){this.renderer.shadowRenderer.draw(ap,ao,aj)}this.renderer.shapeRenderer.draw(ap,ao,aj)}else{var am=this._prevGridData;for(var av=am.length;av>0;av--){aB.push(am[av-1])}if(ad){this.renderer.shadowRenderer.draw(ap,aB,aj)}this._areaPoints=aB;this.renderer.shapeRenderer.draw(ap,aB,aj)}}else{if(aa){var aA=aB.slice(0)}if(this.index==0||!this._stack){var ae=ap.canvas.height;aB.unshift([aB[0][0],ae]);var aw=aB.length;aB.push([aB[aw-1][0],ae])}else{var am=this._prevGridData;for(var av=am.length;av>0;av--){aB.push(am[av-1])}}this._areaPoints=aB;if(ad){this.renderer.shadowRenderer.draw(ap,aB,aj)}this.renderer.shapeRenderer.draw(ap,aB,aj)}if(aa){var ar=G.extend(true,{},aj,{fill:false,closePath:false});this.renderer.shapeRenderer.draw(ap,aA,ar);if(this.markerRenderer.show){if(this.renderer.smooth){aA=this.gridData}for(av=0;av<aA.length;av++){this.markerRenderer.draw(aA[av][0],aA[av][1],ap,aj.markerOptions)}}}}else{if(this.renderer.bands.show){var af;var aD=G.extend(true,{},aj);if(this.renderer.bands.showLines){af=(this.renderer.smooth)?this.renderer._hiBandSmoothedData:this.renderer._hiBandGridData;this.renderer.shapeRenderer.draw(ap,af,aj);af=(this.renderer.smooth)?this.renderer._lowBandSmoothedData:this.renderer._lowBandGridData;this.renderer.shapeRenderer.draw(ap,af,aD)}if(this.renderer.bands.fill){if(this.renderer.smooth){af=this.renderer._hiBandSmoothedData.concat(this.renderer._lowBandSmoothedData.reverse())}else{af=this.renderer._hiBandGridData.concat(this.renderer._lowBandGridData.reverse())}this._areaPoints=af;aD.closePath=true;aD.fill=true;aD.fillStyle=this.renderer.bands.fillColor;this.renderer.shapeRenderer.draw(ap,af,aD)}}if(ad){this.renderer.shadowRenderer.draw(ap,aB,aj)}this.renderer.shapeRenderer.draw(ap,aB,aj)}}var ak=an=aq=ax=null;for(av=0;av<this._areaPoints.length;av++){var al=this._areaPoints[av];if(ak>al[0]||ak==null){ak=al[0]}if(ax<al[1]||ax==null){ax=al[1]}if(an<al[0]||an==null){an=al[0]}if(aq>al[1]||aq==null){aq=al[1]}}if(this.type==="line"&&this.renderer.bands.show){ax=this._yaxis.series_u2p(this.renderer.bands._min);aq=this._yaxis.series_u2p(this.renderer.bands._max)}this._boundingBox=[[ak,ax],[an,aq]];if(this.markerRenderer.show&&!at){if(this.renderer.smooth){aB=this.gridData}for(av=0;av<aB.length;av++){if(aB[av][0]!=null&&aB[av][1]!=null){this.markerRenderer.draw(aB[av][0],aB[av][1],ap,aj.markerOptions)}}}}ap.restore()};G.jqplot.LineRenderer.prototype.drawShadow=function(aa,ac,ab){};function u(ad,ac,aa){for(var ab=0;ab<this.series.length;ab++){if(this.series[ab].renderer.constructor==G.jqplot.LineRenderer){if(this.series[ab].highlightMouseOver){this.series[ab].highlightMouseDown=false}}}}function Y(){if(this.plugins.lineRenderer&&this.plugins.lineRenderer.highlightCanvas){this.plugins.lineRenderer.highlightCanvas.resetCanvas();this.plugins.lineRenderer.highlightCanvas=null}this.plugins.lineRenderer.highlightedSeriesIndex=null;this.plugins.lineRenderer.highlightCanvas=new G.jqplot.GenericCanvas();this.eventCanvas._elem.before(this.plugins.lineRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-lineRenderer-highlight-canvas",this._plotDimensions,this));this.plugins.lineRenderer.highlightCanvas.setContext();this.eventCanvas._elem.bind("mouseleave",{plot:this},function(aa){U(aa.data.plot)})}function W(ag,af,ad,ac){var ab=ag.series[af];var aa=ag.plugins.lineRenderer.highlightCanvas;aa._ctx.clearRect(0,0,aa._ctx.canvas.width,aa._ctx.canvas.height);ab._highlightedPoint=ad;ag.plugins.lineRenderer.highlightedSeriesIndex=af;var ae={fillStyle:ab.highlightColor};if(ab.type==="line"&&ab.renderer.bands.show){ae.fill=true;ae.closePath=true}ab.renderer.shapeRenderer.draw(aa._ctx,ac,ae);aa=null}function U(ac){var aa=ac.plugins.lineRenderer.highlightCanvas;aa._ctx.clearRect(0,0,aa._ctx.canvas.width,aa._ctx.canvas.height);for(var ab=0;ab<ac.series.length;ab++){ac.series[ab]._highlightedPoint=null}ac.plugins.lineRenderer.highlightedSeriesIndex=null;ac.target.trigger("jqplotDataUnhighlight");aa=null}function f(ae,ad,ah,ag,af){if(ag){var ac=[ag.seriesIndex,ag.pointIndex,ag.data];var ab=jQuery.Event("jqplotDataMouseOver");ab.pageX=ae.pageX;ab.pageY=ae.pageY;af.target.trigger(ab,ac);if(af.series[ac[0]].highlightMouseOver&&!(ac[0]==af.plugins.lineRenderer.highlightedSeriesIndex)){var aa=jQuery.Event("jqplotDataHighlight");aa.pageX=ae.pageX;aa.pageY=ae.pageY;af.target.trigger(aa,ac);W(af,ag.seriesIndex,ag.pointIndex,ag.points)}}else{if(ag==null){U(af)}}}function c(ad,ac,ag,af,ae){if(af){var ab=[af.seriesIndex,af.pointIndex,af.data];if(ae.series[ab[0]].highlightMouseDown&&!(ab[0]==ae.plugins.lineRenderer.highlightedSeriesIndex)){var aa=jQuery.Event("jqplotDataHighlight");aa.pageX=ad.pageX;aa.pageY=ad.pageY;ae.target.trigger(aa,ab);W(ae,af.seriesIndex,af.pointIndex,af.points)}}else{if(af==null){U(ae)}}}function X(ac,ab,af,ae,ad){var aa=ad.plugins.lineRenderer.highlightedSeriesIndex;if(aa!=null&&ad.series[aa].highlightMouseDown){U(ad)}}function e(ad,ac,ag,af,ae){if(af){var ab=[af.seriesIndex,af.pointIndex,af.data];var aa=jQuery.Event("jqplotDataClick");aa.pageX=ad.pageX;aa.pageY=ad.pageY;ae.target.trigger(aa,ab)}}function o(ae,ad,ah,ag,af){if(ag){var ac=[ag.seriesIndex,ag.pointIndex,ag.data];var aa=af.plugins.lineRenderer.highlightedSeriesIndex;if(aa!=null&&af.series[aa].highlightMouseDown){U(af)}var ab=jQuery.Event("jqplotDataRightClick");ab.pageX=ae.pageX;ab.pageY=ae.pageY;af.target.trigger(ab,ac)}}G.jqplot.LinearAxisRenderer=function(){};G.jqplot.LinearAxisRenderer.prototype.init=function(aa){this.breakPoints=null;this.breakTickLabel="&asymp;";this.drawBaseline=true;this.baselineWidth=null;this.baselineColor=null;this.forceTickAt0=false;this.forceTickAt100=false;this.tickInset=0;this.minorTicks=0;this.alignTicks=false;this._autoFormatString="";this._overrideFormatString=false;this._scalefact=1;G.extend(true,this,aa);if(this.breakPoints){if(!G.isArray(this.breakPoints)){this.breakPoints=null}else{if(this.breakPoints.length<2||this.breakPoints[1]<=this.breakPoints[0]){this.breakPoints=null}}}if(this.numberTicks!=null&&this.numberTicks<2){this.numberTicks=2}this.resetDataBounds()};G.jqplot.LinearAxisRenderer.prototype.draw=function(aa,ah){if(this.show){this.renderer.createTicks.call(this,ah);var ag=0;var ab;if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=G(document.createElement("div"));this._elem.addClass("jqplot-axis jqplot-"+this.name);this._elem.css("position","absolute");if(this.name=="xaxis"||this.name=="x2axis"){this._elem.width(this._plotDimensions.width)}else{this._elem.height(this._plotDimensions.height)}this.labelOptions.axis=this.name;this._label=new this.labelRenderer(this.labelOptions);if(this._label.show){var af=this._label.draw(aa,ah);af.appendTo(this._elem);af=null}var ae=this._ticks;var ad;for(var ac=0;ac<ae.length;ac++){ad=ae[ac];if(ad.show&&ad.showLabel&&(!ad.isMinorTick||this.showMinorTicks)){this._elem.append(ad.draw(aa,ah))}}ad=null;ae=null}return this._elem};G.jqplot.LinearAxisRenderer.prototype.reset=function(){this.min=this._options.min;this.max=this._options.max;this.tickInterval=this._options.tickInterval;this.numberTicks=this._options.numberTicks;this._autoFormatString="";if(this._overrideFormatString&&this.tickOptions&&this.tickOptions.formatString){this.tickOptions.formatString=""}};G.jqplot.LinearAxisRenderer.prototype.set=function(){var ah=0;var ac;var ab=0;var ag=0;var aa=(this._label==null)?false:this._label.show;if(this.show){var af=this._ticks;var ae;for(var ad=0;ad<af.length;ad++){ae=af[ad];if(!ae._breakTick&&ae.show&&ae.showLabel&&(!ae.isMinorTick||this.showMinorTicks)){if(this.name=="xaxis"||this.name=="x2axis"){ac=ae._elem.outerHeight(true)}else{ac=ae._elem.outerWidth(true)}if(ac>ah){ah=ac}}}ae=null;af=null;if(aa){ab=this._label._elem.outerWidth(true);ag=this._label._elem.outerHeight(true)}if(this.name=="xaxis"){ah=ah+ag;this._elem.css({height:ah+"px",left:"0px",bottom:"0px"})}else{if(this.name=="x2axis"){ah=ah+ag;this._elem.css({height:ah+"px",left:"0px",top:"0px"})}else{if(this.name=="yaxis"){ah=ah+ab;this._elem.css({width:ah+"px",left:"0px",top:"0px"});if(aa&&this._label.constructor==G.jqplot.AxisLabelRenderer){this._label._elem.css("width",ab+"px")}}else{ah=ah+ab;this._elem.css({width:ah+"px",right:"0px",top:"0px"});if(aa&&this._label.constructor==G.jqplot.AxisLabelRenderer){this._label._elem.css("width",ab+"px")}}}}}};G.jqplot.LinearAxisRenderer.prototype.createTicks=function(ac){var aM=this._ticks;var aC=this.ticks;var ar=this.name;var au=this._dataBounds;var aa,ag;var aY,aA;var ai,ah;var aW,aT;var az=this.min;var aX=this.max;var aP=this.numberTicks;var a2=this.tickInterval;if(aC.length){for(aT=0;aT<aC.length;aT++){var aG=aC[aT];var aN=new this.tickRenderer(this.tickOptions);if(G.isArray(aG)){aN.value=aG[0];if(this.breakPoints){if(aG[0]==this.breakPoints[0]){aN.label=this.breakTickLabel;aN._breakTick=true;aN.showGridline=false;aN.showMark=false}else{if(aG[0]>this.breakPoints[0]&&aG[0]<=this.breakPoints[1]){aN.show=false;aN.showGridline=false;aN.label=aG[1]}else{aN.label=aG[1]}}}else{aN.label=aG[1]}aN.setTick(aG[0],this.name);this._ticks.push(aN)}else{if(G.isPlainObject(aG)){G.extend(true,aN,aG);aN.axis=this.name;this._ticks.push(aN)}else{aN.value=aG;if(this.breakPoints){if(aG==this.breakPoints[0]){aN.label=this.breakTickLabel;aN._breakTick=true;aN.showGridline=false;aN.showMark=false}else{if(aG>this.breakPoints[0]&&aG<=this.breakPoints[1]){aN.show=false;aN.showGridline=false}}}aN.setTick(aG,this.name);this._ticks.push(aN)}}}this.numberTicks=aC.length;this.min=this._ticks[0].value;this.max=this._ticks[this.numberTicks-1].value;this.tickInterval=(this.max-this.min)/(this.numberTicks-1)}else{if(ar=="xaxis"||ar=="x2axis"){aa=this._plotDimensions.width}else{aa=this._plotDimensions.height}var ap=this.numberTicks;if(this.alignTicks){if(this.name==="x2axis"&&ac.axes.xaxis.show){ap=ac.axes.xaxis.numberTicks}else{if(this.name.charAt(0)==="y"&&this.name!=="yaxis"&&this.name!=="yMidAxis"&&ac.axes.yaxis.show){ap=ac.axes.yaxis.numberTicks}}}aY=((this.min!=null)?this.min:au.min);aA=((this.max!=null)?this.max:au.max);var an=aA-aY;var aL,aq;var al;if(this.tickOptions==null||!this.tickOptions.formatString){this._overrideFormatString=true}if(this.min==null&&this.max==null&&this.tickInterval==null&&!this.autoscale){if(this.forceTickAt0){if(aY>0){aY=0}if(aA<0){aA=0}}if(this.forceTickAt100){if(aY>100){aY=100}if(aA<100){aA=100}}var af=30;var aI=Math.max(aa,af+1);this._scalefact=(aI-af)/300;var aH=G.jqplot.LinearTickGenerator(aY,aA,this._scalefact,ap);var ao=aY+an*(this.padMin-1);var aJ=aA-an*(this.padMax-1);if(aY<ao||aA>aJ){ao=aY-an*(this.padMin-1);aJ=aA+an*(this.padMax-1);aH=G.jqplot.LinearTickGenerator(ao,aJ,this._scalefact,ap)}this.min=aH[0];this.max=aH[1];this.numberTicks=aH[2];this._autoFormatString=aH[3];this.tickInterval=aH[4]}else{if(aY==aA){var ab=0.05;if(aY>0){ab=Math.max(Math.log(aY)/Math.LN10,0.05)}aY-=ab;aA+=ab}if(this.autoscale&&this.min==null&&this.max==null){var ad,ae,ak;var av=false;var aF=false;var at={min:null,max:null,average:null,stddev:null};for(var aT=0;aT<this._series.length;aT++){var aO=this._series[aT];var aw=(aO.fillAxis=="x")?aO._xaxis.name:aO._yaxis.name;if(this.name==aw){var aK=aO._plotValues[aO.fillAxis];var ay=aK[0];var aU=aK[0];for(var aS=1;aS<aK.length;aS++){if(aK[aS]<ay){ay=aK[aS]}else{if(aK[aS]>aU){aU=aK[aS]}}}var am=(aU-ay)/aU;if(aO.renderer.constructor==G.jqplot.BarRenderer){if(ay>=0&&(aO.fillToZero||am>0.1)){av=true}else{av=false;if(aO.fill&&aO.fillToZero&&ay<0&&aU>0){aF=true}else{aF=false}}}else{if(aO.fill){if(ay>=0&&(aO.fillToZero||am>0.1)){av=true}else{if(ay<0&&aU>0&&aO.fillToZero){av=false;aF=true}else{av=false;aF=false}}}else{if(ay<0){av=false}}}}}if(av){this.numberTicks=2+Math.ceil((aa-(this.tickSpacing-1))/this.tickSpacing);this.min=0;az=0;ae=aA/(this.numberTicks-1);al=Math.pow(10,Math.abs(Math.floor(Math.log(ae)/Math.LN10)));if(ae/al==parseInt(ae/al,10)){ae+=al}this.tickInterval=Math.ceil(ae/al)*al;this.max=this.tickInterval*(this.numberTicks-1)}else{if(aF){this.numberTicks=2+Math.ceil((aa-(this.tickSpacing-1))/this.tickSpacing);var aB=Math.ceil(Math.abs(aY)/an*(this.numberTicks-1));var a1=this.numberTicks-1-aB;ae=Math.max(Math.abs(aY/aB),Math.abs(aA/a1));al=Math.pow(10,Math.abs(Math.floor(Math.log(ae)/Math.LN10)));this.tickInterval=Math.ceil(ae/al)*al;this.max=this.tickInterval*a1;this.min=-this.tickInterval*aB}else{if(this.numberTicks==null){if(this.tickInterval){this.numberTicks=3+Math.ceil(an/this.tickInterval)}else{this.numberTicks=2+Math.ceil((aa-(this.tickSpacing-1))/this.tickSpacing)}}if(this.tickInterval==null){ae=an/(this.numberTicks-1);if(ae<1){al=Math.pow(10,Math.abs(Math.floor(Math.log(ae)/Math.LN10)))}else{al=1}this.tickInterval=Math.ceil(ae*al*this.pad)/al}else{al=1/this.tickInterval}ad=this.tickInterval*(this.numberTicks-1);ak=(ad-an)/2;if(this.min==null){this.min=Math.floor(al*(aY-ak))/al}if(this.max==null){this.max=this.min+ad}}}var ax=G.jqplot.getSignificantFigures(this.tickInterval);var aE;if(ax.digitsLeft>=ax.significantDigits){aE="%d"}else{var al=Math.max(0,5-ax.digitsLeft);al=Math.min(al,ax.digitsRight);aE="%."+al+"f"}this._autoFormatString=aE}else{aL=(this.min!=null)?this.min:aY-an*(this.padMin-1);aq=(this.max!=null)?this.max:aA+an*(this.padMax-1);an=aq-aL;if(this.numberTicks==null){if(this.tickInterval!=null){this.numberTicks=Math.ceil((aq-aL)/this.tickInterval)+1}else{if(aa>100){this.numberTicks=parseInt(3+(aa-100)/75,10)}else{this.numberTicks=2}}}if(this.tickInterval==null){this.tickInterval=an/(this.numberTicks-1)}if(this.max==null){aq=aL+this.tickInterval*(this.numberTicks-1)}if(this.min==null){aL=aq-this.tickInterval*(this.numberTicks-1)}var ax=G.jqplot.getSignificantFigures(this.tickInterval);var aE;if(ax.digitsLeft>=ax.significantDigits){aE="%d"}else{var al=Math.max(0,5-ax.digitsLeft);al=Math.min(al,ax.digitsRight);aE="%."+al+"f"}this._autoFormatString=aE;this.min=aL;this.max=aq}if(this.renderer.constructor==G.jqplot.LinearAxisRenderer&&this._autoFormatString==""){an=this.max-this.min;var aZ=new this.tickRenderer(this.tickOptions);var aD=aZ.formatString||G.jqplot.config.defaultTickFormatString;var aD=aD.match(G.jqplot.sprintf.regex)[0];var aV=0;if(aD){if(aD.search(/[fFeEgGpP]/)>-1){var aR=aD.match(/\%\.(\d{0,})?[eEfFgGpP]/);if(aR){aV=parseInt(aR[1],10)}else{aV=6}}else{if(aD.search(/[di]/)>-1){aV=0}}var aj=Math.pow(10,-aV);if(this.tickInterval<aj){if(aP==null&&a2==null){this.tickInterval=aj;if(aX==null&&az==null){this.min=Math.floor(this._dataBounds.min/aj)*aj;if(this.min==this._dataBounds.min){this.min=this._dataBounds.min-this.tickInterval}this.max=Math.ceil(this._dataBounds.max/aj)*aj;if(this.max==this._dataBounds.max){this.max=this._dataBounds.max+this.tickInterval}var aQ=(this.max-this.min)/this.tickInterval;aQ=aQ.toFixed(11);aQ=Math.ceil(aQ);this.numberTicks=aQ+1}else{if(aX==null){var aQ=(this._dataBounds.max-this.min)/this.tickInterval;aQ=aQ.toFixed(11);this.numberTicks=Math.ceil(aQ)+2;this.max=this.min+this.tickInterval*(this.numberTicks-1)}else{if(az==null){var aQ=(this.max-this._dataBounds.min)/this.tickInterval;aQ=aQ.toFixed(11);this.numberTicks=Math.ceil(aQ)+2;this.min=this.max-this.tickInterval*(this.numberTicks-1)}else{this.numberTicks=Math.ceil((aX-az)/this.tickInterval)+1;this.min=Math.floor(az*Math.pow(10,aV))/Math.pow(10,aV);this.max=Math.ceil(aX*Math.pow(10,aV))/Math.pow(10,aV);this.numberTicks=Math.ceil((this.max-this.min)/this.tickInterval)+1}}}}}}}}if(this._overrideFormatString&&this._autoFormatString!=""){this.tickOptions=this.tickOptions||{};this.tickOptions.formatString=this._autoFormatString}var aN,a0;for(var aT=0;aT<this.numberTicks;aT++){aW=this.min+aT*this.tickInterval;aN=new this.tickRenderer(this.tickOptions);aN.setTick(aW,this.name);this._ticks.push(aN);if(aT<this.numberTicks-1){for(var aS=0;aS<this.minorTicks;aS++){aW+=this.tickInterval/(this.minorTicks+1);a0=G.extend(true,{},this.tickOptions,{name:this.name,value:aW,label:"",isMinorTick:true});aN=new this.tickRenderer(a0);this._ticks.push(aN)}}aN=null}}if(this.tickInset){this.min=this.min-this.tickInset*this.tickInterval;this.max=this.max+this.tickInset*this.tickInterval}aM=null};G.jqplot.LinearAxisRenderer.prototype.resetTickValues=function(ac){if(G.isArray(ac)&&ac.length==this._ticks.length){var ab;for(var aa=0;aa<ac.length;aa++){ab=this._ticks[aa];ab.value=ac[aa];ab.label=ab.formatter(ab.formatString,ac[aa]);ab.label=ab.prefix+ab.label;ab._elem.html(ab.label)}ab=null;this.min=G.jqplot.arrayMin(ac);this.max=G.jqplot.arrayMax(ac);this.pack()}};G.jqplot.LinearAxisRenderer.prototype.pack=function(ac,ab){ac=ac||{};ab=ab||this._offsets;var aq=this._ticks;var am=this.max;var al=this.min;var ah=ab.max;var af=ab.min;var aj=(this._label==null)?false:this._label.show;for(var ak in ac){this._elem.css(ak,ac[ak])}this._offsets=ab;var ad=ah-af;var ae=am-al;if(this.breakPoints){ae=ae-this.breakPoints[1]+this.breakPoints[0];this.p2u=function(at){return(at-af)*ae/ad+al};this.u2p=function(at){if(at>this.breakPoints[0]&&at<this.breakPoints[1]){at=this.breakPoints[0]}if(at<=this.breakPoints[0]){return(at-al)*ad/ae+af}else{return(at-this.breakPoints[1]+this.breakPoints[0]-al)*ad/ae+af}};if(this.name.charAt(0)=="x"){this.series_u2p=function(at){if(at>this.breakPoints[0]&&at<this.breakPoints[1]){at=this.breakPoints[0]}if(at<=this.breakPoints[0]){return(at-al)*ad/ae}else{return(at-this.breakPoints[1]+this.breakPoints[0]-al)*ad/ae}};this.series_p2u=function(at){return at*ae/ad+al}}else{this.series_u2p=function(at){if(at>this.breakPoints[0]&&at<this.breakPoints[1]){at=this.breakPoints[0]}if(at>=this.breakPoints[1]){return(at-am)*ad/ae}else{return(at+this.breakPoints[1]-this.breakPoints[0]-am)*ad/ae}};this.series_p2u=function(at){return at*ae/ad+am}}}else{this.p2u=function(at){return(at-af)*ae/ad+al};this.u2p=function(at){return(at-al)*ad/ae+af};if(this.name=="xaxis"||this.name=="x2axis"){this.series_u2p=function(at){return(at-al)*ad/ae};this.series_p2u=function(at){return at*ae/ad+al}}else{this.series_u2p=function(at){return(at-am)*ad/ae};this.series_p2u=function(at){return at*ae/ad+am}}}if(this.show){if(this.name=="xaxis"||this.name=="x2axis"){for(var an=0;an<aq.length;an++){var ai=aq[an];if(ai.show&&ai.showLabel){var aa;if(ai.constructor==G.jqplot.CanvasAxisTickRenderer&&ai.angle){var ap=(this.name=="xaxis")?1:-1;switch(ai.labelPosition){case"auto":if(ap*ai.angle<0){aa=-ai.getWidth()+ai._textRenderer.height*Math.sin(-ai._textRenderer.angle)/2}else{aa=-ai._textRenderer.height*Math.sin(ai._textRenderer.angle)/2}break;case"end":aa=-ai.getWidth()+ai._textRenderer.height*Math.sin(-ai._textRenderer.angle)/2;break;case"start":aa=-ai._textRenderer.height*Math.sin(ai._textRenderer.angle)/2;break;case"middle":aa=-ai.getWidth()/2+ai._textRenderer.height*Math.sin(-ai._textRenderer.angle)/2;break;default:aa=-ai.getWidth()/2+ai._textRenderer.height*Math.sin(-ai._textRenderer.angle)/2;break}}else{aa=-ai.getWidth()/2}var ar=this.u2p(ai.value)+aa+"px";ai._elem.css("left",ar);ai.pack()}}if(aj){var ag=this._label._elem.outerWidth(true);this._label._elem.css("left",af+ad/2-ag/2+"px");if(this.name=="xaxis"){this._label._elem.css("bottom","0px")}else{this._label._elem.css("top","0px")}this._label.pack()}}else{for(var an=0;an<aq.length;an++){var ai=aq[an];if(ai.show&&ai.showLabel){var aa;if(ai.constructor==G.jqplot.CanvasAxisTickRenderer&&ai.angle){var ap=(this.name=="yaxis")?1:-1;switch(ai.labelPosition){case"auto":case"end":if(ap*ai.angle<0){aa=-ai._textRenderer.height*Math.cos(-ai._textRenderer.angle)/2}else{aa=-ai.getHeight()+ai._textRenderer.height*Math.cos(ai._textRenderer.angle)/2}break;case"start":if(ai.angle>0){aa=-ai._textRenderer.height*Math.cos(-ai._textRenderer.angle)/2}else{aa=-ai.getHeight()+ai._textRenderer.height*Math.cos(ai._textRenderer.angle)/2}break;case"middle":aa=-ai.getHeight()/2;break;default:aa=-ai.getHeight()/2;break}}else{aa=-ai.getHeight()/2}var ar=this.u2p(ai.value)+aa+"px";ai._elem.css("top",ar);ai.pack()}}if(aj){var ao=this._label._elem.outerHeight(true);this._label._elem.css("top",ah-ad/2-ao/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{this._label._elem.css("right","0px")}this._label.pack()}}}aq=null};function g(ab){var aa;ab=Math.abs(ab);if(ab>=10){aa="%d"}else{if(ab>1){if(ab===parseInt(ab)){aa="%d"}else{aa="%.1f"}}else{var ac=-Math.floor(Math.log(ab)/Math.LN10);aa="%."+ac+"f"}}return aa}var a=[0.1,0.2,0.3,0.4,0.5,0.8,1,2,3,4,5];var b=function(ab){var aa=a.indexOf(ab);if(aa>0){return a[aa-1]}else{return a[a.length-1]/100}};var h=function(ab){var aa=a.indexOf(ab);if(aa<a.length-1){return a[aa+1]}else{return a[0]*100}};function R(ab,ae){var ad=ab/(ae-1);var ac=Math.pow(10,Math.floor(Math.log(ad)/Math.LN10));var af=ad/ac;var aa;if(ac<1){if(af>5){aa=10*ac}else{if(af>2){aa=5*ac}else{if(af>1){aa=2*ac}else{aa=ac}}}}else{if(af>5){aa=10*ac}else{if(af>4){aa=5*ac}else{if(af>3){aa=4*ac}else{if(af>2){aa=3*ac}else{if(af>1){aa=2*ac}else{aa=ac}}}}}}return aa}function L(ab,aa){var ad=Math.floor(Math.log(ab)/Math.LN10);var af=Math.pow(10,ad);var ae=ab/af;var ac;ae=ae/aa;if(ae<=0.38){ac=0.1}else{if(ae<=1.6){ac=0.2}else{if(ae<=4){ac=0.5}else{if(ae<=8){ac=1}else{if(ae<=16){ac=2}else{ac=5}}}}}return ac*af}function s(ac,ab){var ae=Math.floor(Math.log(ac)/Math.LN10);var ag=Math.pow(10,ae);var af=ac/ag;var aa;var ad;af=af/ab;if(af<=0.38){ad=0.1}else{if(af<=1.6){ad=0.2}else{if(af<=4){ad=0.5}else{if(af<=8){ad=1}else{if(af<=16){ad=2}else{ad=5}}}}}aa=ad*ag;return[aa,ad,ag]}G.jqplot.LinearTickGenerator=function(af,ag,ac,ad){if(af===ag){ag=(ag)?0:1}ac=ac||1;if(ag<af){var ah=ag;ag=af;af=ah}var ab=[];var ai=L(ag-af,ac);if(ad==null){ab[0]=Math.floor(af/ai)*ai;ab[1]=Math.ceil(ag/ai)*ai;ab[2]=Math.round((ab[1]-ab[0])/ai+1);ab[3]=g(ai);ab[4]=ai}else{var ae=[];ae[0]=Math.floor(af/ai)*ai;ae[1]=Math.ceil(ag/ai)*ai;ae[2]=Math.round((ae[1]-ae[0])/ai+1);ae[3]=g(ai);ae[4]=ai;if(ae[2]===ad){ab=ae}else{var aa=R(ae[1]-ae[0],ad);ab[0]=ae[0];ab[2]=ad;ab[4]=aa;ab[3]=g(aa);ab[1]=ab[0]+(ab[2]-1)*ab[4]}}return ab};G.jqplot.LinearTickGenerator.bestLinearInterval=L;G.jqplot.LinearTickGenerator.bestInterval=R;G.jqplot.LinearTickGenerator.bestLinearComponents=s;G.jqplot.MarkerRenderer=function(aa){this.show=true;this.style="filledCircle";this.lineWidth=2;this.size=9;this.color="#666666";this.shadow=true;this.shadowAngle=45;this.shadowOffset=1;this.shadowDepth=3;this.shadowAlpha="0.07";this.shadowRenderer=new G.jqplot.ShadowRenderer();this.shapeRenderer=new G.jqplot.ShapeRenderer();G.extend(true,this,aa)};G.jqplot.MarkerRenderer.prototype.init=function(aa){G.extend(true,this,aa);var ac={angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,lineWidth:this.lineWidth,depth:this.shadowDepth,closePath:true};if(this.style.indexOf("filled")!=-1){ac.fill=true}if(this.style.indexOf("ircle")!=-1){ac.isarc=true;ac.closePath=false}this.shadowRenderer.init(ac);var ab={fill:false,isarc:false,strokeStyle:this.color,fillStyle:this.color,lineWidth:this.lineWidth,closePath:true};if(this.style.indexOf("filled")!=-1){ab.fill=true}if(this.style.indexOf("ircle")!=-1){ab.isarc=true;ab.closePath=false}this.shapeRenderer.init(ab)};G.jqplot.MarkerRenderer.prototype.drawDiamond=function(ac,ab,af,ae,ah){var aa=1.2;var ai=this.size/2/aa;var ag=this.size/2*aa;var ad=[[ac-ai,ab],[ac,ab+ag],[ac+ai,ab],[ac,ab-ag]];if(this.shadow){this.shadowRenderer.draw(af,ad)}this.shapeRenderer.draw(af,ad,ah)};G.jqplot.MarkerRenderer.prototype.drawPlus=function(ad,ac,ag,af,aj){var ab=1;var ak=this.size/2*ab;var ah=this.size/2*ab;var ai=[[ad,ac-ah],[ad,ac+ah]];var ae=[[ad+ak,ac],[ad-ak,ac]];var aa=G.extend(true,{},this.options,{closePath:false});if(this.shadow){this.shadowRenderer.draw(ag,ai,{closePath:false});this.shadowRenderer.draw(ag,ae,{closePath:false})}this.shapeRenderer.draw(ag,ai,aa);this.shapeRenderer.draw(ag,ae,aa)};G.jqplot.MarkerRenderer.prototype.drawX=function(ad,ac,ag,af,aj){var ab=1;var ak=this.size/2*ab;var ah=this.size/2*ab;var aa=G.extend(true,{},this.options,{closePath:false});var ai=[[ad-ak,ac-ah],[ad+ak,ac+ah]];var ae=[[ad-ak,ac+ah],[ad+ak,ac-ah]];if(this.shadow){this.shadowRenderer.draw(ag,ai,{closePath:false});this.shadowRenderer.draw(ag,ae,{closePath:false})}this.shapeRenderer.draw(ag,ai,aa);this.shapeRenderer.draw(ag,ae,aa)};G.jqplot.MarkerRenderer.prototype.drawDash=function(ac,ab,af,ae,ah){var aa=1;var ai=this.size/2*aa;var ag=this.size/2*aa;var ad=[[ac-ai,ab],[ac+ai,ab]];if(this.shadow){this.shadowRenderer.draw(af,ad)}this.shapeRenderer.draw(af,ad,ah)};G.jqplot.MarkerRenderer.prototype.drawLine=function(af,ae,aa,ad,ab){var ac=[af,ae];if(this.shadow){this.shadowRenderer.draw(aa,ac)}this.shapeRenderer.draw(aa,ac,ab)};G.jqplot.MarkerRenderer.prototype.drawSquare=function(ac,ab,af,ae,ah){var aa=1;var ai=this.size/2/aa;var ag=this.size/2*aa;var ad=[[ac-ai,ab-ag],[ac-ai,ab+ag],[ac+ai,ab+ag],[ac+ai,ab-ag]];if(this.shadow){this.shadowRenderer.draw(af,ad)}this.shapeRenderer.draw(af,ad,ah)};G.jqplot.MarkerRenderer.prototype.drawCircle=function(ab,ah,ad,ag,ae){var aa=this.size/2;var ac=2*Math.PI;var af=[ab,ah,aa,0,ac,true];if(this.shadow){this.shadowRenderer.draw(ad,af)}this.shapeRenderer.draw(ad,af,ae)};G.jqplot.MarkerRenderer.prototype.draw=function(aa,ad,ab,ac){ac=ac||{};if(ac.show==null||ac.show!=false){if(ac.color&&!ac.fillStyle){ac.fillStyle=ac.color}if(ac.color&&!ac.strokeStyle){ac.strokeStyle=ac.color}switch(this.style){case"diamond":this.drawDiamond(aa,ad,ab,false,ac);break;case"filledDiamond":this.drawDiamond(aa,ad,ab,true,ac);break;case"circle":this.drawCircle(aa,ad,ab,false,ac);break;case"filledCircle":this.drawCircle(aa,ad,ab,true,ac);break;case"square":this.drawSquare(aa,ad,ab,false,ac);break;case"filledSquare":this.drawSquare(aa,ad,ab,true,ac);break;case"x":this.drawX(aa,ad,ab,true,ac);break;case"plus":this.drawPlus(aa,ad,ab,true,ac);break;case"dash":this.drawDash(aa,ad,ab,true,ac);break;case"line":this.drawLine(aa,ad,ab,false,ac);break;default:this.drawDiamond(aa,ad,ab,false,ac);break}}};G.jqplot.ShadowRenderer=function(aa){this.angle=45;this.offset=1;this.alpha=0.07;this.lineWidth=1.5;this.lineJoin="miter";this.lineCap="round";this.closePath=false;this.fill=false;this.depth=3;this.strokeStyle="rgba(0,0,0,0.1)";this.isarc=false;G.extend(true,this,aa)};G.jqplot.ShadowRenderer.prototype.init=function(aa){G.extend(true,this,aa)};G.jqplot.ShadowRenderer.prototype.draw=function(an,al,ap){an.save();var aa=(ap!=null)?ap:{};var am=(aa.fill!=null)?aa.fill:this.fill;var ai=(aa.fillRect!=null)?aa.fillRect:this.fillRect;var ah=(aa.closePath!=null)?aa.closePath:this.closePath;var ae=(aa.offset!=null)?aa.offset:this.offset;var ac=(aa.alpha!=null)?aa.alpha:this.alpha;var ag=(aa.depth!=null)?aa.depth:this.depth;var ao=(aa.isarc!=null)?aa.isarc:this.isarc;var aj=(aa.linePattern!=null)?aa.linePattern:this.linePattern;an.lineWidth=(aa.lineWidth!=null)?aa.lineWidth:this.lineWidth;an.lineJoin=(aa.lineJoin!=null)?aa.lineJoin:this.lineJoin;an.lineCap=(aa.lineCap!=null)?aa.lineCap:this.lineCap;an.strokeStyle=aa.strokeStyle||this.strokeStyle||"rgba(0,0,0,"+ac+")";an.fillStyle=aa.fillStyle||this.fillStyle||"rgba(0,0,0,"+ac+")";for(var ad=0;ad<ag;ad++){var ak=G.jqplot.LinePattern(an,aj);an.translate(Math.cos(this.angle*Math.PI/180)*ae,Math.sin(this.angle*Math.PI/180)*ae);ak.beginPath();if(ao){an.arc(al[0],al[1],al[2],al[3],al[4],true)}else{if(ai){if(ai){an.fillRect(al[0],al[1],al[2],al[3])}}else{if(al&&al.length){var ab=true;for(var af=0;af<al.length;af++){if(al[af][0]!=null&&al[af][1]!=null){if(ab){ak.moveTo(al[af][0],al[af][1]);ab=false}else{ak.lineTo(al[af][0],al[af][1])}}else{ab=true}}}}}if(ah){ak.closePath()}if(am){an.fill()}else{an.stroke()}}an.restore()};G.jqplot.ShapeRenderer=function(aa){this.lineWidth=1.5;this.linePattern="solid";this.lineJoin="miter";this.lineCap="round";this.closePath=false;this.fill=false;this.isarc=false;this.fillRect=false;this.strokeRect=false;this.clearRect=false;this.strokeStyle="#999999";this.fillStyle="#999999";G.extend(true,this,aa)};G.jqplot.ShapeRenderer.prototype.init=function(aa){G.extend(true,this,aa)};G.jqplot.ShapeRenderer.prototype.draw=function(al,aj,an){al.save();var aa=(an!=null)?an:{};var ak=(aa.fill!=null)?aa.fill:this.fill;var af=(aa.closePath!=null)?aa.closePath:this.closePath;var ag=(aa.fillRect!=null)?aa.fillRect:this.fillRect;var ad=(aa.strokeRect!=null)?aa.strokeRect:this.strokeRect;var ab=(aa.clearRect!=null)?aa.clearRect:this.clearRect;var am=(aa.isarc!=null)?aa.isarc:this.isarc;var ah=(aa.linePattern!=null)?aa.linePattern:this.linePattern;var ai=G.jqplot.LinePattern(al,ah);al.lineWidth=aa.lineWidth||this.lineWidth;al.lineJoin=aa.lineJoin||this.lineJoin;al.lineCap=aa.lineCap||this.lineCap;al.strokeStyle=(aa.strokeStyle||aa.color)||this.strokeStyle;al.fillStyle=aa.fillStyle||this.fillStyle;al.beginPath();if(am){al.arc(aj[0],aj[1],aj[2],aj[3],aj[4],true);if(af){al.closePath()}if(ak){al.fill()}else{al.stroke()}al.restore();return}else{if(ab){al.clearRect(aj[0],aj[1],aj[2],aj[3]);al.restore();return}else{if(ag||ad){if(ag){al.fillRect(aj[0],aj[1],aj[2],aj[3])}if(ad){al.strokeRect(aj[0],aj[1],aj[2],aj[3]);al.restore();return}}else{if(aj&&aj.length){var ac=true;for(var ae=0;ae<aj.length;ae++){if(aj[ae][0]!=null&&aj[ae][1]!=null){if(ac){ai.moveTo(aj[ae][0],aj[ae][1]);ac=false}else{ai.lineTo(aj[ae][0],aj[ae][1])}}else{ac=true}}if(af){ai.closePath()}if(ak){al.fill()}else{al.stroke()}}}}}al.restore()};G.jqplot.TableLegendRenderer=function(){};G.jqplot.TableLegendRenderer.prototype.init=function(aa){G.extend(true,this,aa)};G.jqplot.TableLegendRenderer.prototype.addrow=function(aj,ad,aa,ah){var ae=(aa)?this.rowSpacing+"px":"0px";var ai;var ac;var ab;var ag;var af;ab=document.createElement("tr");ai=G(ab);ai.addClass("jqplot-table-legend");ab=null;if(ah){ai.prependTo(this._elem)}else{ai.appendTo(this._elem)}if(this.showSwatches){ac=G(document.createElement("td"));ac.addClass("jqplot-table-legend jqplot-table-legend-swatch");ac.css({textAlign:"center",paddingTop:ae});ag=G(document.createElement("div"));ag.addClass("jqplot-table-legend-swatch-outline");af=G(document.createElement("div"));af.addClass("jqplot-table-legend-swatch");af.css({backgroundColor:ad,borderColor:ad});ai.append(ac.append(ag.append(af)))}if(this.showLabels){ac=G(document.createElement("td"));ac.addClass("jqplot-table-legend jqplot-table-legend-label");ac.css("paddingTop",ae);ai.append(ac);if(this.escapeHtml){ac.text(aj)}else{ac.html(aj)}}ac=null;ag=null;af=null;ai=null;ab=null};G.jqplot.TableLegendRenderer.prototype.draw=function(){if(this._elem){this._elem.emptyForce();this._elem=null}if(this.show){var af=this._series;var ab=document.createElement("table");this._elem=G(ab);this._elem.addClass("jqplot-table-legend");var ak={position:"absolute"};if(this.background){ak.background=this.background}if(this.border){ak.border=this.border}if(this.fontSize){ak.fontSize=this.fontSize}if(this.fontFamily){ak.fontFamily=this.fontFamily}if(this.textColor){ak.textColor=this.textColor}if(this.marginTop!=null){ak.marginTop=this.marginTop}if(this.marginBottom!=null){ak.marginBottom=this.marginBottom}if(this.marginLeft!=null){ak.marginLeft=this.marginLeft}if(this.marginRight!=null){ak.marginRight=this.marginRight}var aa=false,ah=false,aj;for(var ag=0;ag<af.length;ag++){aj=af[ag];if(aj._stack||aj.renderer.constructor==G.jqplot.BezierCurveRenderer){ah=true}if(aj.show&&aj.showLabel){var ae=this.labels[ag]||aj.label.toString();if(ae){var ac=aj.color;if(ah&&ag<af.length-1){aa=true}else{if(ah&&ag==af.length-1){aa=false}}this.renderer.addrow.call(this,ae,ac,aa,ah);aa=true}for(var ad=0;ad<G.jqplot.addLegendRowHooks.length;ad++){var ai=G.jqplot.addLegendRowHooks[ad].call(this,aj);if(ai){this.renderer.addrow.call(this,ai.label,ai.color,aa);aa=true}}ae=null}}}return this._elem};G.jqplot.TableLegendRenderer.prototype.pack=function(ac){if(this.show){if(this.placement=="insideGrid"){switch(this.location){case"nw":var ab=ac.left;var aa=ac.top;this._elem.css("left",ab);this._elem.css("top",aa);break;case"n":var ab=(ac.left+(this._plotDimensions.width-ac.right))/2-this.getWidth()/2;var aa=ac.top;this._elem.css("left",ab);this._elem.css("top",aa);break;case"ne":var ab=ac.right;var aa=ac.top;this._elem.css({right:ab,top:aa});break;case"e":var ab=ac.right;var aa=(ac.top+(this._plotDimensions.height-ac.bottom))/2-this.getHeight()/2;this._elem.css({right:ab,top:aa});break;case"se":var ab=ac.right;var aa=ac.bottom;this._elem.css({right:ab,bottom:aa});break;case"s":var ab=(ac.left+(this._plotDimensions.width-ac.right))/2-this.getWidth()/2;var aa=ac.bottom;this._elem.css({left:ab,bottom:aa});break;case"sw":var ab=ac.left;var aa=ac.bottom;this._elem.css({left:ab,bottom:aa});break;case"w":var ab=ac.left;var aa=(ac.top+(this._plotDimensions.height-ac.bottom))/2-this.getHeight()/2;this._elem.css({left:ab,top:aa});break;default:var ab=ac.right;var aa=ac.bottom;this._elem.css({right:ab,bottom:aa});break}}else{if(this.placement=="outside"){switch(this.location){case"nw":var ab=this._plotDimensions.width-ac.left;var aa=ac.top;this._elem.css("right",ab);this._elem.css("top",aa);break;case"n":var ab=(ac.left+(this._plotDimensions.width-ac.right))/2-this.getWidth()/2;var aa=this._plotDimensions.height-ac.top;this._elem.css("left",ab);this._elem.css("bottom",aa);break;case"ne":var ab=this._plotDimensions.width-ac.right;var aa=ac.top;this._elem.css({left:ab,top:aa});break;case"e":var ab=this._plotDimensions.width-ac.right;var aa=(ac.top+(this._plotDimensions.height-ac.bottom))/2-this.getHeight()/2;this._elem.css({left:ab,top:aa});break;case"se":var ab=this._plotDimensions.width-ac.right;var aa=ac.bottom;this._elem.css({left:ab,bottom:aa});break;case"s":var ab=(ac.left+(this._plotDimensions.width-ac.right))/2-this.getWidth()/2;var aa=this._plotDimensions.height-ac.bottom;this._elem.css({left:ab,top:aa});break;case"sw":var ab=this._plotDimensions.width-ac.left;var aa=ac.bottom;this._elem.css({right:ab,bottom:aa});break;case"w":var ab=this._plotDimensions.width-ac.left;var aa=(ac.top+(this._plotDimensions.height-ac.bottom))/2-this.getHeight()/2;this._elem.css({right:ab,top:aa});break;default:var ab=ac.right;var aa=ac.bottom;this._elem.css({right:ab,bottom:aa});break}}else{switch(this.location){case"nw":this._elem.css({left:0,top:ac.top});break;case"n":var ab=(ac.left+(this._plotDimensions.width-ac.right))/2-this.getWidth()/2;this._elem.css({left:ab,top:ac.top});break;case"ne":this._elem.css({right:0,top:ac.top});break;case"e":var aa=(ac.top+(this._plotDimensions.height-ac.bottom))/2-this.getHeight()/2;this._elem.css({right:ac.right,top:aa});break;case"se":this._elem.css({right:ac.right,bottom:ac.bottom});break;case"s":var ab=(ac.left+(this._plotDimensions.width-ac.right))/2-this.getWidth()/2;this._elem.css({left:ab,bottom:ac.bottom});break;case"sw":this._elem.css({left:ac.left,bottom:ac.bottom});break;case"w":var aa=(ac.top+(this._plotDimensions.height-ac.bottom))/2-this.getHeight()/2;this._elem.css({left:ac.left,top:aa});break;default:this._elem.css({right:ac.right,bottom:ac.bottom});break}}}}};G.jqplot.ThemeEngine=function(){this.themes={};this.activeTheme=null};G.jqplot.ThemeEngine.prototype.init=function(){var ad=new G.jqplot.Theme({_name:"Default"});var ag,ab,af;for(ag in ad.target){if(ag=="textColor"){ad.target[ag]=this.target.css("color")}else{ad.target[ag]=this.target.css(ag)}}if(this.title.show&&this.title._elem){for(ag in ad.title){if(ag=="textColor"){ad.title[ag]=this.title._elem.css("color")}else{ad.title[ag]=this.title._elem.css(ag)}}}for(ag in ad.grid){ad.grid[ag]=this.grid[ag]}if(ad.grid.backgroundColor==null&&this.grid.background!=null){ad.grid.backgroundColor=this.grid.background}if(this.legend.show&&this.legend._elem){for(ag in ad.legend){if(ag=="textColor"){ad.legend[ag]=this.legend._elem.css("color")}else{ad.legend[ag]=this.legend._elem.css(ag)}}}var ac;for(ab=0;ab<this.series.length;ab++){ac=this.series[ab];if(ac.renderer.constructor==G.jqplot.LineRenderer){ad.series.push(new l())}else{if(ac.renderer.constructor==G.jqplot.BarRenderer){ad.series.push(new O())}else{if(ac.renderer.constructor==G.jqplot.PieRenderer){ad.series.push(new d())}else{if(ac.renderer.constructor==G.jqplot.DonutRenderer){ad.series.push(new B())}else{if(ac.renderer.constructor==G.jqplot.FunnelRenderer){ad.series.push(new T())}else{if(ac.renderer.constructor==G.jqplot.MeterGaugeRenderer){ad.series.push(new y())}else{ad.series.push({})}}}}}}for(ag in ad.series[ab]){ad.series[ab][ag]=ac[ag]}}var aa,ae;for(ag in this.axes){ae=this.axes[ag];aa=ad.axes[ag]=new K();aa.borderColor=ae.borderColor;aa.borderWidth=ae.borderWidth;if(ae._ticks&&ae._ticks[0]){for(af in aa.ticks){if(ae._ticks[0].hasOwnProperty(af)){aa.ticks[af]=ae._ticks[0][af]}else{if(ae._ticks[0]._elem){aa.ticks[af]=ae._ticks[0]._elem.css(af)}}}}if(ae._label&&ae._label.show){for(af in aa.label){if(ae._label[af]){aa.label[af]=ae._label[af]}else{if(ae._label._elem){if(af=="textColor"){aa.label[af]=ae._label._elem.css("color")}else{aa.label[af]=ae._label._elem.css(af)}}}}}}this.themeEngine._add(ad);this.themeEngine.activeTheme=this.themeEngine.themes[ad._name]};G.jqplot.ThemeEngine.prototype.get=function(aa){if(!aa){return this.activeTheme}else{return this.themes[aa]}};function J(ab,aa){return ab-aa}G.jqplot.ThemeEngine.prototype.getThemeNames=function(){var aa=[];for(var ab in this.themes){aa.push(ab)}return aa.sort(J)};G.jqplot.ThemeEngine.prototype.getThemes=function(){var ab=[];var aa=[];for(var ad in this.themes){ab.push(ad)}ab.sort(J);for(var ac=0;ac<ab.length;ac++){aa.push(this.themes[ab[ac]])}return aa};G.jqplot.ThemeEngine.prototype.activate=function(an,at){var aa=false;if(!at&&this.activeTheme&&this.activeTheme._name){at=this.activeTheme._name}if(!this.themes.hasOwnProperty(at)){throw new Error("No theme of that name")}else{var af=this.themes[at];this.activeTheme=af;var ar,al=false,ak=false;var ab=["xaxis","x2axis","yaxis","y2axis"];for(ao=0;ao<ab.length;ao++){var ag=ab[ao];if(af.axesStyles.borderColor!=null){an.axes[ag].borderColor=af.axesStyles.borderColor}if(af.axesStyles.borderWidth!=null){an.axes[ag].borderWidth=af.axesStyles.borderWidth}}for(var aq in an.axes){var ad=an.axes[aq];if(ad.show){var aj=af.axes[aq]||{};var ah=af.axesStyles;var ae=G.jqplot.extend(true,{},aj,ah);ar=(af.axesStyles.borderColor!=null)?af.axesStyles.borderColor:ae.borderColor;if(ae.borderColor!=null){ad.borderColor=ae.borderColor;aa=true}ar=(af.axesStyles.borderWidth!=null)?af.axesStyles.borderWidth:ae.borderWidth;if(ae.borderWidth!=null){ad.borderWidth=ae.borderWidth;aa=true}if(ad._ticks&&ad._ticks[0]){for(var ac in ae.ticks){ar=ae.ticks[ac];if(ar!=null){ad.tickOptions[ac]=ar;ad._ticks=[];aa=true}}}if(ad._label&&ad._label.show){for(var ac in ae.label){ar=ae.label[ac];if(ar!=null){ad.labelOptions[ac]=ar;aa=true}}}}}for(var am in af.grid){if(af.grid[am]!=null){an.grid[am]=af.grid[am]}}if(!aa){an.grid.draw()}if(an.legend.show){for(am in af.legend){if(af.legend[am]!=null){an.legend[am]=af.legend[am]}}}if(an.title.show){for(am in af.title){if(af.title[am]!=null){an.title[am]=af.title[am]}}}var ao;for(ao=0;ao<af.series.length;ao++){var ai={};var ap=false;for(am in af.series[ao]){ar=(af.seriesStyles[am]!=null)?af.seriesStyles[am]:af.series[ao][am];if(ar!=null){ai[am]=ar;if(am=="color"){an.series[ao].renderer.shapeRenderer.fillStyle=ar;an.series[ao].renderer.shapeRenderer.strokeStyle=ar;an.series[ao][am]=ar}else{if((am=="lineWidth")||(am=="linePattern")){an.series[ao].renderer.shapeRenderer[am]=ar;an.series[ao][am]=ar}else{if(am=="markerOptions"){Q(an.series[ao].markerOptions,ar);Q(an.series[ao].markerRenderer,ar)}else{an.series[ao][am]=ar}}}aa=true}}}if(aa){an.target.empty();an.draw()}for(am in af.target){if(af.target[am]!=null){an.target.css(am,af.target[am])}}}};G.jqplot.ThemeEngine.prototype._add=function(ab,aa){if(aa){ab._name=aa}if(!ab._name){ab._name=Date.parse(new Date())}if(!this.themes.hasOwnProperty(ab._name)){this.themes[ab._name]=ab}else{throw new Error("jqplot.ThemeEngine Error: Theme already in use")}};G.jqplot.ThemeEngine.prototype.remove=function(aa){if(aa=="Default"){return false}return delete this.themes[aa]};G.jqplot.ThemeEngine.prototype.newTheme=function(aa,ac){if(typeof(aa)=="object"){ac=ac||aa;aa=null}if(ac&&ac._name){aa=ac._name}else{aa=aa||Date.parse(new Date())}var ab=this.copy(this.themes.Default._name,aa);G.jqplot.extend(ab,ac);return ab};function w(ac){if(ac==null||typeof(ac)!="object"){return ac}var aa=new ac.constructor();for(var ab in ac){aa[ab]=w(ac[ab])}return aa}G.jqplot.clone=w;function Q(ac,ab){if(ab==null||typeof(ab)!="object"){return}for(var aa in ab){if(aa=="highlightColors"){ac[aa]=w(ab[aa])}if(ab[aa]!=null&&typeof(ab[aa])=="object"){if(!ac.hasOwnProperty(aa)){ac[aa]={}}Q(ac[aa],ab[aa])}else{ac[aa]=ab[aa]}}}G.jqplot.merge=Q;G.jqplot.extend=function(){var af=arguments[0]||{},ad=1,ae=arguments.length,aa=false,ac;if(typeof af==="boolean"){aa=af;af=arguments[1]||{};ad=2}if(typeof af!=="object"&&!toString.call(af)==="[object Function]"){af={}}for(;ad<ae;ad++){if((ac=arguments[ad])!=null){for(var ab in ac){var ag=af[ab],ah=ac[ab];if(af===ah){continue}if(aa&&ah&&typeof ah==="object"&&!ah.nodeType){af[ab]=G.jqplot.extend(aa,ag||(ah.length!=null?[]:{}),ah)}else{if(ah!==q){af[ab]=ah}}}}}return af};G.jqplot.ThemeEngine.prototype.rename=function(ab,aa){if(ab=="Default"||aa=="Default"){throw new Error("jqplot.ThemeEngine Error: Cannot rename from/to Default")}if(this.themes.hasOwnProperty(aa)){throw new Error("jqplot.ThemeEngine Error: New name already in use.")}else{if(this.themes.hasOwnProperty(ab)){var ac=this.copy(ab,aa);this.remove(ab);return ac}}throw new Error("jqplot.ThemeEngine Error: Old name or new name invalid")};G.jqplot.ThemeEngine.prototype.copy=function(aa,ac,ae){if(ac=="Default"){throw new Error("jqplot.ThemeEngine Error: Cannot copy over Default theme")}if(!this.themes.hasOwnProperty(aa)){var ab="jqplot.ThemeEngine Error: Source name invalid";throw new Error(ab)}if(this.themes.hasOwnProperty(ac)){var ab="jqplot.ThemeEngine Error: Target name invalid";throw new Error(ab)}else{var ad=w(this.themes[aa]);ad._name=ac;G.jqplot.extend(true,ad,ae);this._add(ad);return ad}};G.jqplot.Theme=function(aa,ab){if(typeof(aa)=="object"){ab=ab||aa;aa=null}aa=aa||Date.parse(new Date());this._name=aa;this.target={backgroundColor:null};this.legend={textColor:null,fontFamily:null,fontSize:null,border:null,background:null};this.title={textColor:null,fontFamily:null,fontSize:null,textAlign:null};this.seriesStyles={};this.series=[];this.grid={drawGridlines:null,gridLineColor:null,gridLineWidth:null,backgroundColor:null,borderColor:null,borderWidth:null,shadow:null};this.axesStyles={label:{},ticks:{}};this.axes={};if(typeof(ab)=="string"){this._name=ab}else{if(typeof(ab)=="object"){G.jqplot.extend(true,this,ab)}}};var K=function(){this.borderColor=null;this.borderWidth=null;this.ticks=new k();this.label=new p()};var k=function(){this.show=null;this.showGridline=null;this.showLabel=null;this.showMark=null;this.size=null;this.textColor=null;this.whiteSpace=null;this.fontSize=null;this.fontFamily=null};var p=function(){this.textColor=null;this.whiteSpace=null;this.fontSize=null;this.fontFamily=null;this.fontWeight=null};var l=function(){this.color=null;this.lineWidth=null;this.linePattern=null;this.shadow=null;this.fillColor=null;this.showMarker=null;this.markerOptions=new D()};var D=function(){this.show=null;this.style=null;this.lineWidth=null;this.size=null;this.color=null;this.shadow=null};var O=function(){this.color=null;this.seriesColors=null;this.lineWidth=null;this.shadow=null;this.barPadding=null;this.barMargin=null;this.barWidth=null;this.highlightColors=null};var d=function(){this.seriesColors=null;this.padding=null;this.sliceMargin=null;this.fill=null;this.shadow=null;this.startAngle=null;this.lineWidth=null;this.highlightColors=null};var B=function(){this.seriesColors=null;this.padding=null;this.sliceMargin=null;this.fill=null;this.shadow=null;this.startAngle=null;this.lineWidth=null;this.innerDiameter=null;this.thickness=null;this.ringMargin=null;this.highlightColors=null};var T=function(){this.color=null;this.lineWidth=null;this.shadow=null;this.padding=null;this.sectionMargin=null;this.seriesColors=null;this.highlightColors=null};var y=function(){this.padding=null;this.backgroundColor=null;this.ringColor=null;this.tickColor=null;this.ringWidth=null;this.intervalColors=null;this.intervalInnerRadius=null;this.intervalOuterRadius=null;this.hubRadius=null;this.needleThickness=null;this.needlePad=null};G.fn.jqplotChildText=function(){return G(this).contents().filter(function(){return this.nodeType==3}).text()};G.fn.jqplotGetComputedFontStyle=function(){var ad=window.getComputedStyle?window.getComputedStyle(this[0]):this[0].currentStyle;var ab=ad["font-style"]?["font-style","font-weight","font-size","font-family"]:["fontStyle","fontWeight","fontSize","fontFamily"];var ae=[];for(var ac=0;ac<ab.length;++ac){var aa=String(ad[ab[ac]]);if(aa&&aa!="normal"){ae.push(aa)}}return ae.join(" ")};G.fn.jqplotToImageCanvas=function(ac){ac=ac||{};var an=(ac.x_offset==null)?0:ac.x_offset;var ap=(ac.y_offset==null)?0:ac.y_offset;var ae=(ac.backgroundColor==null)?"rgb(255,255,255)":ac.backgroundColor;if(G(this).width()==0||G(this).height()==0){return null}if(!G.jqplot.support_canvas){return null}var ag=document.createElement("canvas");var at=G(this).outerHeight(true);var al=G(this).outerWidth(true);var af=G(this).offset();var ah=af.left;var aj=af.top;var am=0,ak=0;var aq=["jqplot-table-legend","jqplot-xaxis-tick","jqplot-x2axis-tick","jqplot-yaxis-tick","jqplot-y2axis-tick","jqplot-y3axis-tick","jqplot-y4axis-tick","jqplot-y5axis-tick","jqplot-y6axis-tick","jqplot-y7axis-tick","jqplot-y8axis-tick","jqplot-y9axis-tick","jqplot-xaxis-label","jqplot-x2axis-label","jqplot-yaxis-label","jqplot-y2axis-label","jqplot-y3axis-label","jqplot-y4axis-label","jqplot-y5axis-label","jqplot-y6axis-label","jqplot-y7axis-label","jqplot-y8axis-label","jqplot-y9axis-label"];var ai,aa,ab,au;for(var ar in aq){G(this).find("."+aq[ar]).each(function(){ai=G(this).offset().top-aj;aa=G(this).offset().left-ah;au=aa+G(this).outerWidth(true)+am;ab=ai+G(this).outerHeight(true)+ak;if(aa<-am){al=al-am-aa;am=-aa}if(ai<-ak){at=at-ak-ai;ak=-ai}if(au>al){al=au}if(ab>at){at=ab}})}ag.width=al+Number(an);ag.height=at+Number(ap);var ad=ag.getContext("2d");ad.save();ad.fillStyle=ae;ad.fillRect(0,0,ag.width,ag.height);ad.restore();ad.translate(am,ak);ad.textAlign="left";ad.textBaseline="top";function av(ax){var ay=parseInt(G(ax).css("line-height"));if(isNaN(ay)){ay=parseInt(G(ax).css("font-size"))*1.2}return ay}function aw(ay,ax,aL,az,aH,aA){var aJ=av(ay);var aD=G(ay).innerWidth();var aE=G(ay).innerHeight();var aG=aL.split(/\s+/);var aK=aG.length;var aI="";var aF=[];var aN=aH;var aM=az;for(var aC=0;aC<aK;aC++){aI+=aG[aC];if(ax.measureText(aI).width>aD){aF.push(aC);aI=""}}if(aF.length===0){if(G(ay).css("textAlign")==="center"){aM=az+(aA-ax.measureText(aI).width)/2-am}ax.fillText(aL,aM,aH)}else{aI=aG.slice(0,aF[0]).join(" ");if(G(ay).css("textAlign")==="center"){aM=az+(aA-ax.measureText(aI).width)/2-am}ax.fillText(aI,aM,aN);aN+=aJ;for(var aC=1,aB=aF.length;aC<aB;aC++){aI=aG.slice(aF[aC-1],aF[aC]).join(" ");if(G(ay).css("textAlign")==="center"){aM=az+(aA-ax.measureText(aI).width)/2-am}ax.fillText(aI,aM,aN);aN+=aJ}aI=aG.slice(aF[aC-1],aG.length).join(" ");if(G(ay).css("textAlign")==="center"){aM=az+(aA-ax.measureText(aI).width)/2-am}ax.fillText(aI,aM,aN)}}function ao(az,aC,ax){var aG=az.tagName.toLowerCase();var ay=G(az).position();var aD=window.getComputedStyle?window.getComputedStyle(az):az.currentStyle;var aB=aC+ay.left+parseInt(aD.marginLeft)+parseInt(aD.borderLeftWidth)+parseInt(aD.paddingLeft);var aE=ax+ay.top+parseInt(aD.marginTop)+parseInt(aD.borderTopWidth)+parseInt(aD.paddingTop);var aF=ag.width;if((aG=="div"||aG=="span")&&!G(az).hasClass("jqplot-highlighter-tooltip")){G(az).children().each(function(){ao(this,aB,aE)});var aH=G(az).jqplotChildText();if(aH){ad.font=G(az).jqplotGetComputedFontStyle();ad.fillStyle=G(az).css("color");aw(az,ad,aH,aB,aE,aF)}}else{if(aG==="table"&&G(az).hasClass("jqplot-table-legend")){ad.strokeStyle=G(az).css("border-top-color");ad.fillStyle=G(az).css("background-color");ad.fillRect(aB,aE,G(az).innerWidth(),G(az).innerHeight());if(parseInt(G(az).css("border-top-width"))>0){ad.strokeRect(aB,aE,G(az).innerWidth(),G(az).innerHeight())}G(az).find("div.jqplot-table-legend-swatch-outline").each(function(){var aN=G(this);ad.strokeStyle=aN.css("border-top-color");var aJ=aB+aN.position().left;var aK=aE+aN.position().top;ad.strokeRect(aJ,aK,aN.innerWidth(),aN.innerHeight());aJ+=parseInt(aN.css("padding-left"));aK+=parseInt(aN.css("padding-top"));var aM=aN.innerHeight()-2*parseInt(aN.css("padding-top"));var aI=aN.innerWidth()-2*parseInt(aN.css("padding-left"));var aL=aN.children("div.jqplot-table-legend-swatch");ad.fillStyle=aL.css("background-color");ad.fillRect(aJ,aK,aI,aM)});G(az).find("td.jqplot-table-legend-label").each(function(){var aK=G(this);var aI=aB+aK.position().left;var aJ=aE+aK.position().top+parseInt(aK.css("padding-top"));ad.font=aK.jqplotGetComputedFontStyle();ad.fillStyle=aK.css("color");ad.fillText(aK.text(),aI,aJ)});var aA=null}else{if(aG=="canvas"){ad.drawImage(az,aB,aE)}}}}G(this).children().each(function(){ao(this,an,ap)});return ag};G.fn.jqplotToImageStr=function(ab){var aa=G(this).jqplotToImageCanvas(ab);if(aa){return aa.toDataURL("image/png")}else{return null}};G.fn.jqplotToImageElem=function(aa){var ab=document.createElement("img");var ac=G(this).jqplotToImageStr(aa);ab.src=ac;return ab};G.fn.jqplotToImageElemStr=function(aa){var ab="<img src="+G(this).jqplotToImageStr(aa)+" />";return ab};G.fn.jqplotSaveImage=function(){var aa=G(this).jqplotToImageStr({});if(aa){window.location.href=aa.replace("image/png","image/octet-stream")}};G.fn.jqplotViewImage=function(){var ab=G(this).jqplotToImageElemStr({});var ac=G(this).jqplotToImageStr({});if(ab){var aa=window.open("");aa.document.open("image/png");aa.document.write(ab);aa.document.close();aa=null}};var Z=function(){this.syntax=Z.config.syntax;this._type="jsDate";this.utcOffset=new Date().getTimezoneOffset*60000;this.proxy=new Date();this.options={};this.locale=Z.regional.getLocale();this.formatString="";this.defaultCentury=Z.config.defaultCentury;switch(arguments.length){case 0:break;case 1:if(i(arguments[0])=="[object Object]"&&arguments[0]._type!="jsDate"){var ac=this.options=arguments[0];this.syntax=ac.syntax||this.syntax;this.defaultCentury=ac.defaultCentury||this.defaultCentury;this.proxy=Z.createDate(ac.date)}else{this.proxy=Z.createDate(arguments[0])}break;default:var aa=[];for(var ab=0;ab<arguments.length;ab++){aa.push(arguments[ab])}this.proxy=new Date(this.utcOffset);this.proxy.setFullYear.apply(this.proxy,aa.slice(0,3));if(aa.slice(3).length){this.proxy.setHours.apply(this.proxy,aa.slice(3))}break}};Z.config={defaultLocale:"en",syntax:"perl",defaultCentury:1900};Z.prototype.add=function(ac,ab){var aa=z[ab]||z.day;if(typeof aa=="number"){this.proxy.setTime(this.proxy.getTime()+(aa*ac))}else{aa.add(this,ac)}return this};Z.prototype.clone=function(){return new Z(this.proxy.getTime())};Z.prototype.diff=function(ab,ae,aa){ab=new Z(ab);if(ab===null){return null}var ac=z[ae]||z.day;if(typeof ac=="number"){var ad=(this.proxy.getTime()-ab.proxy.getTime())/ac}else{var ad=ac.diff(this.proxy,ab.proxy)}return(aa?ad:Math[ad>0?"floor":"ceil"](ad))};Z.prototype.getAbbrDayName=function(){return Z.regional[this.locale]["dayNamesShort"][this.proxy.getDay()]};Z.prototype.getAbbrMonthName=function(){return Z.regional[this.locale]["monthNamesShort"][this.proxy.getMonth()]};Z.prototype.getAMPM=function(){return this.proxy.getHours()>=12?"PM":"AM"};Z.prototype.getAmPm=function(){return this.proxy.getHours()>=12?"pm":"am"};Z.prototype.getCentury=function(){return parseInt(this.proxy.getFullYear()/100,10)};Z.prototype.getDate=function(){return this.proxy.getDate()};Z.prototype.getDay=function(){return this.proxy.getDay()};Z.prototype.getDayOfWeek=function(){var aa=this.proxy.getDay();return aa===0?7:aa};Z.prototype.getDayOfYear=function(){var ab=this.proxy;var aa=ab-new Date(""+ab.getFullYear()+"/1/1 GMT");aa+=ab.getTimezoneOffset()*60000;ab=null;return parseInt(aa/60000/60/24,10)+1};Z.prototype.getDayName=function(){return Z.regional[this.locale]["dayNames"][this.proxy.getDay()]};Z.prototype.getFullWeekOfYear=function(){var ad=this.proxy;var aa=this.getDayOfYear();var ac=6-ad.getDay();var ab=parseInt((aa+ac)/7,10);return ab};Z.prototype.getFullYear=function(){return this.proxy.getFullYear()};Z.prototype.getGmtOffset=function(){var aa=this.proxy.getTimezoneOffset()/60;var ab=aa<0?"+":"-";aa=Math.abs(aa);return ab+I(Math.floor(aa),2)+":"+I((aa%1)*60,2)};Z.prototype.getHours=function(){return this.proxy.getHours()};Z.prototype.getHours12=function(){var aa=this.proxy.getHours();return aa>12?aa-12:(aa==0?12:aa)};Z.prototype.getIsoWeek=function(){var ad=this.proxy;var ac=ad.getWeekOfYear();var aa=(new Date(""+ad.getFullYear()+"/1/1")).getDay();var ab=ac+(aa>4||aa<=1?0:1);if(ab==53&&(new Date(""+ad.getFullYear()+"/12/31")).getDay()<4){ab=1}else{if(ab===0){ad=new Z(new Date(""+(ad.getFullYear()-1)+"/12/31"));ab=ad.getIsoWeek()}}ad=null;return ab};Z.prototype.getMilliseconds=function(){return this.proxy.getMilliseconds()};Z.prototype.getMinutes=function(){return this.proxy.getMinutes()};Z.prototype.getMonth=function(){return this.proxy.getMonth()};Z.prototype.getMonthName=function(){return Z.regional[this.locale]["monthNames"][this.proxy.getMonth()]};Z.prototype.getMonthNumber=function(){return this.proxy.getMonth()+1};Z.prototype.getSeconds=function(){return this.proxy.getSeconds()};Z.prototype.getShortYear=function(){return this.proxy.getYear()%100};Z.prototype.getTime=function(){return this.proxy.getTime()};Z.prototype.getTimezoneAbbr=function(){return this.proxy.toString().replace(/^.*\(([^)]+)\)$/,"$1")};Z.prototype.getTimezoneName=function(){var aa=/(?:\((.+)\)$| ([A-Z]{3}) )/.exec(this.toString());return aa[1]||aa[2]||"GMT"+this.getGmtOffset()};Z.prototype.getTimezoneOffset=function(){return this.proxy.getTimezoneOffset()};Z.prototype.getWeekOfYear=function(){var aa=this.getDayOfYear();var ac=7-this.getDayOfWeek();var ab=parseInt((aa+ac)/7,10);return ab};Z.prototype.getUnix=function(){return Math.round(this.proxy.getTime()/1000,0)};Z.prototype.getYear=function(){return this.proxy.getYear()};Z.prototype.next=function(aa){aa=aa||"day";return this.clone().add(1,aa)};Z.prototype.set=function(){switch(arguments.length){case 0:this.proxy=new Date();break;case 1:if(i(arguments[0])=="[object Object]"&&arguments[0]._type!="jsDate"){var ac=this.options=arguments[0];this.syntax=ac.syntax||this.syntax;this.defaultCentury=ac.defaultCentury||this.defaultCentury;this.proxy=Z.createDate(ac.date)}else{this.proxy=Z.createDate(arguments[0])}break;default:var aa=[];for(var ab=0;ab<arguments.length;ab++){aa.push(arguments[ab])}this.proxy=new Date(this.utcOffset);this.proxy.setFullYear.apply(this.proxy,aa.slice(0,3));if(aa.slice(3).length){this.proxy.setHours.apply(this.proxy,aa.slice(3))}break}};Z.prototype.setDate=function(aa){return this.proxy.setDate(aa)};Z.prototype.setFullYear=function(){return this.proxy.setFullYear.apply(this.proxy,arguments)};Z.prototype.setHours=function(){return this.proxy.setHours.apply(this.proxy,arguments)};Z.prototype.setMilliseconds=function(aa){return this.proxy.setMilliseconds(aa)};Z.prototype.setMinutes=function(){return this.proxy.setMinutes.apply(this.proxy,arguments)};Z.prototype.setMonth=function(){return this.proxy.setMonth.apply(this.proxy,arguments)};Z.prototype.setSeconds=function(){return this.proxy.setSeconds.apply(this.proxy,arguments)};Z.prototype.setTime=function(aa){return this.proxy.setTime(aa)};Z.prototype.setYear=function(){return this.proxy.setYear.apply(this.proxy,arguments)};Z.prototype.strftime=function(aa){aa=aa||this.formatString||Z.regional[this.locale]["formatString"];return Z.strftime(this,aa,this.syntax)};Z.prototype.toString=function(){return this.proxy.toString()};Z.prototype.toYmdInt=function(){return(this.proxy.getFullYear()*10000)+(this.getMonthNumber()*100)+this.proxy.getDate()};Z.regional={en:{monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],formatString:"%Y-%m-%d %H:%M:%S"},fr:{monthNames:["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"],monthNamesShort:["Jan","Fév","Mar","Avr","Mai","Jun","Jul","Aoû","Sep","Oct","Nov","Déc"],dayNames:["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"],dayNamesShort:["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"],formatString:"%Y-%m-%d %H:%M:%S"},de:{monthNames:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],monthNamesShort:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],dayNames:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],dayNamesShort:["So","Mo","Di","Mi","Do","Fr","Sa"],formatString:"%Y-%m-%d %H:%M:%S"},es:{monthNames:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],monthNamesShort:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],dayNames:["Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&aacute;bado"],dayNamesShort:["Dom","Lun","Mar","Mi&eacute;","Juv","Vie","S&aacute;b"],formatString:"%Y-%m-%d %H:%M:%S"},ru:{monthNames:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],monthNamesShort:["Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],dayNames:["воскресенье","понедельник","вторник","среда","четверг","пятница","суббота"],dayNamesShort:["вск","пнд","втр","срд","чтв","птн","сбт"],formatString:"%Y-%m-%d %H:%M:%S"},ar:{monthNames:["كانون الثاني","شباط","آذار","نيسان","آذار","حزيران","تموز","آب","أيلول","تشرين الأول","تشرين الثاني","كانون الأول"],monthNamesShort:["1","2","3","4","5","6","7","8","9","10","11","12"],dayNames:["السبت","الأحد","الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة"],dayNamesShort:["سبت","أحد","اثنين","ثلاثاء","أربعاء","خميس","جمعة"],formatString:"%Y-%m-%d %H:%M:%S"},pt:{monthNames:["Janeiro","Fevereiro","Mar&ccedil;o","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],monthNamesShort:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],dayNames:["Domingo","Segunda-feira","Ter&ccedil;a-feira","Quarta-feira","Quinta-feira","Sexta-feira","S&aacute;bado"],dayNamesShort:["Dom","Seg","Ter","Qua","Qui","Sex","S&aacute;b"],formatString:"%Y-%m-%d %H:%M:%S"},"pt-BR":{monthNames:["Janeiro","Fevereiro","Mar&ccedil;o","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],monthNamesShort:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],dayNames:["Domingo","Segunda-feira","Ter&ccedil;a-feira","Quarta-feira","Quinta-feira","Sexta-feira","S&aacute;bado"],dayNamesShort:["Dom","Seg","Ter","Qua","Qui","Sex","S&aacute;b"],formatString:"%Y-%m-%d %H:%M:%S"}};Z.regional["en-US"]=Z.regional["en-GB"]=Z.regional.en;Z.regional.getLocale=function(){var aa=Z.config.defaultLocale;if(document&&document.getElementsByTagName("html")&&document.getElementsByTagName("html")[0].lang){aa=document.getElementsByTagName("html")[0].lang;if(!Z.regional.hasOwnProperty(aa)){aa=Z.config.defaultLocale}}return aa};var x=24*60*60*1000;var I=function(aa,ad){aa=String(aa);var ab=ad-aa.length;var ac=String(Math.pow(10,ab)).slice(1);return ac.concat(aa)};var z={millisecond:1,second:1000,minute:60*1000,hour:60*60*1000,day:x,week:7*x,month:{add:function(ac,aa){z.year.add(ac,Math[aa>0?"floor":"ceil"](aa/12));var ab=ac.getMonth()+(aa%12);if(ab==12){ab=0;ac.setYear(ac.getFullYear()+1)}else{if(ab==-1){ab=11;ac.setYear(ac.getFullYear()-1)}}ac.setMonth(ab)},diff:function(ae,ac){var aa=ae.getFullYear()-ac.getFullYear();var ab=ae.getMonth()-ac.getMonth()+(aa*12);var ad=ae.getDate()-ac.getDate();return ab+(ad/30)}},year:{add:function(ab,aa){ab.setYear(ab.getFullYear()+Math[aa>0?"floor":"ceil"](aa))},diff:function(ab,aa){return z.month.diff(ab,aa)/12}}};for(var S in z){if(S.substring(S.length-1)!="s"){z[S+"s"]=z[S]}}var C=function(ae,ad,ab){if(Z.formats[ab]["shortcuts"][ad]){return Z.strftime(ae,Z.formats[ab]["shortcuts"][ad],ab)}else{var aa=(Z.formats[ab]["codes"][ad]||"").split(".");var ac=ae["get"+aa[0]]?ae["get"+aa[0]]():"";if(aa[1]){ac=I(ac,aa[1])}return ac}};Z.strftime=function(ag,ad,ac,ah){var ab="perl";var af=Z.regional.getLocale();if(ac&&Z.formats.hasOwnProperty(ac)){ab=ac}else{if(ac&&Z.regional.hasOwnProperty(ac)){af=ac}}if(ah&&Z.formats.hasOwnProperty(ah)){ab=ah}else{if(ah&&Z.regional.hasOwnProperty(ah)){af=ah}}if(i(ag)!="[object Object]"||ag._type!="jsDate"){ag=new Z(ag);ag.locale=af}if(!ad){ad=ag.formatString||Z.regional[af]["formatString"]}var aa=ad||"%Y-%m-%d",ai="",ae;while(aa.length>0){if(ae=aa.match(Z.formats[ab].codes.matcher)){ai+=aa.slice(0,ae.index);ai+=(ae[1]||"")+C(ag,ae[2],ab);aa=aa.slice(ae.index+ae[0].length)}else{ai+=aa;aa=""}}return ai};Z.formats={ISO:"%Y-%m-%dT%H:%M:%S.%N%G",SQL:"%Y-%m-%d %H:%M:%S"};Z.formats.perl={codes:{matcher:/()%(#?(%|[a-z]))/i,Y:"FullYear",y:"ShortYear.2",m:"MonthNumber.2","#m":"MonthNumber",B:"MonthName",b:"AbbrMonthName",d:"Date.2","#d":"Date",e:"Date",A:"DayName",a:"AbbrDayName",w:"Day",H:"Hours.2","#H":"Hours",I:"Hours12.2","#I":"Hours12",p:"AMPM",M:"Minutes.2","#M":"Minutes",S:"Seconds.2","#S":"Seconds",s:"Unix",N:"Milliseconds.3","#N":"Milliseconds",O:"TimezoneOffset",Z:"TimezoneName",G:"GmtOffset"},shortcuts:{F:"%Y-%m-%d",T:"%H:%M:%S",X:"%H:%M:%S",x:"%m/%d/%y",D:"%m/%d/%y","#c":"%a %b %e %H:%M:%S %Y",v:"%e-%b-%Y",R:"%H:%M",r:"%I:%M:%S %p",t:"\t",n:"\n","%":"%"}};Z.formats.php={codes:{matcher:/()%((%|[a-z]))/i,a:"AbbrDayName",A:"DayName",d:"Date.2",e:"Date",j:"DayOfYear.3",u:"DayOfWeek",w:"Day",U:"FullWeekOfYear.2",V:"IsoWeek.2",W:"WeekOfYear.2",b:"AbbrMonthName",B:"MonthName",m:"MonthNumber.2",h:"AbbrMonthName",C:"Century.2",y:"ShortYear.2",Y:"FullYear",H:"Hours.2",I:"Hours12.2",l:"Hours12",p:"AMPM",P:"AmPm",M:"Minutes.2",S:"Seconds.2",s:"Unix",O:"TimezoneOffset",z:"GmtOffset",Z:"TimezoneAbbr"},shortcuts:{D:"%m/%d/%y",F:"%Y-%m-%d",T:"%H:%M:%S",X:"%H:%M:%S",x:"%m/%d/%y",R:"%H:%M",r:"%I:%M:%S %p",t:"\t",n:"\n","%":"%"}};Z.createDate=function(ac){if(ac==null){return new Date()}if(ac instanceof Date){return ac}if(typeof ac=="number"){return new Date(ac)}var ah=String(ac).replace(/^\s*(.+)\s*$/g,"$1");ah=ah.replace(/^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,4})/,"$1/$2/$3");ah=ah.replace(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{4})/i,"$1 $2 $3");var ag=ah.match(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{2})\D*/i);if(ag&&ag.length>3){var al=parseFloat(ag[3]);var af=Z.config.defaultCentury+al;af=String(af);ah=ah.replace(/^(3[01]|[0-2]?\d)[-\/]([a-z]{3,})[-\/](\d{2})\D*/i,ag[1]+" "+ag[2]+" "+af)}ag=ah.match(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})[^0-9]/);function ak(ap,ao){var av=parseFloat(ao[1]);var au=parseFloat(ao[2]);var at=parseFloat(ao[3]);var ar=Z.config.defaultCentury;var an,am,aw,aq;if(av>31){am=at;aw=au;an=ar+av}else{am=au;aw=av;an=ar+at}aq=aw+"/"+am+"/"+an;return ap.replace(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})/,aq)}if(ag&&ag.length>3){ah=ak(ah,ag)}var ag=ah.match(/^([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{1,2})$/);if(ag&&ag.length>3){ah=ak(ah,ag)}var ae=0;var ab=Z.matchers.length;var aj,aa,ai=ah,ad;while(ae<ab){aa=Date.parse(ai);if(!isNaN(aa)){return new Date(aa)}aj=Z.matchers[ae];if(typeof aj=="function"){ad=aj.call(Z,ai);if(ad instanceof Date){return ad}}else{ai=ah.replace(aj[0],aj[1])}ae++}return NaN};Z.daysInMonth=function(aa,ab){if(ab==2){return new Date(aa,1,29).getDate()==29?29:28}return[q,31,q,31,30,31,30,31,31,30,31,30,31][ab]};Z.matchers=[[/(3[01]|[0-2]\d)\s*\.\s*(1[0-2]|0\d)\s*\.\s*([1-9]\d{3})/,"$2/$1/$3"],[/([1-9]\d{3})\s*-\s*(1[0-2]|0\d)\s*-\s*(3[01]|[0-2]\d)/,"$2/$3/$1"],function(ad){var ab=ad.match(/^(?:(.+)\s+)?([012]?\d)(?:\s*\:\s*(\d\d))?(?:\s*\:\s*(\d\d(\.\d*)?))?\s*(am|pm)?\s*$/i);if(ab){if(ab[1]){var ac=this.createDate(ab[1]);if(isNaN(ac)){return}}else{var ac=new Date();ac.setMilliseconds(0)}var aa=parseFloat(ab[2]);if(ab[6]){aa=ab[6].toLowerCase()=="am"?(aa==12?0:aa):(aa==12?12:aa+12)}ac.setHours(aa,parseInt(ab[3]||0,10),parseInt(ab[4]||0,10),((parseFloat(ab[5]||0))||0)*1000);return ac}else{return ad}},function(ad){var ab=ad.match(/^(?:(.+))[T|\s+]([012]\d)(?:\:(\d\d))(?:\:(\d\d))(?:\.\d+)([\+\-]\d\d\:\d\d)$/i);if(ab){if(ab[1]){var ac=this.createDate(ab[1]);if(isNaN(ac)){return}}else{var ac=new Date();ac.setMilliseconds(0)}var aa=parseFloat(ab[2]);ac.setHours(aa,parseInt(ab[3],10),parseInt(ab[4],10),parseFloat(ab[5])*1000);return ac}else{return ad}},function(ae){var ac=ae.match(/^([0-3]?\d)\s*[-\/.\s]{1}\s*([a-zA-Z]{3,9})\s*[-\/.\s]{1}\s*([0-3]?\d)$/);if(ac){var ad=new Date();var af=Z.config.defaultCentury;var ah=parseFloat(ac[1]);var ag=parseFloat(ac[3]);var ab,aa,ai;if(ah>31){aa=ag;ab=af+ah}else{aa=ah;ab=af+ag}var ai=V(ac[2],Z.regional[Z.regional.getLocale()]["monthNamesShort"]);if(ai==-1){ai=V(ac[2],Z.regional[Z.regional.getLocale()]["monthNames"])}ad.setFullYear(ab,ai,aa);ad.setHours(0,0,0,0);return ad}else{return ae}}];function V(ac,ad){if(ad.indexOf){return ad.indexOf(ac)}for(var aa=0,ab=ad.length;aa<ab;aa++){if(ad[aa]===ac){return aa}}return -1}function i(aa){if(aa===null){return"[object Null]"}return Object.prototype.toString.call(aa)}G.jsDate=Z;G.jqplot.sprintf=function(){function ag(am,ai,aj,al){var ak=(am.length>=ai)?"":Array(1+ai-am.length>>>0).join(aj);return al?am+ak:ak+am}function ad(ak){var aj=new String(ak);for(var ai=10;ai>0;ai--){if(aj==(aj=aj.replace(/^(\d+)(\d{3})/,"$1"+G.jqplot.sprintf.thousandsSeparator+"$2"))){break}}return aj}function ac(an,am,ap,ak,al,aj){var ao=ak-an.length;if(ao>0){var ai=" ";if(aj){ai="&nbsp;"}if(ap||!al){an=ag(an,ak,ai,ap)}else{an=an.slice(0,am.length)+ag("",ao,"0",true)+an.slice(am.length)}}return an}function ah(aq,aj,ao,ak,ai,an,ap,am){var al=aq>>>0;ao=ao&&al&&{"2":"0b","8":"0","16":"0x"}[aj]||"";aq=ao+ag(al.toString(aj),an||0,"0",false);return ac(aq,ao,ak,ai,ap,am)}function aa(am,an,ak,ai,al,aj){if(ai!=null){am=am.slice(0,ai)}return ac(am,"",an,ak,al,aj)}var ab=arguments,ae=0,af=ab[ae++];return af.replace(G.jqplot.sprintf.regex,function(aE,ap,aq,au,aG,aB,an){if(aE=="%%"){return"%"}var av=false,ar="",at=false,aD=false,ao=false,am=false;for(var aA=0;aq&&aA<aq.length;aA++){switch(aq.charAt(aA)){case" ":ar=" ";break;case"+":ar="+";break;case"-":av=true;break;case"0":at=true;break;case"#":aD=true;break;case"&":ao=true;break;case"'":am=true;break}}if(!au){au=0}else{if(au=="*"){au=+ab[ae++]}else{if(au.charAt(0)=="*"){au=+ab[au.slice(1,-1)]}else{au=+au}}}if(au<0){au=-au;av=true}if(!isFinite(au)){throw new Error("$.jqplot.sprintf: (minimum-)width must be finite")}if(!aB){aB="fFeE".indexOf(an)>-1?6:(an=="d")?0:void (0)}else{if(aB=="*"){aB=+ab[ae++]}else{if(aB.charAt(0)=="*"){aB=+ab[aB.slice(1,-1)]}else{aB=+aB}}}var ax=ap?ab[ap.slice(0,-1)]:ab[ae++];switch(an){case"s":if(ax==null){return""}return aa(String(ax),av,au,aB,at,ao);case"c":return aa(String.fromCharCode(+ax),av,au,aB,at,ao);case"b":return ah(ax,2,aD,av,au,aB,at,ao);case"o":return ah(ax,8,aD,av,au,aB,at,ao);case"x":return ah(ax,16,aD,av,au,aB,at,ao);case"X":return ah(ax,16,aD,av,au,aB,at,ao).toUpperCase();case"u":return ah(ax,10,aD,av,au,aB,at,ao);case"i":var ak=parseInt(+ax,10);if(isNaN(ak)){return""}var az=ak<0?"-":ar;var aC=am?ad(String(Math.abs(ak))):String(Math.abs(ak));ax=az+ag(aC,aB,"0",false);return ac(ax,az,av,au,at,ao);case"d":var ak=Math.round(+ax);if(isNaN(ak)){return""}var az=ak<0?"-":ar;var aC=am?ad(String(Math.abs(ak))):String(Math.abs(ak));ax=az+ag(aC,aB,"0",false);return ac(ax,az,av,au,at,ao);case"e":case"E":case"f":case"F":case"g":case"G":var ak=+ax;if(isNaN(ak)){return""}var az=ak<0?"-":ar;var al=["toExponential","toFixed","toPrecision"]["efg".indexOf(an.toLowerCase())];var aF=["toString","toUpperCase"]["eEfFgG".indexOf(an)%2];var aC=Math.abs(ak)[al](aB);aC=am?ad(aC):aC;ax=az+aC;return ac(ax,az,av,au,at,ao)[aF]();case"p":case"P":var ak=+ax;if(isNaN(ak)){return""}var az=ak<0?"-":ar;var aw=String(Number(Math.abs(ak)).toExponential()).split(/e|E/);var aj=(aw[0].indexOf(".")!=-1)?aw[0].length-1:aw[0].length;var ay=(aw[1]<0)?-aw[1]-1:0;if(Math.abs(ak)<1){if(aj+ay<=aB){ax=az+Math.abs(ak).toPrecision(aj)}else{if(aj<=aB-1){ax=az+Math.abs(ak).toExponential(aj-1)}else{ax=az+Math.abs(ak).toExponential(aB-1)}}}else{var ai=(aj<=aB)?aj:aB;ax=az+Math.abs(ak).toPrecision(ai)}var aF=["toString","toUpperCase"]["pP".indexOf(an)%2];return ac(ax,az,av,au,at,ao)[aF]();case"n":return"";default:return aE}})};G.jqplot.sprintf.thousandsSeparator=",";G.jqplot.sprintf.regex=/%%|%(\d+\$)?([-+#0&\' ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([nAscboxXuidfegpEGP])/g;G.jqplot.getSignificantFigures=function(ae){var ag=String(Number(Math.abs(ae)).toExponential()).split(/e|E/);var af=(ag[0].indexOf(".")!=-1)?ag[0].length-1:ag[0].length;var ab=(ag[1]<0)?-ag[1]-1:0;var aa=parseInt(ag[1]);var ac=(aa+1>0)?aa+1:0;var ad=(af<=ac)?0:af-aa-1;return{significantDigits:af,digitsLeft:ac,digitsRight:ad,zeros:ab,exponent:aa}};G.jqplot.getPrecision=function(ab){var aa=G.jqplot.getSignificantFigures(ab);var ac=aa[1]-1-parseInt(aa[0][1]);return ac}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.js
deleted file mode 100644
index 11e6d06..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.js
+++ /dev/null
@@ -1,9046 +0,0 @@
-/*!
- * jQuery JavaScript Library v1.6.4
- * http://jquery.com/
- *
- * Copyright 2011, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2011, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Mon Sep 12 18:54:48 2011 -0400
- */
-(function( window, undefined ) {
-
-// Use the correct document accordingly with window argument (sandbox)
-var document = window.document,
-	navigator = window.navigator,
-	location = window.location;
-var jQuery = (function() {
-
-// Define a local copy of jQuery
-var jQuery = function( selector, context ) {
-		// The jQuery object is actually just the init constructor 'enhanced'
-		return new jQuery.fn.init( selector, context, rootjQuery );
-	},
-
-	// Map over jQuery in case of overwrite
-	_jQuery = window.jQuery,
-
-	// Map over the $ in case of overwrite
-	_$ = window.$,
-
-	// A central reference to the root jQuery(document)
-	rootjQuery,
-
-	// A simple way to check for HTML strings or ID strings
-	// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
-	quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
-
-	// Check if a string has a non-whitespace character in it
-	rnotwhite = /\S/,
-
-	// Used for trimming whitespace
-	trimLeft = /^\s+/,
-	trimRight = /\s+$/,
-
-	// Check for digits
-	rdigit = /\d/,
-
-	// Match a standalone tag
-	rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
-
-	// JSON RegExp
-	rvalidchars = /^[\],:{}\s]*$/,
-	rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
-	rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
-	rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
-
-	// Useragent RegExp
-	rwebkit = /(webkit)[ \/]([\w.]+)/,
-	ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
-	rmsie = /(msie) ([\w.]+)/,
-	rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
-
-	// Matches dashed string for camelizing
-	rdashAlpha = /-([a-z]|[0-9])/ig,
-	rmsPrefix = /^-ms-/,
-
-	// Used by jQuery.camelCase as callback to replace()
-	fcamelCase = function( all, letter ) {
-		return ( letter + "" ).toUpperCase();
-	},
-
-	// Keep a UserAgent string for use with jQuery.browser
-	userAgent = navigator.userAgent,
-
-	// For matching the engine and version of the browser
-	browserMatch,
-
-	// The deferred used on DOM ready
-	readyList,
-
-	// The ready event handler
-	DOMContentLoaded,
-
-	// Save a reference to some core methods
-	toString = Object.prototype.toString,
-	hasOwn = Object.prototype.hasOwnProperty,
-	push = Array.prototype.push,
-	slice = Array.prototype.slice,
-	trim = String.prototype.trim,
-	indexOf = Array.prototype.indexOf,
-
-	// [[Class]] -> type pairs
-	class2type = {};
-
-jQuery.fn = jQuery.prototype = {
-	constructor: jQuery,
-	init: function( selector, context, rootjQuery ) {
-		var match, elem, ret, doc;
-
-		// Handle $(""), $(null), or $(undefined)
-		if ( !selector ) {
-			return this;
-		}
-
-		// Handle $(DOMElement)
-		if ( selector.nodeType ) {
-			this.context = this[0] = selector;
-			this.length = 1;
-			return this;
-		}
-
-		// The body element only exists once, optimize finding it
-		if ( selector === "body" && !context && document.body ) {
-			this.context = document;
-			this[0] = document.body;
-			this.selector = selector;
-			this.length = 1;
-			return this;
-		}
-
-		// Handle HTML strings
-		if ( typeof selector === "string" ) {
-			// Are we dealing with HTML string or an ID?
-			if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
-				// Assume that strings that start and end with <> are HTML and skip the regex check
-				match = [ null, selector, null ];
-
-			} else {
-				match = quickExpr.exec( selector );
-			}
-
-			// Verify a match, and that no context was specified for #id
-			if ( match && (match[1] || !context) ) {
-
-				// HANDLE: $(html) -> $(array)
-				if ( match[1] ) {
-					context = context instanceof jQuery ? context[0] : context;
-					doc = (context ? context.ownerDocument || context : document);
-
-					// If a single string is passed in and it's a single tag
-					// just do a createElement and skip the rest
-					ret = rsingleTag.exec( selector );
-
-					if ( ret ) {
-						if ( jQuery.isPlainObject( context ) ) {
-							selector = [ document.createElement( ret[1] ) ];
-							jQuery.fn.attr.call( selector, context, true );
-
-						} else {
-							selector = [ doc.createElement( ret[1] ) ];
-						}
-
-					} else {
-						ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
-						selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
-					}
-
-					return jQuery.merge( this, selector );
-
-				// HANDLE: $("#id")
-				} else {
-					elem = document.getElementById( match[2] );
-
-					// Check parentNode to catch when Blackberry 4.6 returns
-					// nodes that are no longer in the document #6963
-					if ( elem && elem.parentNode ) {
-						// Handle the case where IE and Opera return items
-						// by name instead of ID
-						if ( elem.id !== match[2] ) {
-							return rootjQuery.find( selector );
-						}
-
-						// Otherwise, we inject the element directly into the jQuery object
-						this.length = 1;
-						this[0] = elem;
-					}
-
-					this.context = document;
-					this.selector = selector;
-					return this;
-				}
-
-			// HANDLE: $(expr, $(...))
-			} else if ( !context || context.jquery ) {
-				return (context || rootjQuery).find( selector );
-
-			// HANDLE: $(expr, context)
-			// (which is just equivalent to: $(context).find(expr)
-			} else {
-				return this.constructor( context ).find( selector );
-			}
-
-		// HANDLE: $(function)
-		// Shortcut for document ready
-		} else if ( jQuery.isFunction( selector ) ) {
-			return rootjQuery.ready( selector );
-		}
-
-		if (selector.selector !== undefined) {
-			this.selector = selector.selector;
-			this.context = selector.context;
-		}
-
-		return jQuery.makeArray( selector, this );
-	},
-
-	// Start with an empty selector
-	selector: "",
-
-	// The current version of jQuery being used
-	jquery: "1.6.4",
-
-	// The default length of a jQuery object is 0
-	length: 0,
-
-	// The number of elements contained in the matched element set
-	size: function() {
-		return this.length;
-	},
-
-	toArray: function() {
-		return slice.call( this, 0 );
-	},
-
-	// Get the Nth element in the matched element set OR
-	// Get the whole matched element set as a clean array
-	get: function( num ) {
-		return num == null ?
-
-			// Return a 'clean' array
-			this.toArray() :
-
-			// Return just the object
-			( num < 0 ? this[ this.length + num ] : this[ num ] );
-	},
-
-	// Take an array of elements and push it onto the stack
-	// (returning the new matched element set)
-	pushStack: function( elems, name, selector ) {
-		// Build a new jQuery matched element set
-		var ret = this.constructor();
-
-		if ( jQuery.isArray( elems ) ) {
-			push.apply( ret, elems );
-
-		} else {
-			jQuery.merge( ret, elems );
-		}
-
-		// Add the old object onto the stack (as a reference)
-		ret.prevObject = this;
-
-		ret.context = this.context;
-
-		if ( name === "find" ) {
-			ret.selector = this.selector + (this.selector ? " " : "") + selector;
-		} else if ( name ) {
-			ret.selector = this.selector + "." + name + "(" + selector + ")";
-		}
-
-		// Return the newly-formed element set
-		return ret;
-	},
-
-	// Execute a callback for every element in the matched set.
-	// (You can seed the arguments with an array of args, but this is
-	// only used internally.)
-	each: function( callback, args ) {
-		return jQuery.each( this, callback, args );
-	},
-
-	ready: function( fn ) {
-		// Attach the listeners
-		jQuery.bindReady();
-
-		// Add the callback
-		readyList.done( fn );
-
-		return this;
-	},
-
-	eq: function( i ) {
-		return i === -1 ?
-			this.slice( i ) :
-			this.slice( i, +i + 1 );
-	},
-
-	first: function() {
-		return this.eq( 0 );
-	},
-
-	last: function() {
-		return this.eq( -1 );
-	},
-
-	slice: function() {
-		return this.pushStack( slice.apply( this, arguments ),
-			"slice", slice.call(arguments).join(",") );
-	},
-
-	map: function( callback ) {
-		return this.pushStack( jQuery.map(this, function( elem, i ) {
-			return callback.call( elem, i, elem );
-		}));
-	},
-
-	end: function() {
-		return this.prevObject || this.constructor(null);
-	},
-
-	// For internal use only.
-	// Behaves like an Array's method, not like a jQuery method.
-	push: push,
-	sort: [].sort,
-	splice: [].splice
-};
-
-// Give the init function the jQuery prototype for later instantiation
-jQuery.fn.init.prototype = jQuery.fn;
-
-jQuery.extend = jQuery.fn.extend = function() {
-	var options, name, src, copy, copyIsArray, clone,
-		target = arguments[0] || {},
-		i = 1,
-		length = arguments.length,
-		deep = false;
-
-	// Handle a deep copy situation
-	if ( typeof target === "boolean" ) {
-		deep = target;
-		target = arguments[1] || {};
-		// skip the boolean and the target
-		i = 2;
-	}
-
-	// Handle case when target is a string or something (possible in deep copy)
-	if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
-		target = {};
-	}
-
-	// extend jQuery itself if only one argument is passed
-	if ( length === i ) {
-		target = this;
-		--i;
-	}
-
-	for ( ; i < length; i++ ) {
-		// Only deal with non-null/undefined values
-		if ( (options = arguments[ i ]) != null ) {
-			// Extend the base object
-			for ( name in options ) {
-				src = target[ name ];
-				copy = options[ name ];
-
-				// Prevent never-ending loop
-				if ( target === copy ) {
-					continue;
-				}
-
-				// Recurse if we're merging plain objects or arrays
-				if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
-					if ( copyIsArray ) {
-						copyIsArray = false;
-						clone = src && jQuery.isArray(src) ? src : [];
-
-					} else {
-						clone = src && jQuery.isPlainObject(src) ? src : {};
-					}
-
-					// Never move original objects, clone them
-					target[ name ] = jQuery.extend( deep, clone, copy );
-
-				// Don't bring in undefined values
-				} else if ( copy !== undefined ) {
-					target[ name ] = copy;
-				}
-			}
-		}
-	}
-
-	// Return the modified object
-	return target;
-};
-
-jQuery.extend({
-	noConflict: function( deep ) {
-		if ( window.$ === jQuery ) {
-			window.$ = _$;
-		}
-
-		if ( deep && window.jQuery === jQuery ) {
-			window.jQuery = _jQuery;
-		}
-
-		return jQuery;
-	},
-
-	// Is the DOM ready to be used? Set to true once it occurs.
-	isReady: false,
-
-	// A counter to track how many items to wait for before
-	// the ready event fires. See #6781
-	readyWait: 1,
-
-	// Hold (or release) the ready event
-	holdReady: function( hold ) {
-		if ( hold ) {
-			jQuery.readyWait++;
-		} else {
-			jQuery.ready( true );
-		}
-	},
-
-	// Handle when the DOM is ready
-	ready: function( wait ) {
-		// Either a released hold or an DOMready/load event and not yet ready
-		if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
-			// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
-			if ( !document.body ) {
-				return setTimeout( jQuery.ready, 1 );
-			}
-
-			// Remember that the DOM is ready
-			jQuery.isReady = true;
-
-			// If a normal DOM Ready event fired, decrement, and wait if need be
-			if ( wait !== true && --jQuery.readyWait > 0 ) {
-				return;
-			}
-
-			// If there are functions bound, to execute
-			readyList.resolveWith( document, [ jQuery ] );
-
-			// Trigger any bound ready events
-			if ( jQuery.fn.trigger ) {
-				jQuery( document ).trigger( "ready" ).unbind( "ready" );
-			}
-		}
-	},
-
-	bindReady: function() {
-		if ( readyList ) {
-			return;
-		}
-
-		readyList = jQuery._Deferred();
-
-		// Catch cases where $(document).ready() is called after the
-		// browser event has already occurred.
-		if ( document.readyState === "complete" ) {
-			// Handle it asynchronously to allow scripts the opportunity to delay ready
-			return setTimeout( jQuery.ready, 1 );
-		}
-
-		// Mozilla, Opera and webkit nightlies currently support this event
-		if ( document.addEventListener ) {
-			// Use the handy event callback
-			document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
-
-			// A fallback to window.onload, that will always work
-			window.addEventListener( "load", jQuery.ready, false );
-
-		// If IE event model is used
-		} else if ( document.attachEvent ) {
-			// ensure firing before onload,
-			// maybe late but safe also for iframes
-			document.attachEvent( "onreadystatechange", DOMContentLoaded );
-
-			// A fallback to window.onload, that will always work
-			window.attachEvent( "onload", jQuery.ready );
-
-			// If IE and not a frame
-			// continually check to see if the document is ready
-			var toplevel = false;
-
-			try {
-				toplevel = window.frameElement == null;
-			} catch(e) {}
-
-			if ( document.documentElement.doScroll && toplevel ) {
-				doScrollCheck();
-			}
-		}
-	},
-
-	// See test/unit/core.js for details concerning isFunction.
-	// Since version 1.3, DOM methods and functions like alert
-	// aren't supported. They return false on IE (#2968).
-	isFunction: function( obj ) {
-		return jQuery.type(obj) === "function";
-	},
-
-	isArray: Array.isArray || function( obj ) {
-		return jQuery.type(obj) === "array";
-	},
-
-	// A crude way of determining if an object is a window
-	isWindow: function( obj ) {
-		return obj && typeof obj === "object" && "setInterval" in obj;
-	},
-
-	isNaN: function( obj ) {
-		return obj == null || !rdigit.test( obj ) || isNaN( obj );
-	},
-
-	type: function( obj ) {
-		return obj == null ?
-			String( obj ) :
-			class2type[ toString.call(obj) ] || "object";
-	},
-
-	isPlainObject: function( obj ) {
-		// Must be an Object.
-		// Because of IE, we also have to check the presence of the constructor property.
-		// Make sure that DOM nodes and window objects don't pass through, as well
-		if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
-			return false;
-		}
-
-		try {
-			// Not own constructor property must be Object
-			if ( obj.constructor &&
-				!hasOwn.call(obj, "constructor") &&
-				!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
-				return false;
-			}
-		} catch ( e ) {
-			// IE8,9 Will throw exceptions on certain host objects #9897
-			return false;
-		}
-
-		// Own properties are enumerated firstly, so to speed up,
-		// if last one is own, then all properties are own.
-
-		var key;
-		for ( key in obj ) {}
-
-		return key === undefined || hasOwn.call( obj, key );
-	},
-
-	isEmptyObject: function( obj ) {
-		for ( var name in obj ) {
-			return false;
-		}
-		return true;
-	},
-
-	error: function( msg ) {
-		throw msg;
-	},
-
-	parseJSON: function( data ) {
-		if ( typeof data !== "string" || !data ) {
-			return null;
-		}
-
-		// Make sure leading/trailing whitespace is removed (IE can't handle it)
-		data = jQuery.trim( data );
-
-		// Attempt to parse using the native JSON parser first
-		if ( window.JSON && window.JSON.parse ) {
-			return window.JSON.parse( data );
-		}
-
-		// Make sure the incoming data is actual JSON
-		// Logic borrowed from http://json.org/json2.js
-		if ( rvalidchars.test( data.replace( rvalidescape, "@" )
-			.replace( rvalidtokens, "]" )
-			.replace( rvalidbraces, "")) ) {
-
-			return (new Function( "return " + data ))();
-
-		}
-		jQuery.error( "Invalid JSON: " + data );
-	},
-
-	// Cross-browser xml parsing
-	parseXML: function( data ) {
-		var xml, tmp;
-		try {
-			if ( window.DOMParser ) { // Standard
-				tmp = new DOMParser();
-				xml = tmp.parseFromString( data , "text/xml" );
-			} else { // IE
-				xml = new ActiveXObject( "Microsoft.XMLDOM" );
-				xml.async = "false";
-				xml.loadXML( data );
-			}
-		} catch( e ) {
-			xml = undefined;
-		}
-		if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
-			jQuery.error( "Invalid XML: " + data );
-		}
-		return xml;
-	},
-
-	noop: function() {},
-
-	// Evaluates a script in a global context
-	// Workarounds based on findings by Jim Driscoll
-	// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
-	globalEval: function( data ) {
-		if ( data && rnotwhite.test( data ) ) {
-			// We use execScript on Internet Explorer
-			// We use an anonymous function so that context is window
-			// rather than jQuery in Firefox
-			( window.execScript || function( data ) {
-				window[ "eval" ].call( window, data );
-			} )( data );
-		}
-	},
-
-	// Convert dashed to camelCase; used by the css and data modules
-	// Microsoft forgot to hump their vendor prefix (#9572)
-	camelCase: function( string ) {
-		return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
-	},
-
-	nodeName: function( elem, name ) {
-		return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
-	},
-
-	// args is for internal usage only
-	each: function( object, callback, args ) {
-		var name, i = 0,
-			length = object.length,
-			isObj = length === undefined || jQuery.isFunction( object );
-
-		if ( args ) {
-			if ( isObj ) {
-				for ( name in object ) {
-					if ( callback.apply( object[ name ], args ) === false ) {
-						break;
-					}
-				}
-			} else {
-				for ( ; i < length; ) {
-					if ( callback.apply( object[ i++ ], args ) === false ) {
-						break;
-					}
-				}
-			}
-
-		// A special, fast, case for the most common use of each
-		} else {
-			if ( isObj ) {
-				for ( name in object ) {
-					if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
-						break;
-					}
-				}
-			} else {
-				for ( ; i < length; ) {
-					if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
-						break;
-					}
-				}
-			}
-		}
-
-		return object;
-	},
-
-	// Use native String.trim function wherever possible
-	trim: trim ?
-		function( text ) {
-			return text == null ?
-				"" :
-				trim.call( text );
-		} :
-
-		// Otherwise use our own trimming functionality
-		function( text ) {
-			return text == null ?
-				"" :
-				text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
-		},
-
-	// results is for internal usage only
-	makeArray: function( array, results ) {
-		var ret = results || [];
-
-		if ( array != null ) {
-			// The window, strings (and functions) also have 'length'
-			// The extra typeof function check is to prevent crashes
-			// in Safari 2 (See: #3039)
-			// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
-			var type = jQuery.type( array );
-
-			if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
-				push.call( ret, array );
-			} else {
-				jQuery.merge( ret, array );
-			}
-		}
-
-		return ret;
-	},
-
-	inArray: function( elem, array ) {
-		if ( !array ) {
-			return -1;
-		}
-
-		if ( indexOf ) {
-			return indexOf.call( array, elem );
-		}
-
-		for ( var i = 0, length = array.length; i < length; i++ ) {
-			if ( array[ i ] === elem ) {
-				return i;
-			}
-		}
-
-		return -1;
-	},
-
-	merge: function( first, second ) {
-		var i = first.length,
-			j = 0;
-
-		if ( typeof second.length === "number" ) {
-			for ( var l = second.length; j < l; j++ ) {
-				first[ i++ ] = second[ j ];
-			}
-
-		} else {
-			while ( second[j] !== undefined ) {
-				first[ i++ ] = second[ j++ ];
-			}
-		}
-
-		first.length = i;
-
-		return first;
-	},
-
-	grep: function( elems, callback, inv ) {
-		var ret = [], retVal;
-		inv = !!inv;
-
-		// Go through the array, only saving the items
-		// that pass the validator function
-		for ( var i = 0, length = elems.length; i < length; i++ ) {
-			retVal = !!callback( elems[ i ], i );
-			if ( inv !== retVal ) {
-				ret.push( elems[ i ] );
-			}
-		}
-
-		return ret;
-	},
-
-	// arg is for internal usage only
-	map: function( elems, callback, arg ) {
-		var value, key, ret = [],
-			i = 0,
-			length = elems.length,
-			// jquery objects are treated as arrays
-			isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
-
-		// Go through the array, translating each of the items to their
-		if ( isArray ) {
-			for ( ; i < length; i++ ) {
-				value = callback( elems[ i ], i, arg );
-
-				if ( value != null ) {
-					ret[ ret.length ] = value;
-				}
-			}
-
-		// Go through every key on the object,
-		} else {
-			for ( key in elems ) {
-				value = callback( elems[ key ], key, arg );
-
-				if ( value != null ) {
-					ret[ ret.length ] = value;
-				}
-			}
-		}
-
-		// Flatten any nested arrays
-		return ret.concat.apply( [], ret );
-	},
-
-	// A global GUID counter for objects
-	guid: 1,
-
-	// Bind a function to a context, optionally partially applying any
-	// arguments.
-	proxy: function( fn, context ) {
-		if ( typeof context === "string" ) {
-			var tmp = fn[ context ];
-			context = fn;
-			fn = tmp;
-		}
-
-		// Quick check to determine if target is callable, in the spec
-		// this throws a TypeError, but we will just return undefined.
-		if ( !jQuery.isFunction( fn ) ) {
-			return undefined;
-		}
-
-		// Simulated bind
-		var args = slice.call( arguments, 2 ),
-			proxy = function() {
-				return fn.apply( context, args.concat( slice.call( arguments ) ) );
-			};
-
-		// Set the guid of unique handler to the same of original handler, so it can be removed
-		proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
-
-		return proxy;
-	},
-
-	// Mutifunctional method to get and set values to a collection
-	// The value/s can optionally be executed if it's a function
-	access: function( elems, key, value, exec, fn, pass ) {
-		var length = elems.length;
-
-		// Setting many attributes
-		if ( typeof key === "object" ) {
-			for ( var k in key ) {
-				jQuery.access( elems, k, key[k], exec, fn, value );
-			}
-			return elems;
-		}
-
-		// Setting one attribute
-		if ( value !== undefined ) {
-			// Optionally, function values get executed if exec is true
-			exec = !pass && exec && jQuery.isFunction(value);
-
-			for ( var i = 0; i < length; i++ ) {
-				fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
-			}
-
-			return elems;
-		}
-
-		// Getting an attribute
-		return length ? fn( elems[0], key ) : undefined;
-	},
-
-	now: function() {
-		return (new Date()).getTime();
-	},
-
-	// Use of jQuery.browser is frowned upon.
-	// More details: http://docs.jquery.com/Utilities/jQuery.browser
-	uaMatch: function( ua ) {
-		ua = ua.toLowerCase();
-
-		var match = rwebkit.exec( ua ) ||
-			ropera.exec( ua ) ||
-			rmsie.exec( ua ) ||
-			ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
-			[];
-
-		return { browser: match[1] || "", version: match[2] || "0" };
-	},
-
-	sub: function() {
-		function jQuerySub( selector, context ) {
-			return new jQuerySub.fn.init( selector, context );
-		}
-		jQuery.extend( true, jQuerySub, this );
-		jQuerySub.superclass = this;
-		jQuerySub.fn = jQuerySub.prototype = this();
-		jQuerySub.fn.constructor = jQuerySub;
-		jQuerySub.sub = this.sub;
-		jQuerySub.fn.init = function init( selector, context ) {
-			if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
-				context = jQuerySub( context );
-			}
-
-			return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
-		};
-		jQuerySub.fn.init.prototype = jQuerySub.fn;
-		var rootjQuerySub = jQuerySub(document);
-		return jQuerySub;
-	},
-
-	browser: {}
-});
-
-// Populate the class2type map
-jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
-	class2type[ "[object " + name + "]" ] = name.toLowerCase();
-});
-
-browserMatch = jQuery.uaMatch( userAgent );
-if ( browserMatch.browser ) {
-	jQuery.browser[ browserMatch.browser ] = true;
-	jQuery.browser.version = browserMatch.version;
-}
-
-// Deprecated, use jQuery.browser.webkit instead
-if ( jQuery.browser.webkit ) {
-	jQuery.browser.safari = true;
-}
-
-// IE doesn't match non-breaking spaces with \s
-if ( rnotwhite.test( "\xA0" ) ) {
-	trimLeft = /^[\s\xA0]+/;
-	trimRight = /[\s\xA0]+$/;
-}
-
-// All jQuery objects should point back to these
-rootjQuery = jQuery(document);
-
-// Cleanup functions for the document ready method
-if ( document.addEventListener ) {
-	DOMContentLoaded = function() {
-		document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
-		jQuery.ready();
-	};
-
-} else if ( document.attachEvent ) {
-	DOMContentLoaded = function() {
-		// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
-		if ( document.readyState === "complete" ) {
-			document.detachEvent( "onreadystatechange", DOMContentLoaded );
-			jQuery.ready();
-		}
-	};
-}
-
-// The DOM ready check for Internet Explorer
-function doScrollCheck() {
-	if ( jQuery.isReady ) {
-		return;
-	}
-
-	try {
-		// If IE is used, use the trick by Diego Perini
-		// http://javascript.nwbox.com/IEContentLoaded/
-		document.documentElement.doScroll("left");
-	} catch(e) {
-		setTimeout( doScrollCheck, 1 );
-		return;
-	}
-
-	// and execute any waiting functions
-	jQuery.ready();
-}
-
-return jQuery;
-
-})();
-
-
-var // Promise methods
-	promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
-	// Static reference to slice
-	sliceDeferred = [].slice;
-
-jQuery.extend({
-	// Create a simple deferred (one callbacks list)
-	_Deferred: function() {
-		var // callbacks list
-			callbacks = [],
-			// stored [ context , args ]
-			fired,
-			// to avoid firing when already doing so
-			firing,
-			// flag to know if the deferred has been cancelled
-			cancelled,
-			// the deferred itself
-			deferred  = {
-
-				// done( f1, f2, ...)
-				done: function() {
-					if ( !cancelled ) {
-						var args = arguments,
-							i,
-							length,
-							elem,
-							type,
-							_fired;
-						if ( fired ) {
-							_fired = fired;
-							fired = 0;
-						}
-						for ( i = 0, length = args.length; i < length; i++ ) {
-							elem = args[ i ];
-							type = jQuery.type( elem );
-							if ( type === "array" ) {
-								deferred.done.apply( deferred, elem );
-							} else if ( type === "function" ) {
-								callbacks.push( elem );
-							}
-						}
-						if ( _fired ) {
-							deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
-						}
-					}
-					return this;
-				},
-
-				// resolve with given context and args
-				resolveWith: function( context, args ) {
-					if ( !cancelled && !fired && !firing ) {
-						// make sure args are available (#8421)
-						args = args || [];
-						firing = 1;
-						try {
-							while( callbacks[ 0 ] ) {
-								callbacks.shift().apply( context, args );
-							}
-						}
-						finally {
-							fired = [ context, args ];
-							firing = 0;
-						}
-					}
-					return this;
-				},
-
-				// resolve with this as context and given arguments
-				resolve: function() {
-					deferred.resolveWith( this, arguments );
-					return this;
-				},
-
-				// Has this deferred been resolved?
-				isResolved: function() {
-					return !!( firing || fired );
-				},
-
-				// Cancel
-				cancel: function() {
-					cancelled = 1;
-					callbacks = [];
-					return this;
-				}
-			};
-
-		return deferred;
-	},
-
-	// Full fledged deferred (two callbacks list)
-	Deferred: function( func ) {
-		var deferred = jQuery._Deferred(),
-			failDeferred = jQuery._Deferred(),
-			promise;
-		// Add errorDeferred methods, then and promise
-		jQuery.extend( deferred, {
-			then: function( doneCallbacks, failCallbacks ) {
-				deferred.done( doneCallbacks ).fail( failCallbacks );
-				return this;
-			},
-			always: function() {
-				return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
-			},
-			fail: failDeferred.done,
-			rejectWith: failDeferred.resolveWith,
-			reject: failDeferred.resolve,
-			isRejected: failDeferred.isResolved,
-			pipe: function( fnDone, fnFail ) {
-				return jQuery.Deferred(function( newDefer ) {
-					jQuery.each( {
-						done: [ fnDone, "resolve" ],
-						fail: [ fnFail, "reject" ]
-					}, function( handler, data ) {
-						var fn = data[ 0 ],
-							action = data[ 1 ],
-							returned;
-						if ( jQuery.isFunction( fn ) ) {
-							deferred[ handler ](function() {
-								returned = fn.apply( this, arguments );
-								if ( returned && jQuery.isFunction( returned.promise ) ) {
-									returned.promise().then( newDefer.resolve, newDefer.reject );
-								} else {
-									newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
-								}
-							});
-						} else {
-							deferred[ handler ]( newDefer[ action ] );
-						}
-					});
-				}).promise();
-			},
-			// Get a promise for this deferred
-			// If obj is provided, the promise aspect is added to the object
-			promise: function( obj ) {
-				if ( obj == null ) {
-					if ( promise ) {
-						return promise;
-					}
-					promise = obj = {};
-				}
-				var i = promiseMethods.length;
-				while( i-- ) {
-					obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
-				}
-				return obj;
-			}
-		});
-		// Make sure only one callback list will be used
-		deferred.done( failDeferred.cancel ).fail( deferred.cancel );
-		// Unexpose cancel
-		delete deferred.cancel;
-		// Call given func if any
-		if ( func ) {
-			func.call( deferred, deferred );
-		}
-		return deferred;
-	},
-
-	// Deferred helper
-	when: function( firstParam ) {
-		var args = arguments,
-			i = 0,
-			length = args.length,
-			count = length,
-			deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
-				firstParam :
-				jQuery.Deferred();
-		function resolveFunc( i ) {
-			return function( value ) {
-				args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
-				if ( !( --count ) ) {
-					// Strange bug in FF4:
-					// Values changed onto the arguments object sometimes end up as undefined values
-					// outside the $.when method. Cloning the object into a fresh array solves the issue
-					deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
-				}
-			};
-		}
-		if ( length > 1 ) {
-			for( ; i < length; i++ ) {
-				if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
-					args[ i ].promise().then( resolveFunc(i), deferred.reject );
-				} else {
-					--count;
-				}
-			}
-			if ( !count ) {
-				deferred.resolveWith( deferred, args );
-			}
-		} else if ( deferred !== firstParam ) {
-			deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
-		}
-		return deferred.promise();
-	}
-});
-
-
-
-jQuery.support = (function() {
-
-	var div = document.createElement( "div" ),
-		documentElement = document.documentElement,
-		all,
-		a,
-		select,
-		opt,
-		input,
-		marginDiv,
-		support,
-		fragment,
-		body,
-		testElementParent,
-		testElement,
-		testElementStyle,
-		tds,
-		events,
-		eventName,
-		i,
-		isSupported;
-
-	// Preliminary tests
-	div.setAttribute("className", "t");
-	div.innerHTML = "   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
-
-
-	all = div.getElementsByTagName( "*" );
-	a = div.getElementsByTagName( "a" )[ 0 ];
-
-	// Can't get basic test support
-	if ( !all || !all.length || !a ) {
-		return {};
-	}
-
-	// First batch of supports tests
-	select = document.createElement( "select" );
-	opt = select.appendChild( document.createElement("option") );
-	input = div.getElementsByTagName( "input" )[ 0 ];
-
-	support = {
-		// IE strips leading whitespace when .innerHTML is used
-		leadingWhitespace: ( div.firstChild.nodeType === 3 ),
-
-		// Make sure that tbody elements aren't automatically inserted
-		// IE will insert them into empty tables
-		tbody: !div.getElementsByTagName( "tbody" ).length,
-
-		// Make sure that link elements get serialized correctly by innerHTML
-		// This requires a wrapper element in IE
-		htmlSerialize: !!div.getElementsByTagName( "link" ).length,
-
-		// Get the style information from getAttribute
-		// (IE uses .cssText instead)
-		style: /top/.test( a.getAttribute("style") ),
-
-		// Make sure that URLs aren't manipulated
-		// (IE normalizes it by default)
-		hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
-
-		// Make sure that element opacity exists
-		// (IE uses filter instead)
-		// Use a regex to work around a WebKit issue. See #5145
-		opacity: /^0.55$/.test( a.style.opacity ),
-
-		// Verify style float existence
-		// (IE uses styleFloat instead of cssFloat)
-		cssFloat: !!a.style.cssFloat,
-
-		// Make sure that if no value is specified for a checkbox
-		// that it defaults to "on".
-		// (WebKit defaults to "" instead)
-		checkOn: ( input.value === "on" ),
-
-		// Make sure that a selected-by-default option has a working selected property.
-		// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
-		optSelected: opt.selected,
-
-		// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
-		getSetAttribute: div.className !== "t",
-
-		// Will be defined later
-		submitBubbles: true,
-		changeBubbles: true,
-		focusinBubbles: false,
-		deleteExpando: true,
-		noCloneEvent: true,
-		inlineBlockNeedsLayout: false,
-		shrinkWrapBlocks: false,
-		reliableMarginRight: true
-	};
-
-	// Make sure checked status is properly cloned
-	input.checked = true;
-	support.noCloneChecked = input.cloneNode( true ).checked;
-
-	// Make sure that the options inside disabled selects aren't marked as disabled
-	// (WebKit marks them as disabled)
-	select.disabled = true;
-	support.optDisabled = !opt.disabled;
-
-	// Test to see if it's possible to delete an expando from an element
-	// Fails in Internet Explorer
-	try {
-		delete div.test;
-	} catch( e ) {
-		support.deleteExpando = false;
-	}
-
-	if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
-		div.attachEvent( "onclick", function() {
-			// Cloning a node shouldn't copy over any
-			// bound event handlers (IE does this)
-			support.noCloneEvent = false;
-		});
-		div.cloneNode( true ).fireEvent( "onclick" );
-	}
-
-	// Check if a radio maintains it's value
-	// after being appended to the DOM
-	input = document.createElement("input");
-	input.value = "t";
-	input.setAttribute("type", "radio");
-	support.radioValue = input.value === "t";
-
-	input.setAttribute("checked", "checked");
-	div.appendChild( input );
-	fragment = document.createDocumentFragment();
-	fragment.appendChild( div.firstChild );
-
-	// WebKit doesn't clone checked state correctly in fragments
-	support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
-
-	div.innerHTML = "";
-
-	// Figure out if the W3C box model works as expected
-	div.style.width = div.style.paddingLeft = "1px";
-
-	body = document.getElementsByTagName( "body" )[ 0 ];
-	// We use our own, invisible, body unless the body is already present
-	// in which case we use a div (#9239)
-	testElement = document.createElement( body ? "div" : "body" );
-	testElementStyle = {
-		visibility: "hidden",
-		width: 0,
-		height: 0,
-		border: 0,
-		margin: 0,
-		background: "none"
-	};
-	if ( body ) {
-		jQuery.extend( testElementStyle, {
-			position: "absolute",
-			left: "-1000px",
-			top: "-1000px"
-		});
-	}
-	for ( i in testElementStyle ) {
-		testElement.style[ i ] = testElementStyle[ i ];
-	}
-	testElement.appendChild( div );
-	testElementParent = body || documentElement;
-	testElementParent.insertBefore( testElement, testElementParent.firstChild );
-
-	// Check if a disconnected checkbox will retain its checked
-	// value of true after appended to the DOM (IE6/7)
-	support.appendChecked = input.checked;
-
-	support.boxModel = div.offsetWidth === 2;
-
-	if ( "zoom" in div.style ) {
-		// Check if natively block-level elements act like inline-block
-		// elements when setting their display to 'inline' and giving
-		// them layout
-		// (IE < 8 does this)
-		div.style.display = "inline";
-		div.style.zoom = 1;
-		support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
-
-		// Check if elements with layout shrink-wrap their children
-		// (IE 6 does this)
-		div.style.display = "";
-		div.innerHTML = "<div style='width:4px;'></div>";
-		support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
-	}
-
-	div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
-	tds = div.getElementsByTagName( "td" );
-
-	// Check if table cells still have offsetWidth/Height when they are set
-	// to display:none and there are still other visible table cells in a
-	// table row; if so, offsetWidth/Height are not reliable for use when
-	// determining if an element has been hidden directly using
-	// display:none (it is still safe to use offsets if a parent element is
-	// hidden; don safety goggles and see bug #4512 for more information).
-	// (only IE 8 fails this test)
-	isSupported = ( tds[ 0 ].offsetHeight === 0 );
-
-	tds[ 0 ].style.display = "";
-	tds[ 1 ].style.display = "none";
-
-	// Check if empty table cells still have offsetWidth/Height
-	// (IE < 8 fail this test)
-	support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
-	div.innerHTML = "";
-
-	// Check if div with explicit width and no margin-right incorrectly
-	// gets computed margin-right based on width of container. For more
-	// info see bug #3333
-	// Fails in WebKit before Feb 2011 nightlies
-	// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
-	if ( document.defaultView && document.defaultView.getComputedStyle ) {
-		marginDiv = document.createElement( "div" );
-		marginDiv.style.width = "0";
-		marginDiv.style.marginRight = "0";
-		div.appendChild( marginDiv );
-		support.reliableMarginRight =
-			( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
-	}
-
-	// Remove the body element we added
-	testElement.innerHTML = "";
-	testElementParent.removeChild( testElement );
-
-	// Technique from Juriy Zaytsev
-	// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
-	// We only care about the case where non-standard event systems
-	// are used, namely in IE. Short-circuiting here helps us to
-	// avoid an eval call (in setAttribute) which can cause CSP
-	// to go haywire. See: https://developer.mozilla.org/en/Security/CSP
-	if ( div.attachEvent ) {
-		for( i in {
-			submit: 1,
-			change: 1,
-			focusin: 1
-		} ) {
-			eventName = "on" + i;
-			isSupported = ( eventName in div );
-			if ( !isSupported ) {
-				div.setAttribute( eventName, "return;" );
-				isSupported = ( typeof div[ eventName ] === "function" );
-			}
-			support[ i + "Bubbles" ] = isSupported;
-		}
-	}
-
-	// Null connected elements to avoid leaks in IE
-	testElement = fragment = select = opt = body = marginDiv = div = input = null;
-
-	return support;
-})();
-
-// Keep track of boxModel
-jQuery.boxModel = jQuery.support.boxModel;
-
-
-
-
-var rbrace = /^(?:\{.*\}|\[.*\])$/,
-	rmultiDash = /([A-Z])/g;
-
-jQuery.extend({
-	cache: {},
-
-	// Please use with caution
-	uuid: 0,
-
-	// Unique for each copy of jQuery on the page
-	// Non-digits removed to match rinlinejQuery
-	expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
-
-	// The following elements throw uncatchable exceptions if you
-	// attempt to add expando properties to them.
-	noData: {
-		"embed": true,
-		// Ban all objects except for Flash (which handle expandos)
-		"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
-		"applet": true
-	},
-
-	hasData: function( elem ) {
-		elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
-
-		return !!elem && !isEmptyDataObject( elem );
-	},
-
-	data: function( elem, name, data, pvt /* Internal Use Only */ ) {
-		if ( !jQuery.acceptData( elem ) ) {
-			return;
-		}
-
-		var thisCache, ret,
-			internalKey = jQuery.expando,
-			getByName = typeof name === "string",
-
-			// We have to handle DOM nodes and JS objects differently because IE6-7
-			// can't GC object references properly across the DOM-JS boundary
-			isNode = elem.nodeType,
-
-			// Only DOM nodes need the global jQuery cache; JS object data is
-			// attached directly to the object so GC can occur automatically
-			cache = isNode ? jQuery.cache : elem,
-
-			// Only defining an ID for JS objects if its cache already exists allows
-			// the code to shortcut on the same path as a DOM node with no cache
-			id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
-
-		// Avoid doing any more work than we need to when trying to get data on an
-		// object that has no data at all
-		if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) {
-			return;
-		}
-
-		if ( !id ) {
-			// Only DOM nodes need a new unique ID for each element since their data
-			// ends up in the global cache
-			if ( isNode ) {
-				elem[ jQuery.expando ] = id = ++jQuery.uuid;
-			} else {
-				id = jQuery.expando;
-			}
-		}
-
-		if ( !cache[ id ] ) {
-			cache[ id ] = {};
-
-			// TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
-			// metadata on plain JS objects when the object is serialized using
-			// JSON.stringify
-			if ( !isNode ) {
-				cache[ id ].toJSON = jQuery.noop;
-			}
-		}
-
-		// An object can be passed to jQuery.data instead of a key/value pair; this gets
-		// shallow copied over onto the existing cache
-		if ( typeof name === "object" || typeof name === "function" ) {
-			if ( pvt ) {
-				cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
-			} else {
-				cache[ id ] = jQuery.extend(cache[ id ], name);
-			}
-		}
-
-		thisCache = cache[ id ];
-
-		// Internal jQuery data is stored in a separate object inside the object's data
-		// cache in order to avoid key collisions between internal data and user-defined
-		// data
-		if ( pvt ) {
-			if ( !thisCache[ internalKey ] ) {
-				thisCache[ internalKey ] = {};
-			}
-
-			thisCache = thisCache[ internalKey ];
-		}
-
-		if ( data !== undefined ) {
-			thisCache[ jQuery.camelCase( name ) ] = data;
-		}
-
-		// TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
-		// not attempt to inspect the internal events object using jQuery.data, as this
-		// internal data object is undocumented and subject to change.
-		if ( name === "events" && !thisCache[name] ) {
-			return thisCache[ internalKey ] && thisCache[ internalKey ].events;
-		}
-
-		// Check for both converted-to-camel and non-converted data property names
-		// If a data property was specified
-		if ( getByName ) {
-
-			// First Try to find as-is property data
-			ret = thisCache[ name ];
-
-			// Test for null|undefined property data
-			if ( ret == null ) {
-
-				// Try to find the camelCased property
-				ret = thisCache[ jQuery.camelCase( name ) ];
-			}
-		} else {
-			ret = thisCache;
-		}
-
-		return ret;
-	},
-
-	removeData: function( elem, name, pvt /* Internal Use Only */ ) {
-		if ( !jQuery.acceptData( elem ) ) {
-			return;
-		}
-
-		var thisCache,
-
-			// Reference to internal data cache key
-			internalKey = jQuery.expando,
-
-			isNode = elem.nodeType,
-
-			// See jQuery.data for more information
-			cache = isNode ? jQuery.cache : elem,
-
-			// See jQuery.data for more information
-			id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
-
-		// If there is already no cache entry for this object, there is no
-		// purpose in continuing
-		if ( !cache[ id ] ) {
-			return;
-		}
-
-		if ( name ) {
-
-			thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
-
-			if ( thisCache ) {
-
-				// Support interoperable removal of hyphenated or camelcased keys
-				if ( !thisCache[ name ] ) {
-					name = jQuery.camelCase( name );
-				}
-
-				delete thisCache[ name ];
-
-				// If there is no data left in the cache, we want to continue
-				// and let the cache object itself get destroyed
-				if ( !isEmptyDataObject(thisCache) ) {
-					return;
-				}
-			}
-		}
-
-		// See jQuery.data for more information
-		if ( pvt ) {
-			delete cache[ id ][ internalKey ];
-
-			// Don't destroy the parent cache unless the internal data object
-			// had been the only thing left in it
-			if ( !isEmptyDataObject(cache[ id ]) ) {
-				return;
-			}
-		}
-
-		var internalCache = cache[ id ][ internalKey ];
-
-		// Browsers that fail expando deletion also refuse to delete expandos on
-		// the window, but it will allow it on all other JS objects; other browsers
-		// don't care
-		// Ensure that `cache` is not a window object #10080
-		if ( jQuery.support.deleteExpando || !cache.setInterval ) {
-			delete cache[ id ];
-		} else {
-			cache[ id ] = null;
-		}
-
-		// We destroyed the entire user cache at once because it's faster than
-		// iterating through each key, but we need to continue to persist internal
-		// data if it existed
-		if ( internalCache ) {
-			cache[ id ] = {};
-			// TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
-			// metadata on plain JS objects when the object is serialized using
-			// JSON.stringify
-			if ( !isNode ) {
-				cache[ id ].toJSON = jQuery.noop;
-			}
-
-			cache[ id ][ internalKey ] = internalCache;
-
-		// Otherwise, we need to eliminate the expando on the node to avoid
-		// false lookups in the cache for entries that no longer exist
-		} else if ( isNode ) {
-			// IE does not allow us to delete expando properties from nodes,
-			// nor does it have a removeAttribute function on Document nodes;
-			// we must handle all of these cases
-			if ( jQuery.support.deleteExpando ) {
-				delete elem[ jQuery.expando ];
-			} else if ( elem.removeAttribute ) {
-				elem.removeAttribute( jQuery.expando );
-			} else {
-				elem[ jQuery.expando ] = null;
-			}
-		}
-	},
-
-	// For internal use only.
-	_data: function( elem, name, data ) {
-		return jQuery.data( elem, name, data, true );
-	},
-
-	// A method for determining if a DOM node can handle the data expando
-	acceptData: function( elem ) {
-		if ( elem.nodeName ) {
-			var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
-
-			if ( match ) {
-				return !(match === true || elem.getAttribute("classid") !== match);
-			}
-		}
-
-		return true;
-	}
-});
-
-jQuery.fn.extend({
-	data: function( key, value ) {
-		var data = null;
-
-		if ( typeof key === "undefined" ) {
-			if ( this.length ) {
-				data = jQuery.data( this[0] );
-
-				if ( this[0].nodeType === 1 ) {
-			    var attr = this[0].attributes, name;
-					for ( var i = 0, l = attr.length; i < l; i++ ) {
-						name = attr[i].name;
-
-						if ( name.indexOf( "data-" ) === 0 ) {
-							name = jQuery.camelCase( name.substring(5) );
-
-							dataAttr( this[0], name, data[ name ] );
-						}
-					}
-				}
-			}
-
-			return data;
-
-		} else if ( typeof key === "object" ) {
-			return this.each(function() {
-				jQuery.data( this, key );
-			});
-		}
-
-		var parts = key.split(".");
-		parts[1] = parts[1] ? "." + parts[1] : "";
-
-		if ( value === undefined ) {
-			data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
-
-			// Try to fetch any internally stored data first
-			if ( data === undefined && this.length ) {
-				data = jQuery.data( this[0], key );
-				data = dataAttr( this[0], key, data );
-			}
-
-			return data === undefined && parts[1] ?
-				this.data( parts[0] ) :
-				data;
-
-		} else {
-			return this.each(function() {
-				var $this = jQuery( this ),
-					args = [ parts[0], value ];
-
-				$this.triggerHandler( "setData" + parts[1] + "!", args );
-				jQuery.data( this, key, value );
-				$this.triggerHandler( "changeData" + parts[1] + "!", args );
-			});
-		}
-	},
-
-	removeData: function( key ) {
-		return this.each(function() {
-			jQuery.removeData( this, key );
-		});
-	}
-});
-
-function dataAttr( elem, key, data ) {
-	// If nothing was found internally, try to fetch any
-	// data from the HTML5 data-* attribute
-	if ( data === undefined && elem.nodeType === 1 ) {
-
-		var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
-
-		data = elem.getAttribute( name );
-
-		if ( typeof data === "string" ) {
-			try {
-				data = data === "true" ? true :
-				data === "false" ? false :
-				data === "null" ? null :
-				!jQuery.isNaN( data ) ? parseFloat( data ) :
-					rbrace.test( data ) ? jQuery.parseJSON( data ) :
-					data;
-			} catch( e ) {}
-
-			// Make sure we set the data so it isn't changed later
-			jQuery.data( elem, key, data );
-
-		} else {
-			data = undefined;
-		}
-	}
-
-	return data;
-}
-
-// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
-// property to be considered empty objects; this property always exists in
-// order to make sure JSON.stringify does not expose internal metadata
-function isEmptyDataObject( obj ) {
-	for ( var name in obj ) {
-		if ( name !== "toJSON" ) {
-			return false;
-		}
-	}
-
-	return true;
-}
-
-
-
-
-function handleQueueMarkDefer( elem, type, src ) {
-	var deferDataKey = type + "defer",
-		queueDataKey = type + "queue",
-		markDataKey = type + "mark",
-		defer = jQuery.data( elem, deferDataKey, undefined, true );
-	if ( defer &&
-		( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
-		( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
-		// Give room for hard-coded callbacks to fire first
-		// and eventually mark/queue something else on the element
-		setTimeout( function() {
-			if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
-				!jQuery.data( elem, markDataKey, undefined, true ) ) {
-				jQuery.removeData( elem, deferDataKey, true );
-				defer.resolve();
-			}
-		}, 0 );
-	}
-}
-
-jQuery.extend({
-
-	_mark: function( elem, type ) {
-		if ( elem ) {
-			type = (type || "fx") + "mark";
-			jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
-		}
-	},
-
-	_unmark: function( force, elem, type ) {
-		if ( force !== true ) {
-			type = elem;
-			elem = force;
-			force = false;
-		}
-		if ( elem ) {
-			type = type || "fx";
-			var key = type + "mark",
-				count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
-			if ( count ) {
-				jQuery.data( elem, key, count, true );
-			} else {
-				jQuery.removeData( elem, key, true );
-				handleQueueMarkDefer( elem, type, "mark" );
-			}
-		}
-	},
-
-	queue: function( elem, type, data ) {
-		if ( elem ) {
-			type = (type || "fx") + "queue";
-			var q = jQuery.data( elem, type, undefined, true );
-			// Speed up dequeue by getting out quickly if this is just a lookup
-			if ( data ) {
-				if ( !q || jQuery.isArray(data) ) {
-					q = jQuery.data( elem, type, jQuery.makeArray(data), true );
-				} else {
-					q.push( data );
-				}
-			}
-			return q || [];
-		}
-	},
-
-	dequeue: function( elem, type ) {
-		type = type || "fx";
-
-		var queue = jQuery.queue( elem, type ),
-			fn = queue.shift(),
-			defer;
-
-		// If the fx queue is dequeued, always remove the progress sentinel
-		if ( fn === "inprogress" ) {
-			fn = queue.shift();
-		}
-
-		if ( fn ) {
-			// Add a progress sentinel to prevent the fx queue from being
-			// automatically dequeued
-			if ( type === "fx" ) {
-				queue.unshift("inprogress");
-			}
-
-			fn.call(elem, function() {
-				jQuery.dequeue(elem, type);
-			});
-		}
-
-		if ( !queue.length ) {
-			jQuery.removeData( elem, type + "queue", true );
-			handleQueueMarkDefer( elem, type, "queue" );
-		}
-	}
-});
-
-jQuery.fn.extend({
-	queue: function( type, data ) {
-		if ( typeof type !== "string" ) {
-			data = type;
-			type = "fx";
-		}
-
-		if ( data === undefined ) {
-			return jQuery.queue( this[0], type );
-		}
-		return this.each(function() {
-			var queue = jQuery.queue( this, type, data );
-
-			if ( type === "fx" && queue[0] !== "inprogress" ) {
-				jQuery.dequeue( this, type );
-			}
-		});
-	},
-	dequeue: function( type ) {
-		return this.each(function() {
-			jQuery.dequeue( this, type );
-		});
-	},
-	// Based off of the plugin by Clint Helfers, with permission.
-	// http://blindsignals.com/index.php/2009/07/jquery-delay/
-	delay: function( time, type ) {
-		time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
-		type = type || "fx";
-
-		return this.queue( type, function() {
-			var elem = this;
-			setTimeout(function() {
-				jQuery.dequeue( elem, type );
-			}, time );
-		});
-	},
-	clearQueue: function( type ) {
-		return this.queue( type || "fx", [] );
-	},
-	// Get a promise resolved when queues of a certain type
-	// are emptied (fx is the type by default)
-	promise: function( type, object ) {
-		if ( typeof type !== "string" ) {
-			object = type;
-			type = undefined;
-		}
-		type = type || "fx";
-		var defer = jQuery.Deferred(),
-			elements = this,
-			i = elements.length,
-			count = 1,
-			deferDataKey = type + "defer",
-			queueDataKey = type + "queue",
-			markDataKey = type + "mark",
-			tmp;
-		function resolve() {
-			if ( !( --count ) ) {
-				defer.resolveWith( elements, [ elements ] );
-			}
-		}
-		while( i-- ) {
-			if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
-					( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
-						jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
-					jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
-				count++;
-				tmp.done( resolve );
-			}
-		}
-		resolve();
-		return defer.promise();
-	}
-});
-
-
-
-
-var rclass = /[\n\t\r]/g,
-	rspace = /\s+/,
-	rreturn = /\r/g,
-	rtype = /^(?:button|input)$/i,
-	rfocusable = /^(?:button|input|object|select|textarea)$/i,
-	rclickable = /^a(?:rea)?$/i,
-	rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
-	nodeHook, boolHook;
-
-jQuery.fn.extend({
-	attr: function( name, value ) {
-		return jQuery.access( this, name, value, true, jQuery.attr );
-	},
-
-	removeAttr: function( name ) {
-		return this.each(function() {
-			jQuery.removeAttr( this, name );
-		});
-	},
-	
-	prop: function( name, value ) {
-		return jQuery.access( this, name, value, true, jQuery.prop );
-	},
-	
-	removeProp: function( name ) {
-		name = jQuery.propFix[ name ] || name;
-		return this.each(function() {
-			// try/catch handles cases where IE balks (such as removing a property on window)
-			try {
-				this[ name ] = undefined;
-				delete this[ name ];
-			} catch( e ) {}
-		});
-	},
-
-	addClass: function( value ) {
-		var classNames, i, l, elem,
-			setClass, c, cl;
-
-		if ( jQuery.isFunction( value ) ) {
-			return this.each(function( j ) {
-				jQuery( this ).addClass( value.call(this, j, this.className) );
-			});
-		}
-
-		if ( value && typeof value === "string" ) {
-			classNames = value.split( rspace );
-
-			for ( i = 0, l = this.length; i < l; i++ ) {
-				elem = this[ i ];
-
-				if ( elem.nodeType === 1 ) {
-					if ( !elem.className && classNames.length === 1 ) {
-						elem.className = value;
-
-					} else {
-						setClass = " " + elem.className + " ";
-
-						for ( c = 0, cl = classNames.length; c < cl; c++ ) {
-							if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
-								setClass += classNames[ c ] + " ";
-							}
-						}
-						elem.className = jQuery.trim( setClass );
-					}
-				}
-			}
-		}
-
-		return this;
-	},
-
-	removeClass: function( value ) {
-		var classNames, i, l, elem, className, c, cl;
-
-		if ( jQuery.isFunction( value ) ) {
-			return this.each(function( j ) {
-				jQuery( this ).removeClass( value.call(this, j, this.className) );
-			});
-		}
-
-		if ( (value && typeof value === "string") || value === undefined ) {
-			classNames = (value || "").split( rspace );
-
-			for ( i = 0, l = this.length; i < l; i++ ) {
-				elem = this[ i ];
-
-				if ( elem.nodeType === 1 && elem.className ) {
-					if ( value ) {
-						className = (" " + elem.className + " ").replace( rclass, " " );
-						for ( c = 0, cl = classNames.length; c < cl; c++ ) {
-							className = className.replace(" " + classNames[ c ] + " ", " ");
-						}
-						elem.className = jQuery.trim( className );
-
-					} else {
-						elem.className = "";
-					}
-				}
-			}
-		}
-
-		return this;
-	},
-
-	toggleClass: function( value, stateVal ) {
-		var type = typeof value,
-			isBool = typeof stateVal === "boolean";
-
-		if ( jQuery.isFunction( value ) ) {
-			return this.each(function( i ) {
-				jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
-			});
-		}
-
-		return this.each(function() {
-			if ( type === "string" ) {
-				// toggle individual class names
-				var className,
-					i = 0,
-					self = jQuery( this ),
-					state = stateVal,
-					classNames = value.split( rspace );
-
-				while ( (className = classNames[ i++ ]) ) {
-					// check each className given, space seperated list
-					state = isBool ? state : !self.hasClass( className );
-					self[ state ? "addClass" : "removeClass" ]( className );
-				}
-
-			} else if ( type === "undefined" || type === "boolean" ) {
-				if ( this.className ) {
-					// store className if set
-					jQuery._data( this, "__className__", this.className );
-				}
-
-				// toggle whole className
-				this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
-			}
-		});
-	},
-
-	hasClass: function( selector ) {
-		var className = " " + selector + " ";
-		for ( var i = 0, l = this.length; i < l; i++ ) {
-			if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
-				return true;
-			}
-		}
-
-		return false;
-	},
-
-	val: function( value ) {
-		var hooks, ret,
-			elem = this[0];
-		
-		if ( !arguments.length ) {
-			if ( elem ) {
-				hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
-
-				if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
-					return ret;
-				}
-
-				ret = elem.value;
-
-				return typeof ret === "string" ? 
-					// handle most common string cases
-					ret.replace(rreturn, "") : 
-					// handle cases where value is null/undef or number
-					ret == null ? "" : ret;
-			}
-
-			return undefined;
-		}
-
-		var isFunction = jQuery.isFunction( value );
-
-		return this.each(function( i ) {
-			var self = jQuery(this), val;
-
-			if ( this.nodeType !== 1 ) {
-				return;
-			}
-
-			if ( isFunction ) {
-				val = value.call( this, i, self.val() );
-			} else {
-				val = value;
-			}
-
-			// Treat null/undefined as ""; convert numbers to string
-			if ( val == null ) {
-				val = "";
-			} else if ( typeof val === "number" ) {
-				val += "";
-			} else if ( jQuery.isArray( val ) ) {
-				val = jQuery.map(val, function ( value ) {
-					return value == null ? "" : value + "";
-				});
-			}
-
-			hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
-
-			// If set returns undefined, fall back to normal setting
-			if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
-				this.value = val;
-			}
-		});
-	}
-});
-
-jQuery.extend({
-	valHooks: {
-		option: {
-			get: function( elem ) {
-				// attributes.value is undefined in Blackberry 4.7 but
-				// uses .value. See #6932
-				var val = elem.attributes.value;
-				return !val || val.specified ? elem.value : elem.text;
-			}
-		},
-		select: {
-			get: function( elem ) {
-				var value,
-					index = elem.selectedIndex,
-					values = [],
-					options = elem.options,
-					one = elem.type === "select-one";
-
-				// Nothing was selected
-				if ( index < 0 ) {
-					return null;
-				}
-
-				// Loop through all the selected options
-				for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
-					var option = options[ i ];
-
-					// Don't return options that are disabled or in a disabled optgroup
-					if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
-							(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
-
-						// Get the specific value for the option
-						value = jQuery( option ).val();
-
-						// We don't need an array for one selects
-						if ( one ) {
-							return value;
-						}
-
-						// Multi-Selects return an array
-						values.push( value );
-					}
-				}
-
-				// Fixes Bug #2551 -- select.val() broken in IE after form.reset()
-				if ( one && !values.length && options.length ) {
-					return jQuery( options[ index ] ).val();
-				}
-
-				return values;
-			},
-
-			set: function( elem, value ) {
-				var values = jQuery.makeArray( value );
-
-				jQuery(elem).find("option").each(function() {
-					this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
-				});
-
-				if ( !values.length ) {
-					elem.selectedIndex = -1;
-				}
-				return values;
-			}
-		}
-	},
-
-	attrFn: {
-		val: true,
-		css: true,
-		html: true,
-		text: true,
-		data: true,
-		width: true,
-		height: true,
-		offset: true
-	},
-	
-	attrFix: {
-		// Always normalize to ensure hook usage
-		tabindex: "tabIndex"
-	},
-	
-	attr: function( elem, name, value, pass ) {
-		var nType = elem.nodeType;
-		
-		// don't get/set attributes on text, comment and attribute nodes
-		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
-			return undefined;
-		}
-
-		if ( pass && name in jQuery.attrFn ) {
-			return jQuery( elem )[ name ]( value );
-		}
-
-		// Fallback to prop when attributes are not supported
-		if ( !("getAttribute" in elem) ) {
-			return jQuery.prop( elem, name, value );
-		}
-
-		var ret, hooks,
-			notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
-		// Normalize the name if needed
-		if ( notxml ) {
-			name = jQuery.attrFix[ name ] || name;
-
-			hooks = jQuery.attrHooks[ name ];
-
-			if ( !hooks ) {
-				// Use boolHook for boolean attributes
-				if ( rboolean.test( name ) ) {
-					hooks = boolHook;
-
-				// Use nodeHook if available( IE6/7 )
-				} else if ( nodeHook ) {
-					hooks = nodeHook;
-				}
-			}
-		}
-
-		if ( value !== undefined ) {
-
-			if ( value === null ) {
-				jQuery.removeAttr( elem, name );
-				return undefined;
-
-			} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
-				return ret;
-
-			} else {
-				elem.setAttribute( name, "" + value );
-				return value;
-			}
-
-		} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
-			return ret;
-
-		} else {
-
-			ret = elem.getAttribute( name );
-
-			// Non-existent attributes return null, we normalize to undefined
-			return ret === null ?
-				undefined :
-				ret;
-		}
-	},
-
-	removeAttr: function( elem, name ) {
-		var propName;
-		if ( elem.nodeType === 1 ) {
-			name = jQuery.attrFix[ name ] || name;
-
-			jQuery.attr( elem, name, "" );
-			elem.removeAttribute( name );
-
-			// Set corresponding property to false for boolean attributes
-			if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
-				elem[ propName ] = false;
-			}
-		}
-	},
-
-	attrHooks: {
-		type: {
-			set: function( elem, value ) {
-				// We can't allow the type property to be changed (since it causes problems in IE)
-				if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
-					jQuery.error( "type property can't be changed" );
-				} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
-					// Setting the type on a radio button after the value resets the value in IE6-9
-					// Reset value to it's default in case type is set after value
-					// This is for element creation
-					var val = elem.value;
-					elem.setAttribute( "type", value );
-					if ( val ) {
-						elem.value = val;
-					}
-					return value;
-				}
-			}
-		},
-		// Use the value property for back compat
-		// Use the nodeHook for button elements in IE6/7 (#1954)
-		value: {
-			get: function( elem, name ) {
-				if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
-					return nodeHook.get( elem, name );
-				}
-				return name in elem ?
-					elem.value :
-					null;
-			},
-			set: function( elem, value, name ) {
-				if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
-					return nodeHook.set( elem, value, name );
-				}
-				// Does not return so that setAttribute is also used
-				elem.value = value;
-			}
-		}
-	},
-
-	propFix: {
-		tabindex: "tabIndex",
-		readonly: "readOnly",
-		"for": "htmlFor",
-		"class": "className",
-		maxlength: "maxLength",
-		cellspacing: "cellSpacing",
-		cellpadding: "cellPadding",
-		rowspan: "rowSpan",
-		colspan: "colSpan",
-		usemap: "useMap",
-		frameborder: "frameBorder",
-		contenteditable: "contentEditable"
-	},
-	
-	prop: function( elem, name, value ) {
-		var nType = elem.nodeType;
-
-		// don't get/set properties on text, comment and attribute nodes
-		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
-			return undefined;
-		}
-
-		var ret, hooks,
-			notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
-		if ( notxml ) {
-			// Fix name and attach hooks
-			name = jQuery.propFix[ name ] || name;
-			hooks = jQuery.propHooks[ name ];
-		}
-
-		if ( value !== undefined ) {
-			if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
-				return ret;
-
-			} else {
-				return (elem[ name ] = value);
-			}
-
-		} else {
-			if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
-				return ret;
-
-			} else {
-				return elem[ name ];
-			}
-		}
-	},
-	
-	propHooks: {
-		tabIndex: {
-			get: function( elem ) {
-				// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
-				// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
-				var attributeNode = elem.getAttributeNode("tabindex");
-
-				return attributeNode && attributeNode.specified ?
-					parseInt( attributeNode.value, 10 ) :
-					rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
-						0 :
-						undefined;
-			}
-		}
-	}
-});
-
-// Add the tabindex propHook to attrHooks for back-compat
-jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex;
-
-// Hook for boolean attributes
-boolHook = {
-	get: function( elem, name ) {
-		// Align boolean attributes with corresponding properties
-		// Fall back to attribute presence where some booleans are not supported
-		var attrNode;
-		return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ?
-			name.toLowerCase() :
-			undefined;
-	},
-	set: function( elem, value, name ) {
-		var propName;
-		if ( value === false ) {
-			// Remove boolean attributes when set to false
-			jQuery.removeAttr( elem, name );
-		} else {
-			// value is true since we know at this point it's type boolean and not false
-			// Set boolean attributes to the same name and set the DOM property
-			propName = jQuery.propFix[ name ] || name;
-			if ( propName in elem ) {
-				// Only set the IDL specifically if it already exists on the element
-				elem[ propName ] = true;
-			}
-
-			elem.setAttribute( name, name.toLowerCase() );
-		}
-		return name;
-	}
-};
-
-// IE6/7 do not support getting/setting some attributes with get/setAttribute
-if ( !jQuery.support.getSetAttribute ) {
-	
-	// Use this for any attribute in IE6/7
-	// This fixes almost every IE6/7 issue
-	nodeHook = jQuery.valHooks.button = {
-		get: function( elem, name ) {
-			var ret;
-			ret = elem.getAttributeNode( name );
-			// Return undefined if nodeValue is empty string
-			return ret && ret.nodeValue !== "" ?
-				ret.nodeValue :
-				undefined;
-		},
-		set: function( elem, value, name ) {
-			// Set the existing or create a new attribute node
-			var ret = elem.getAttributeNode( name );
-			if ( !ret ) {
-				ret = document.createAttribute( name );
-				elem.setAttributeNode( ret );
-			}
-			return (ret.nodeValue = value + "");
-		}
-	};
-
-	// Set width and height to auto instead of 0 on empty string( Bug #8150 )
-	// This is for removals
-	jQuery.each([ "width", "height" ], function( i, name ) {
-		jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
-			set: function( elem, value ) {
-				if ( value === "" ) {
-					elem.setAttribute( name, "auto" );
-					return value;
-				}
-			}
-		});
-	});
-}
-
-
-// Some attributes require a special call on IE
-if ( !jQuery.support.hrefNormalized ) {
-	jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
-		jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
-			get: function( elem ) {
-				var ret = elem.getAttribute( name, 2 );
-				return ret === null ? undefined : ret;
-			}
-		});
-	});
-}
-
-if ( !jQuery.support.style ) {
-	jQuery.attrHooks.style = {
-		get: function( elem ) {
-			// Return undefined in the case of empty string
-			// Normalize to lowercase since IE uppercases css property names
-			return elem.style.cssText.toLowerCase() || undefined;
-		},
-		set: function( elem, value ) {
-			return (elem.style.cssText = "" + value);
-		}
-	};
-}
-
-// Safari mis-reports the default selected property of an option
-// Accessing the parent's selectedIndex property fixes it
-if ( !jQuery.support.optSelected ) {
-	jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
-		get: function( elem ) {
-			var parent = elem.parentNode;
-
-			if ( parent ) {
-				parent.selectedIndex;
-
-				// Make sure that it also works with optgroups, see #5701
-				if ( parent.parentNode ) {
-					parent.parentNode.selectedIndex;
-				}
-			}
-			return null;
-		}
-	});
-}
-
-// Radios and checkboxes getter/setter
-if ( !jQuery.support.checkOn ) {
-	jQuery.each([ "radio", "checkbox" ], function() {
-		jQuery.valHooks[ this ] = {
-			get: function( elem ) {
-				// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
-				return elem.getAttribute("value") === null ? "on" : elem.value;
-			}
-		};
-	});
-}
-jQuery.each([ "radio", "checkbox" ], function() {
-	jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
-		set: function( elem, value ) {
-			if ( jQuery.isArray( value ) ) {
-				return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
-			}
-		}
-	});
-});
-
-
-
-
-var rnamespaces = /\.(.*)$/,
-	rformElems = /^(?:textarea|input|select)$/i,
-	rperiod = /\./g,
-	rspaces = / /g,
-	rescape = /[^\w\s.|`]/g,
-	fcleanup = function( nm ) {
-		return nm.replace(rescape, "\\$&");
-	};
-
-/*
- * A number of helper functions used for managing events.
- * Many of the ideas behind this code originated from
- * Dean Edwards' addEvent library.
- */
-jQuery.event = {
-
-	// Bind an event to an element
-	// Original by Dean Edwards
-	add: function( elem, types, handler, data ) {
-		if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
-			return;
-		}
-
-		if ( handler === false ) {
-			handler = returnFalse;
-		} else if ( !handler ) {
-			// Fixes bug #7229. Fix recommended by jdalton
-			return;
-		}
-
-		var handleObjIn, handleObj;
-
-		if ( handler.handler ) {
-			handleObjIn = handler;
-			handler = handleObjIn.handler;
-		}
-
-		// Make sure that the function being executed has a unique ID
-		if ( !handler.guid ) {
-			handler.guid = jQuery.guid++;
-		}
-
-		// Init the element's event structure
-		var elemData = jQuery._data( elem );
-
-		// If no elemData is found then we must be trying to bind to one of the
-		// banned noData elements
-		if ( !elemData ) {
-			return;
-		}
-
-		var events = elemData.events,
-			eventHandle = elemData.handle;
-
-		if ( !events ) {
-			elemData.events = events = {};
-		}
-
-		if ( !eventHandle ) {
-			elemData.handle = eventHandle = function( e ) {
-				// Discard the second event of a jQuery.event.trigger() and
-				// when an event is called after a page has unloaded
-				return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
-					jQuery.event.handle.apply( eventHandle.elem, arguments ) :
-					undefined;
-			};
-		}
-
-		// Add elem as a property of the handle function
-		// This is to prevent a memory leak with non-native events in IE.
-		eventHandle.elem = elem;
-
-		// Handle multiple events separated by a space
-		// jQuery(...).bind("mouseover mouseout", fn);
-		types = types.split(" ");
-
-		var type, i = 0, namespaces;
-
-		while ( (type = types[ i++ ]) ) {
-			handleObj = handleObjIn ?
-				jQuery.extend({}, handleObjIn) :
-				{ handler: handler, data: data };
-
-			// Namespaced event handlers
-			if ( type.indexOf(".") > -1 ) {
-				namespaces = type.split(".");
-				type = namespaces.shift();
-				handleObj.namespace = namespaces.slice(0).sort().join(".");
-
-			} else {
-				namespaces = [];
-				handleObj.namespace = "";
-			}
-
-			handleObj.type = type;
-			if ( !handleObj.guid ) {
-				handleObj.guid = handler.guid;
-			}
-
-			// Get the current list of functions bound to this event
-			var handlers = events[ type ],
-				special = jQuery.event.special[ type ] || {};
-
-			// Init the event handler queue
-			if ( !handlers ) {
-				handlers = events[ type ] = [];
-
-				// Check for a special event handler
-				// Only use addEventListener/attachEvent if the special
-				// events handler returns false
-				if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
-					// Bind the global event handler to the element
-					if ( elem.addEventListener ) {
-						elem.addEventListener( type, eventHandle, false );
-
-					} else if ( elem.attachEvent ) {
-						elem.attachEvent( "on" + type, eventHandle );
-					}
-				}
-			}
-
-			if ( special.add ) {
-				special.add.call( elem, handleObj );
-
-				if ( !handleObj.handler.guid ) {
-					handleObj.handler.guid = handler.guid;
-				}
-			}
-
-			// Add the function to the element's handler list
-			handlers.push( handleObj );
-
-			// Keep track of which events have been used, for event optimization
-			jQuery.event.global[ type ] = true;
-		}
-
-		// Nullify elem to prevent memory leaks in IE
-		elem = null;
-	},
-
-	global: {},
-
-	// Detach an event or set of events from an element
-	remove: function( elem, types, handler, pos ) {
-		// don't do events on text and comment nodes
-		if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
-			return;
-		}
-
-		if ( handler === false ) {
-			handler = returnFalse;
-		}
-
-		var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
-			elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
-			events = elemData && elemData.events;
-
-		if ( !elemData || !events ) {
-			return;
-		}
-
-		// types is actually an event object here
-		if ( types && types.type ) {
-			handler = types.handler;
-			types = types.type;
-		}
-
-		// Unbind all events for the element
-		if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
-			types = types || "";
-
-			for ( type in events ) {
-				jQuery.event.remove( elem, type + types );
-			}
-
-			return;
-		}
-
-		// Handle multiple events separated by a space
-		// jQuery(...).unbind("mouseover mouseout", fn);
-		types = types.split(" ");
-
-		while ( (type = types[ i++ ]) ) {
-			origType = type;
-			handleObj = null;
-			all = type.indexOf(".") < 0;
-			namespaces = [];
-
-			if ( !all ) {
-				// Namespaced event handlers
-				namespaces = type.split(".");
-				type = namespaces.shift();
-
-				namespace = new RegExp("(^|\\.)" +
-					jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
-			}
-
-			eventType = events[ type ];
-
-			if ( !eventType ) {
-				continue;
-			}
-
-			if ( !handler ) {
-				for ( j = 0; j < eventType.length; j++ ) {
-					handleObj = eventType[ j ];
-
-					if ( all || namespace.test( handleObj.namespace ) ) {
-						jQuery.event.remove( elem, origType, handleObj.handler, j );
-						eventType.splice( j--, 1 );
-					}
-				}
-
-				continue;
-			}
-
-			special = jQuery.event.special[ type ] || {};
-
-			for ( j = pos || 0; j < eventType.length; j++ ) {
-				handleObj = eventType[ j ];
-
-				if ( handler.guid === handleObj.guid ) {
-					// remove the given handler for the given type
-					if ( all || namespace.test( handleObj.namespace ) ) {
-						if ( pos == null ) {
-							eventType.splice( j--, 1 );
-						}
-
-						if ( special.remove ) {
-							special.remove.call( elem, handleObj );
-						}
-					}
-
-					if ( pos != null ) {
-						break;
-					}
-				}
-			}
-
-			// remove generic event handler if no more handlers exist
-			if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
-				if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
-					jQuery.removeEvent( elem, type, elemData.handle );
-				}
-
-				ret = null;
-				delete events[ type ];
-			}
-		}
-
-		// Remove the expando if it's no longer used
-		if ( jQuery.isEmptyObject( events ) ) {
-			var handle = elemData.handle;
-			if ( handle ) {
-				handle.elem = null;
-			}
-
-			delete elemData.events;
-			delete elemData.handle;
-
-			if ( jQuery.isEmptyObject( elemData ) ) {
-				jQuery.removeData( elem, undefined, true );
-			}
-		}
-	},
-	
-	// Events that are safe to short-circuit if no handlers are attached.
-	// Native DOM events should not be added, they may have inline handlers.
-	customEvent: {
-		"getData": true,
-		"setData": true,
-		"changeData": true
-	},
-
-	trigger: function( event, data, elem, onlyHandlers ) {
-		// Event object or event type
-		var type = event.type || event,
-			namespaces = [],
-			exclusive;
-
-		if ( type.indexOf("!") >= 0 ) {
-			// Exclusive events trigger only for the exact event (no namespaces)
-			type = type.slice(0, -1);
-			exclusive = true;
-		}
-
-		if ( type.indexOf(".") >= 0 ) {
-			// Namespaced trigger; create a regexp to match event type in handle()
-			namespaces = type.split(".");
-			type = namespaces.shift();
-			namespaces.sort();
-		}
-
-		if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
-			// No jQuery handlers for this event type, and it can't have inline handlers
-			return;
-		}
-
-		// Caller can pass in an Event, Object, or just an event type string
-		event = typeof event === "object" ?
-			// jQuery.Event object
-			event[ jQuery.expando ] ? event :
-			// Object literal
-			new jQuery.Event( type, event ) :
-			// Just the event type (string)
-			new jQuery.Event( type );
-
-		event.type = type;
-		event.exclusive = exclusive;
-		event.namespace = namespaces.join(".");
-		event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
-		
-		// triggerHandler() and global events don't bubble or run the default action
-		if ( onlyHandlers || !elem ) {
-			event.preventDefault();
-			event.stopPropagation();
-		}
-
-		// Handle a global trigger
-		if ( !elem ) {
-			// TODO: Stop taunting the data cache; remove global events and always attach to document
-			jQuery.each( jQuery.cache, function() {
-				// internalKey variable is just used to make it easier to find
-				// and potentially change this stuff later; currently it just
-				// points to jQuery.expando
-				var internalKey = jQuery.expando,
-					internalCache = this[ internalKey ];
-				if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
-					jQuery.event.trigger( event, data, internalCache.handle.elem );
-				}
-			});
-			return;
-		}
-
-		// Don't do events on text and comment nodes
-		if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
-			return;
-		}
-
-		// Clean up the event in case it is being reused
-		event.result = undefined;
-		event.target = elem;
-
-		// Clone any incoming data and prepend the event, creating the handler arg list
-		data = data != null ? jQuery.makeArray( data ) : [];
-		data.unshift( event );
-
-		var cur = elem,
-			// IE doesn't like method names with a colon (#3533, #8272)
-			ontype = type.indexOf(":") < 0 ? "on" + type : "";
-
-		// Fire event on the current element, then bubble up the DOM tree
-		do {
-			var handle = jQuery._data( cur, "handle" );
-
-			event.currentTarget = cur;
-			if ( handle ) {
-				handle.apply( cur, data );
-			}
-
-			// Trigger an inline bound script
-			if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
-				event.result = false;
-				event.preventDefault();
-			}
-
-			// Bubble up to document, then to window
-			cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
-		} while ( cur && !event.isPropagationStopped() );
-
-		// If nobody prevented the default action, do it now
-		if ( !event.isDefaultPrevented() ) {
-			var old,
-				special = jQuery.event.special[ type ] || {};
-
-			if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
-				!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
-
-				// Call a native DOM method on the target with the same name name as the event.
-				// Can't use an .isFunction)() check here because IE6/7 fails that test.
-				// IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
-				try {
-					if ( ontype && elem[ type ] ) {
-						// Don't re-trigger an onFOO event when we call its FOO() method
-						old = elem[ ontype ];
-
-						if ( old ) {
-							elem[ ontype ] = null;
-						}
-
-						jQuery.event.triggered = type;
-						elem[ type ]();
-					}
-				} catch ( ieError ) {}
-
-				if ( old ) {
-					elem[ ontype ] = old;
-				}
-
-				jQuery.event.triggered = undefined;
-			}
-		}
-		
-		return event.result;
-	},
-
-	handle: function( event ) {
-		event = jQuery.event.fix( event || window.event );
-		// Snapshot the handlers list since a called handler may add/remove events.
-		var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
-			run_all = !event.exclusive && !event.namespace,
-			args = Array.prototype.slice.call( arguments, 0 );
-
-		// Use the fix-ed Event rather than the (read-only) native event
-		args[0] = event;
-		event.currentTarget = this;
-
-		for ( var j = 0, l = handlers.length; j < l; j++ ) {
-			var handleObj = handlers[ j ];
-
-			// Triggered event must 1) be non-exclusive and have no namespace, or
-			// 2) have namespace(s) a subset or equal to those in the bound event.
-			if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
-				// Pass in a reference to the handler function itself
-				// So that we can later remove it
-				event.handler = handleObj.handler;
-				event.data = handleObj.data;
-				event.handleObj = handleObj;
-
-				var ret = handleObj.handler.apply( this, args );
-
-				if ( ret !== undefined ) {
-					event.result = ret;
-					if ( ret === false ) {
-						event.preventDefault();
-						event.stopPropagation();
-					}
-				}
-
-				if ( event.isImmediatePropagationStopped() ) {
-					break;
-				}
-			}
-		}
-		return event.result;
-	},
-
-	props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
-
-	fix: function( event ) {
-		if ( event[ jQuery.expando ] ) {
-			return event;
-		}
-
-		// store a copy of the original event object
-		// and "clone" to set read-only properties
-		var originalEvent = event;
-		event = jQuery.Event( originalEvent );
-
-		for ( var i = this.props.length, prop; i; ) {
-			prop = this.props[ --i ];
-			event[ prop ] = originalEvent[ prop ];
-		}
-
-		// Fix target property, if necessary
-		if ( !event.target ) {
-			// Fixes #1925 where srcElement might not be defined either
-			event.target = event.srcElement || document;
-		}
-
-		// check if target is a textnode (safari)
-		if ( event.target.nodeType === 3 ) {
-			event.target = event.target.parentNode;
-		}
-
-		// Add relatedTarget, if necessary
-		if ( !event.relatedTarget && event.fromElement ) {
-			event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
-		}
-
-		// Calculate pageX/Y if missing and clientX/Y available
-		if ( event.pageX == null && event.clientX != null ) {
-			var eventDocument = event.target.ownerDocument || document,
-				doc = eventDocument.documentElement,
-				body = eventDocument.body;
-
-			event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
-			event.pageY = event.clientY + (doc && doc.scrollTop  || body && body.scrollTop  || 0) - (doc && doc.clientTop  || body && body.clientTop  || 0);
-		}
-
-		// Add which for key events
-		if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
-			event.which = event.charCode != null ? event.charCode : event.keyCode;
-		}
-
-		// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
-		if ( !event.metaKey && event.ctrlKey ) {
-			event.metaKey = event.ctrlKey;
-		}
-
-		// Add which for click: 1 === left; 2 === middle; 3 === right
-		// Note: button is not normalized, so don't use it
-		if ( !event.which && event.button !== undefined ) {
-			event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
-		}
-
-		return event;
-	},
-
-	// Deprecated, use jQuery.guid instead
-	guid: 1E8,
-
-	// Deprecated, use jQuery.proxy instead
-	proxy: jQuery.proxy,
-
-	special: {
-		ready: {
-			// Make sure the ready event is setup
-			setup: jQuery.bindReady,
-			teardown: jQuery.noop
-		},
-
-		live: {
-			add: function( handleObj ) {
-				jQuery.event.add( this,
-					liveConvert( handleObj.origType, handleObj.selector ),
-					jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
-			},
-
-			remove: function( handleObj ) {
-				jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
-			}
-		},
-
-		beforeunload: {
-			setup: function( data, namespaces, eventHandle ) {
-				// We only want to do this special case on windows
-				if ( jQuery.isWindow( this ) ) {
-					this.onbeforeunload = eventHandle;
-				}
-			},
-
-			teardown: function( namespaces, eventHandle ) {
-				if ( this.onbeforeunload === eventHandle ) {
-					this.onbeforeunload = null;
-				}
-			}
-		}
-	}
-};
-
-jQuery.removeEvent = document.removeEventListener ?
-	function( elem, type, handle ) {
-		if ( elem.removeEventListener ) {
-			elem.removeEventListener( type, handle, false );
-		}
-	} :
-	function( elem, type, handle ) {
-		if ( elem.detachEvent ) {
-			elem.detachEvent( "on" + type, handle );
-		}
-	};
-
-jQuery.Event = function( src, props ) {
-	// Allow instantiation without the 'new' keyword
-	if ( !this.preventDefault ) {
-		return new jQuery.Event( src, props );
-	}
-
-	// Event object
-	if ( src && src.type ) {
-		this.originalEvent = src;
-		this.type = src.type;
-
-		// Events bubbling up the document may have been marked as prevented
-		// by a handler lower down the tree; reflect the correct value.
-		this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
-			src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
-
-	// Event type
-	} else {
-		this.type = src;
-	}
-
-	// Put explicitly provided properties onto the event object
-	if ( props ) {
-		jQuery.extend( this, props );
-	}
-
-	// timeStamp is buggy for some events on Firefox(#3843)
-	// So we won't rely on the native value
-	this.timeStamp = jQuery.now();
-
-	// Mark it as fixed
-	this[ jQuery.expando ] = true;
-};
-
-function returnFalse() {
-	return false;
-}
-function returnTrue() {
-	return true;
-}
-
-// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
-// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
-jQuery.Event.prototype = {
-	preventDefault: function() {
-		this.isDefaultPrevented = returnTrue;
-
-		var e = this.originalEvent;
-		if ( !e ) {
-			return;
-		}
-
-		// if preventDefault exists run it on the original event
-		if ( e.preventDefault ) {
-			e.preventDefault();
-
-		// otherwise set the returnValue property of the original event to false (IE)
-		} else {
-			e.returnValue = false;
-		}
-	},
-	stopPropagation: function() {
-		this.isPropagationStopped = returnTrue;
-
-		var e = this.originalEvent;
-		if ( !e ) {
-			return;
-		}
-		// if stopPropagation exists run it on the original event
-		if ( e.stopPropagation ) {
-			e.stopPropagation();
-		}
-		// otherwise set the cancelBubble property of the original event to true (IE)
-		e.cancelBubble = true;
-	},
-	stopImmediatePropagation: function() {
-		this.isImmediatePropagationStopped = returnTrue;
-		this.stopPropagation();
-	},
-	isDefaultPrevented: returnFalse,
-	isPropagationStopped: returnFalse,
-	isImmediatePropagationStopped: returnFalse
-};
-
-// Checks if an event happened on an element within another element
-// Used in jQuery.event.special.mouseenter and mouseleave handlers
-var withinElement = function( event ) {
-
-	// Check if mouse(over|out) are still within the same parent element
-	var related = event.relatedTarget,
-		inside = false,
-		eventType = event.type;
-
-	event.type = event.data;
-
-	if ( related !== this ) {
-
-		if ( related ) {
-			inside = jQuery.contains( this, related );
-		}
-
-		if ( !inside ) {
-
-			jQuery.event.handle.apply( this, arguments );
-
-			event.type = eventType;
-		}
-	}
-},
-
-// In case of event delegation, we only need to rename the event.type,
-// liveHandler will take care of the rest.
-delegate = function( event ) {
-	event.type = event.data;
-	jQuery.event.handle.apply( this, arguments );
-};
-
-// Create mouseenter and mouseleave events
-jQuery.each({
-	mouseenter: "mouseover",
-	mouseleave: "mouseout"
-}, function( orig, fix ) {
-	jQuery.event.special[ orig ] = {
-		setup: function( data ) {
-			jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
-		},
-		teardown: function( data ) {
-			jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
-		}
-	};
-});
-
-// submit delegation
-if ( !jQuery.support.submitBubbles ) {
-
-	jQuery.event.special.submit = {
-		setup: function( data, namespaces ) {
-			if ( !jQuery.nodeName( this, "form" ) ) {
-				jQuery.event.add(this, "click.specialSubmit", function( e ) {
-					// Avoid triggering error on non-existent type attribute in IE VML (#7071)
-					var elem = e.target,
-						type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
-
-					if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
-						trigger( "submit", this, arguments );
-					}
-				});
-
-				jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
-					var elem = e.target,
-						type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
-
-					if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
-						trigger( "submit", this, arguments );
-					}
-				});
-
-			} else {
-				return false;
-			}
-		},
-
-		teardown: function( namespaces ) {
-			jQuery.event.remove( this, ".specialSubmit" );
-		}
-	};
-
-}
-
-// change delegation, happens here so we have bind.
-if ( !jQuery.support.changeBubbles ) {
-
-	var changeFilters,
-
-	getVal = function( elem ) {
-		var type = jQuery.nodeName( elem, "input" ) ? elem.type : "",
-			val = elem.value;
-
-		if ( type === "radio" || type === "checkbox" ) {
-			val = elem.checked;
-
-		} else if ( type === "select-multiple" ) {
-			val = elem.selectedIndex > -1 ?
-				jQuery.map( elem.options, function( elem ) {
-					return elem.selected;
-				}).join("-") :
-				"";
-
-		} else if ( jQuery.nodeName( elem, "select" ) ) {
-			val = elem.selectedIndex;
-		}
-
-		return val;
-	},
-
-	testChange = function testChange( e ) {
-		var elem = e.target, data, val;
-
-		if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
-			return;
-		}
-
-		data = jQuery._data( elem, "_change_data" );
-		val = getVal(elem);
-
-		// the current data will be also retrieved by beforeactivate
-		if ( e.type !== "focusout" || elem.type !== "radio" ) {
-			jQuery._data( elem, "_change_data", val );
-		}
-
-		if ( data === undefined || val === data ) {
-			return;
-		}
-
-		if ( data != null || val ) {
-			e.type = "change";
-			e.liveFired = undefined;
-			jQuery.event.trigger( e, arguments[1], elem );
-		}
-	};
-
-	jQuery.event.special.change = {
-		filters: {
-			focusout: testChange,
-
-			beforedeactivate: testChange,
-
-			click: function( e ) {
-				var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
-
-				if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
-					testChange.call( this, e );
-				}
-			},
-
-			// Change has to be called before submit
-			// Keydown will be called before keypress, which is used in submit-event delegation
-			keydown: function( e ) {
-				var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
-
-				if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
-					(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
-					type === "select-multiple" ) {
-					testChange.call( this, e );
-				}
-			},
-
-			// Beforeactivate happens also before the previous element is blurred
-			// with this event you can't trigger a change event, but you can store
-			// information
-			beforeactivate: function( e ) {
-				var elem = e.target;
-				jQuery._data( elem, "_change_data", getVal(elem) );
-			}
-		},
-
-		setup: function( data, namespaces ) {
-			if ( this.type === "file" ) {
-				return false;
-			}
-
-			for ( var type in changeFilters ) {
-				jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
-			}
-
-			return rformElems.test( this.nodeName );
-		},
-
-		teardown: function( namespaces ) {
-			jQuery.event.remove( this, ".specialChange" );
-
-			return rformElems.test( this.nodeName );
-		}
-	};
-
-	changeFilters = jQuery.event.special.change.filters;
-
-	// Handle when the input is .focus()'d
-	changeFilters.focus = changeFilters.beforeactivate;
-}
-
-function trigger( type, elem, args ) {
-	// Piggyback on a donor event to simulate a different one.
-	// Fake originalEvent to avoid donor's stopPropagation, but if the
-	// simulated event prevents default then we do the same on the donor.
-	// Don't pass args or remember liveFired; they apply to the donor event.
-	var event = jQuery.extend( {}, args[ 0 ] );
-	event.type = type;
-	event.originalEvent = {};
-	event.liveFired = undefined;
-	jQuery.event.handle.call( elem, event );
-	if ( event.isDefaultPrevented() ) {
-		args[ 0 ].preventDefault();
-	}
-}
-
-// Create "bubbling" focus and blur events
-if ( !jQuery.support.focusinBubbles ) {
-	jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
-
-		// Attach a single capturing handler while someone wants focusin/focusout
-		var attaches = 0;
-
-		jQuery.event.special[ fix ] = {
-			setup: function() {
-				if ( attaches++ === 0 ) {
-					document.addEventListener( orig, handler, true );
-				}
-			},
-			teardown: function() {
-				if ( --attaches === 0 ) {
-					document.removeEventListener( orig, handler, true );
-				}
-			}
-		};
-
-		function handler( donor ) {
-			// Donor event is always a native one; fix it and switch its type.
-			// Let focusin/out handler cancel the donor focus/blur event.
-			var e = jQuery.event.fix( donor );
-			e.type = fix;
-			e.originalEvent = {};
-			jQuery.event.trigger( e, null, e.target );
-			if ( e.isDefaultPrevented() ) {
-				donor.preventDefault();
-			}
-		}
-	});
-}
-
-jQuery.each(["bind", "one"], function( i, name ) {
-	jQuery.fn[ name ] = function( type, data, fn ) {
-		var handler;
-
-		// Handle object literals
-		if ( typeof type === "object" ) {
-			for ( var key in type ) {
-				this[ name ](key, data, type[key], fn);
-			}
-			return this;
-		}
-
-		if ( arguments.length === 2 || data === false ) {
-			fn = data;
-			data = undefined;
-		}
-
-		if ( name === "one" ) {
-			handler = function( event ) {
-				jQuery( this ).unbind( event, handler );
-				return fn.apply( this, arguments );
-			};
-			handler.guid = fn.guid || jQuery.guid++;
-		} else {
-			handler = fn;
-		}
-
-		if ( type === "unload" && name !== "one" ) {
-			this.one( type, data, fn );
-
-		} else {
-			for ( var i = 0, l = this.length; i < l; i++ ) {
-				jQuery.event.add( this[i], type, handler, data );
-			}
-		}
-
-		return this;
-	};
-});
-
-jQuery.fn.extend({
-	unbind: function( type, fn ) {
-		// Handle object literals
-		if ( typeof type === "object" && !type.preventDefault ) {
-			for ( var key in type ) {
-				this.unbind(key, type[key]);
-			}
-
-		} else {
-			for ( var i = 0, l = this.length; i < l; i++ ) {
-				jQuery.event.remove( this[i], type, fn );
-			}
-		}
-
-		return this;
-	},
-
-	delegate: function( selector, types, data, fn ) {
-		return this.live( types, data, fn, selector );
-	},
-
-	undelegate: function( selector, types, fn ) {
-		if ( arguments.length === 0 ) {
-			return this.unbind( "live" );
-
-		} else {
-			return this.die( types, null, fn, selector );
-		}
-	},
-
-	trigger: function( type, data ) {
-		return this.each(function() {
-			jQuery.event.trigger( type, data, this );
-		});
-	},
-
-	triggerHandler: function( type, data ) {
-		if ( this[0] ) {
-			return jQuery.event.trigger( type, data, this[0], true );
-		}
-	},
-
-	toggle: function( fn ) {
-		// Save reference to arguments for access in closure
-		var args = arguments,
-			guid = fn.guid || jQuery.guid++,
-			i = 0,
-			toggler = function( event ) {
-				// Figure out which function to execute
-				var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
-				jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
-
-				// Make sure that clicks stop
-				event.preventDefault();
-
-				// and execute the function
-				return args[ lastToggle ].apply( this, arguments ) || false;
-			};
-
-		// link all the functions, so any of them can unbind this click handler
-		toggler.guid = guid;
-		while ( i < args.length ) {
-			args[ i++ ].guid = guid;
-		}
-
-		return this.click( toggler );
-	},
-
-	hover: function( fnOver, fnOut ) {
-		return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
-	}
-});
-
-var liveMap = {
-	focus: "focusin",
-	blur: "focusout",
-	mouseenter: "mouseover",
-	mouseleave: "mouseout"
-};
-
-jQuery.each(["live", "die"], function( i, name ) {
-	jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
-		var type, i = 0, match, namespaces, preType,
-			selector = origSelector || this.selector,
-			context = origSelector ? this : jQuery( this.context );
-
-		if ( typeof types === "object" && !types.preventDefault ) {
-			for ( var key in types ) {
-				context[ name ]( key, data, types[key], selector );
-			}
-
-			return this;
-		}
-
-		if ( name === "die" && !types &&
-					origSelector && origSelector.charAt(0) === "." ) {
-
-			context.unbind( origSelector );
-
-			return this;
-		}
-
-		if ( data === false || jQuery.isFunction( data ) ) {
-			fn = data || returnFalse;
-			data = undefined;
-		}
-
-		types = (types || "").split(" ");
-
-		while ( (type = types[ i++ ]) != null ) {
-			match = rnamespaces.exec( type );
-			namespaces = "";
-
-			if ( match )  {
-				namespaces = match[0];
-				type = type.replace( rnamespaces, "" );
-			}
-
-			if ( type === "hover" ) {
-				types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
-				continue;
-			}
-
-			preType = type;
-
-			if ( liveMap[ type ] ) {
-				types.push( liveMap[ type ] + namespaces );
-				type = type + namespaces;
-
-			} else {
-				type = (liveMap[ type ] || type) + namespaces;
-			}
-
-			if ( name === "live" ) {
-				// bind live handler
-				for ( var j = 0, l = context.length; j < l; j++ ) {
-					jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
-						{ data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
-				}
-
-			} else {
-				// unbind live handler
-				context.unbind( "live." + liveConvert( type, selector ), fn );
-			}
-		}
-
-		return this;
-	};
-});
-
-function liveHandler( event ) {
-	var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
-		elems = [],
-		selectors = [],
-		events = jQuery._data( this, "events" );
-
-	// Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
-	if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
-		return;
-	}
-
-	if ( event.namespace ) {
-		namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
-	}
-
-	event.liveFired = this;
-
-	var live = events.live.slice(0);
-
-	for ( j = 0; j < live.length; j++ ) {
-		handleObj = live[j];
-
-		if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
-			selectors.push( handleObj.selector );
-
-		} else {
-			live.splice( j--, 1 );
-		}
-	}
-
-	match = jQuery( event.target ).closest( selectors, event.currentTarget );
-
-	for ( i = 0, l = match.length; i < l; i++ ) {
-		close = match[i];
-
-		for ( j = 0; j < live.length; j++ ) {
-			handleObj = live[j];
-
-			if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
-				elem = close.elem;
-				related = null;
-
-				// Those two events require additional checking
-				if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
-					event.type = handleObj.preType;
-					related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
-
-					// Make sure not to accidentally match a child element with the same selector
-					if ( related && jQuery.contains( elem, related ) ) {
-						related = elem;
-					}
-				}
-
-				if ( !related || related !== elem ) {
-					elems.push({ elem: elem, handleObj: handleObj, level: close.level });
-				}
-			}
-		}
-	}
-
-	for ( i = 0, l = elems.length; i < l; i++ ) {
-		match = elems[i];
-
-		if ( maxLevel && match.level > maxLevel ) {
-			break;
-		}
-
-		event.currentTarget = match.elem;
-		event.data = match.handleObj.data;
-		event.handleObj = match.handleObj;
-
-		ret = match.handleObj.origHandler.apply( match.elem, arguments );
-
-		if ( ret === false || event.isPropagationStopped() ) {
-			maxLevel = match.level;
-
-			if ( ret === false ) {
-				stop = false;
-			}
-			if ( event.isImmediatePropagationStopped() ) {
-				break;
-			}
-		}
-	}
-
-	return stop;
-}
-
-function liveConvert( type, selector ) {
-	return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
-}
-
-jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
-	"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
-	"change select submit keydown keypress keyup error").split(" "), function( i, name ) {
-
-	// Handle event binding
-	jQuery.fn[ name ] = function( data, fn ) {
-		if ( fn == null ) {
-			fn = data;
-			data = null;
-		}
-
-		return arguments.length > 0 ?
-			this.bind( name, data, fn ) :
-			this.trigger( name );
-	};
-
-	if ( jQuery.attrFn ) {
-		jQuery.attrFn[ name ] = true;
-	}
-});
-
-
-
-/*!
- * Sizzle CSS Selector Engine
- *  Copyright 2011, The Dojo Foundation
- *  Released under the MIT, BSD, and GPL Licenses.
- *  More information: http://sizzlejs.com/
- */
-(function(){
-
-var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
-	done = 0,
-	toString = Object.prototype.toString,
-	hasDuplicate = false,
-	baseHasDuplicate = true,
-	rBackslash = /\\/g,
-	rNonWord = /\W/;
-
-// Here we check if the JavaScript engine is using some sort of
-// optimization where it does not always call our comparision
-// function. If that is the case, discard the hasDuplicate value.
-//   Thus far that includes Google Chrome.
-[0, 0].sort(function() {
-	baseHasDuplicate = false;
-	return 0;
-});
-
-var Sizzle = function( selector, context, results, seed ) {
-	results = results || [];
-	context = context || document;
-
-	var origContext = context;
-
-	if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
-		return [];
-	}
-	
-	if ( !selector || typeof selector !== "string" ) {
-		return results;
-	}
-
-	var m, set, checkSet, extra, ret, cur, pop, i,
-		prune = true,
-		contextXML = Sizzle.isXML( context ),
-		parts = [],
-		soFar = selector;
-	
-	// Reset the position of the chunker regexp (start from head)
-	do {
-		chunker.exec( "" );
-		m = chunker.exec( soFar );
-
-		if ( m ) {
-			soFar = m[3];
-		
-			parts.push( m[1] );
-		
-			if ( m[2] ) {
-				extra = m[3];
-				break;
-			}
-		}
-	} while ( m );
-
-	if ( parts.length > 1 && origPOS.exec( selector ) ) {
-
-		if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
-			set = posProcess( parts[0] + parts[1], context );
-
-		} else {
-			set = Expr.relative[ parts[0] ] ?
-				[ context ] :
-				Sizzle( parts.shift(), context );
-
-			while ( parts.length ) {
-				selector = parts.shift();
-
-				if ( Expr.relative[ selector ] ) {
-					selector += parts.shift();
-				}
-				
-				set = posProcess( selector, set );
-			}
-		}
-
-	} else {
-		// Take a shortcut and set the context if the root selector is an ID
-		// (but not if it'll be faster if the inner selector is an ID)
-		if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
-				Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
-
-			ret = Sizzle.find( parts.shift(), context, contextXML );
-			context = ret.expr ?
-				Sizzle.filter( ret.expr, ret.set )[0] :
-				ret.set[0];
-		}
-
-		if ( context ) {
-			ret = seed ?
-				{ expr: parts.pop(), set: makeArray(seed) } :
-				Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
-
-			set = ret.expr ?
-				Sizzle.filter( ret.expr, ret.set ) :
-				ret.set;
-
-			if ( parts.length > 0 ) {
-				checkSet = makeArray( set );
-
-			} else {
-				prune = false;
-			}
-
-			while ( parts.length ) {
-				cur = parts.pop();
-				pop = cur;
-
-				if ( !Expr.relative[ cur ] ) {
-					cur = "";
-				} else {
-					pop = parts.pop();
-				}
-
-				if ( pop == null ) {
-					pop = context;
-				}
-
-				Expr.relative[ cur ]( checkSet, pop, contextXML );
-			}
-
-		} else {
-			checkSet = parts = [];
-		}
-	}
-
-	if ( !checkSet ) {
-		checkSet = set;
-	}
-
-	if ( !checkSet ) {
-		Sizzle.error( cur || selector );
-	}
-
-	if ( toString.call(checkSet) === "[object Array]" ) {
-		if ( !prune ) {
-			results.push.apply( results, checkSet );
-
-		} else if ( context && context.nodeType === 1 ) {
-			for ( i = 0; checkSet[i] != null; i++ ) {
-				if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
-					results.push( set[i] );
-				}
-			}
-
-		} else {
-			for ( i = 0; checkSet[i] != null; i++ ) {
-				if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
-					results.push( set[i] );
-				}
-			}
-		}
-
-	} else {
-		makeArray( checkSet, results );
-	}
-
-	if ( extra ) {
-		Sizzle( extra, origContext, results, seed );
-		Sizzle.uniqueSort( results );
-	}
-
-	return results;
-};
-
-Sizzle.uniqueSort = function( results ) {
-	if ( sortOrder ) {
-		hasDuplicate = baseHasDuplicate;
-		results.sort( sortOrder );
-
-		if ( hasDuplicate ) {
-			for ( var i = 1; i < results.length; i++ ) {
-				if ( results[i] === results[ i - 1 ] ) {
-					results.splice( i--, 1 );
-				}
-			}
-		}
-	}
-
-	return results;
-};
-
-Sizzle.matches = function( expr, set ) {
-	return Sizzle( expr, null, null, set );
-};
-
-Sizzle.matchesSelector = function( node, expr ) {
-	return Sizzle( expr, null, null, [node] ).length > 0;
-};
-
-Sizzle.find = function( expr, context, isXML ) {
-	var set;
-
-	if ( !expr ) {
-		return [];
-	}
-
-	for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
-		var match,
-			type = Expr.order[i];
-		
-		if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
-			var left = match[1];
-			match.splice( 1, 1 );
-
-			if ( left.substr( left.length - 1 ) !== "\\" ) {
-				match[1] = (match[1] || "").replace( rBackslash, "" );
-				set = Expr.find[ type ]( match, context, isXML );
-
-				if ( set != null ) {
-					expr = expr.replace( Expr.match[ type ], "" );
-					break;
-				}
-			}
-		}
-	}
-
-	if ( !set ) {
-		set = typeof context.getElementsByTagName !== "undefined" ?
-			context.getElementsByTagName( "*" ) :
-			[];
-	}
-
-	return { set: set, expr: expr };
-};
-
-Sizzle.filter = function( expr, set, inplace, not ) {
-	var match, anyFound,
-		old = expr,
-		result = [],
-		curLoop = set,
-		isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
-
-	while ( expr && set.length ) {
-		for ( var type in Expr.filter ) {
-			if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
-				var found, item,
-					filter = Expr.filter[ type ],
-					left = match[1];
-
-				anyFound = false;
-
-				match.splice(1,1);
-
-				if ( left.substr( left.length - 1 ) === "\\" ) {
-					continue;
-				}
-
-				if ( curLoop === result ) {
-					result = [];
-				}
-
-				if ( Expr.preFilter[ type ] ) {
-					match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
-
-					if ( !match ) {
-						anyFound = found = true;
-
-					} else if ( match === true ) {
-						continue;
-					}
-				}
-
-				if ( match ) {
-					for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
-						if ( item ) {
-							found = filter( item, match, i, curLoop );
-							var pass = not ^ !!found;
-
-							if ( inplace && found != null ) {
-								if ( pass ) {
-									anyFound = true;
-
-								} else {
-									curLoop[i] = false;
-								}
-
-							} else if ( pass ) {
-								result.push( item );
-								anyFound = true;
-							}
-						}
-					}
-				}
-
-				if ( found !== undefined ) {
-					if ( !inplace ) {
-						curLoop = result;
-					}
-
-					expr = expr.replace( Expr.match[ type ], "" );
-
-					if ( !anyFound ) {
-						return [];
-					}
-
-					break;
-				}
-			}
-		}
-
-		// Improper expression
-		if ( expr === old ) {
-			if ( anyFound == null ) {
-				Sizzle.error( expr );
-
-			} else {
-				break;
-			}
-		}
-
-		old = expr;
-	}
-
-	return curLoop;
-};
-
-Sizzle.error = function( msg ) {
-	throw "Syntax error, unrecognized expression: " + msg;
-};
-
-var Expr = Sizzle.selectors = {
-	order: [ "ID", "NAME", "TAG" ],
-
-	match: {
-		ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
-		CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
-		NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
-		ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
-		TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
-		CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
-		POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
-		PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
-	},
-
-	leftMatch: {},
-
-	attrMap: {
-		"class": "className",
-		"for": "htmlFor"
-	},
-
-	attrHandle: {
-		href: function( elem ) {
-			return elem.getAttribute( "href" );
-		},
-		type: function( elem ) {
-			return elem.getAttribute( "type" );
-		}
-	},
-
-	relative: {
-		"+": function(checkSet, part){
-			var isPartStr = typeof part === "string",
-				isTag = isPartStr && !rNonWord.test( part ),
-				isPartStrNotTag = isPartStr && !isTag;
-
-			if ( isTag ) {
-				part = part.toLowerCase();
-			}
-
-			for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
-				if ( (elem = checkSet[i]) ) {
-					while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
-
-					checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
-						elem || false :
-						elem === part;
-				}
-			}
-
-			if ( isPartStrNotTag ) {
-				Sizzle.filter( part, checkSet, true );
-			}
-		},
-
-		">": function( checkSet, part ) {
-			var elem,
-				isPartStr = typeof part === "string",
-				i = 0,
-				l = checkSet.length;
-
-			if ( isPartStr && !rNonWord.test( part ) ) {
-				part = part.toLowerCase();
-
-				for ( ; i < l; i++ ) {
-					elem = checkSet[i];
-
-					if ( elem ) {
-						var parent = elem.parentNode;
-						checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
-					}
-				}
-
-			} else {
-				for ( ; i < l; i++ ) {
-					elem = checkSet[i];
-
-					if ( elem ) {
-						checkSet[i] = isPartStr ?
-							elem.parentNode :
-							elem.parentNode === part;
-					}
-				}
-
-				if ( isPartStr ) {
-					Sizzle.filter( part, checkSet, true );
-				}
-			}
-		},
-
-		"": function(checkSet, part, isXML){
-			var nodeCheck,
-				doneName = done++,
-				checkFn = dirCheck;
-
-			if ( typeof part === "string" && !rNonWord.test( part ) ) {
-				part = part.toLowerCase();
-				nodeCheck = part;
-				checkFn = dirNodeCheck;
-			}
-
-			checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
-		},
-
-		"~": function( checkSet, part, isXML ) {
-			var nodeCheck,
-				doneName = done++,
-				checkFn = dirCheck;
-
-			if ( typeof part === "string" && !rNonWord.test( part ) ) {
-				part = part.toLowerCase();
-				nodeCheck = part;
-				checkFn = dirNodeCheck;
-			}
-
-			checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
-		}
-	},
-
-	find: {
-		ID: function( match, context, isXML ) {
-			if ( typeof context.getElementById !== "undefined" && !isXML ) {
-				var m = context.getElementById(match[1]);
-				// Check parentNode to catch when Blackberry 4.6 returns
-				// nodes that are no longer in the document #6963
-				return m && m.parentNode ? [m] : [];
-			}
-		},
-
-		NAME: function( match, context ) {
-			if ( typeof context.getElementsByName !== "undefined" ) {
-				var ret = [],
-					results = context.getElementsByName( match[1] );
-
-				for ( var i = 0, l = results.length; i < l; i++ ) {
-					if ( results[i].getAttribute("name") === match[1] ) {
-						ret.push( results[i] );
-					}
-				}
-
-				return ret.length === 0 ? null : ret;
-			}
-		},
-
-		TAG: function( match, context ) {
-			if ( typeof context.getElementsByTagName !== "undefined" ) {
-				return context.getElementsByTagName( match[1] );
-			}
-		}
-	},
-	preFilter: {
-		CLASS: function( match, curLoop, inplace, result, not, isXML ) {
-			match = " " + match[1].replace( rBackslash, "" ) + " ";
-
-			if ( isXML ) {
-				return match;
-			}
-
-			for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
-				if ( elem ) {
-					if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
-						if ( !inplace ) {
-							result.push( elem );
-						}
-
-					} else if ( inplace ) {
-						curLoop[i] = false;
-					}
-				}
-			}
-
-			return false;
-		},
-
-		ID: function( match ) {
-			return match[1].replace( rBackslash, "" );
-		},
-
-		TAG: function( match, curLoop ) {
-			return match[1].replace( rBackslash, "" ).toLowerCase();
-		},
-
-		CHILD: function( match ) {
-			if ( match[1] === "nth" ) {
-				if ( !match[2] ) {
-					Sizzle.error( match[0] );
-				}
-
-				match[2] = match[2].replace(/^\+|\s*/g, '');
-
-				// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
-				var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
-					match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
-					!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
-
-				// calculate the numbers (first)n+(last) including if they are negative
-				match[2] = (test[1] + (test[2] || 1)) - 0;
-				match[3] = test[3] - 0;
-			}
-			else if ( match[2] ) {
-				Sizzle.error( match[0] );
-			}
-
-			// TODO: Move to normal caching system
-			match[0] = done++;
-
-			return match;
-		},
-
-		ATTR: function( match, curLoop, inplace, result, not, isXML ) {
-			var name = match[1] = match[1].replace( rBackslash, "" );
-			
-			if ( !isXML && Expr.attrMap[name] ) {
-				match[1] = Expr.attrMap[name];
-			}
-
-			// Handle if an un-quoted value was used
-			match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
-
-			if ( match[2] === "~=" ) {
-				match[4] = " " + match[4] + " ";
-			}
-
-			return match;
-		},
-
-		PSEUDO: function( match, curLoop, inplace, result, not ) {
-			if ( match[1] === "not" ) {
-				// If we're dealing with a complex expression, or a simple one
-				if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
-					match[3] = Sizzle(match[3], null, null, curLoop);
-
-				} else {
-					var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
-
-					if ( !inplace ) {
-						result.push.apply( result, ret );
-					}
-
-					return false;
-				}
-
-			} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
-				return true;
-			}
-			
-			return match;
-		},
-
-		POS: function( match ) {
-			match.unshift( true );
-
-			return match;
-		}
-	},
-	
-	filters: {
-		enabled: function( elem ) {
-			return elem.disabled === false && elem.type !== "hidden";
-		},
-
-		disabled: function( elem ) {
-			return elem.disabled === true;
-		},
-
-		checked: function( elem ) {
-			return elem.checked === true;
-		},
-		
-		selected: function( elem ) {
-			// Accessing this property makes selected-by-default
-			// options in Safari work properly
-			if ( elem.parentNode ) {
-				elem.parentNode.selectedIndex;
-			}
-			
-			return elem.selected === true;
-		},
-
-		parent: function( elem ) {
-			return !!elem.firstChild;
-		},
-
-		empty: function( elem ) {
-			return !elem.firstChild;
-		},
-
-		has: function( elem, i, match ) {
-			return !!Sizzle( match[3], elem ).length;
-		},
-
-		header: function( elem ) {
-			return (/h\d/i).test( elem.nodeName );
-		},
-
-		text: function( elem ) {
-			var attr = elem.getAttribute( "type" ), type = elem.type;
-			// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) 
-			// use getAttribute instead to test this case
-			return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
-		},
-
-		radio: function( elem ) {
-			return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
-		},
-
-		checkbox: function( elem ) {
-			return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
-		},
-
-		file: function( elem ) {
-			return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
-		},
-
-		password: function( elem ) {
-			return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
-		},
-
-		submit: function( elem ) {
-			var name = elem.nodeName.toLowerCase();
-			return (name === "input" || name === "button") && "submit" === elem.type;
-		},
-
-		image: function( elem ) {
-			return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
-		},
-
-		reset: function( elem ) {
-			var name = elem.nodeName.toLowerCase();
-			return (name === "input" || name === "button") && "reset" === elem.type;
-		},
-
-		button: function( elem ) {
-			var name = elem.nodeName.toLowerCase();
-			return name === "input" && "button" === elem.type || name === "button";
-		},
-
-		input: function( elem ) {
-			return (/input|select|textarea|button/i).test( elem.nodeName );
-		},
-
-		focus: function( elem ) {
-			return elem === elem.ownerDocument.activeElement;
-		}
-	},
-	setFilters: {
-		first: function( elem, i ) {
-			return i === 0;
-		},
-
-		last: function( elem, i, match, array ) {
-			return i === array.length - 1;
-		},
-
-		even: function( elem, i ) {
-			return i % 2 === 0;
-		},
-
-		odd: function( elem, i ) {
-			return i % 2 === 1;
-		},
-
-		lt: function( elem, i, match ) {
-			return i < match[3] - 0;
-		},
-
-		gt: function( elem, i, match ) {
-			return i > match[3] - 0;
-		},
-
-		nth: function( elem, i, match ) {
-			return match[3] - 0 === i;
-		},
-
-		eq: function( elem, i, match ) {
-			return match[3] - 0 === i;
-		}
-	},
-	filter: {
-		PSEUDO: function( elem, match, i, array ) {
-			var name = match[1],
-				filter = Expr.filters[ name ];
-
-			if ( filter ) {
-				return filter( elem, i, match, array );
-
-			} else if ( name === "contains" ) {
-				return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
-
-			} else if ( name === "not" ) {
-				var not = match[3];
-
-				for ( var j = 0, l = not.length; j < l; j++ ) {
-					if ( not[j] === elem ) {
-						return false;
-					}
-				}
-
-				return true;
-
-			} else {
-				Sizzle.error( name );
-			}
-		},
-
-		CHILD: function( elem, match ) {
-			var type = match[1],
-				node = elem;
-
-			switch ( type ) {
-				case "only":
-				case "first":
-					while ( (node = node.previousSibling) )	 {
-						if ( node.nodeType === 1 ) { 
-							return false; 
-						}
-					}
-
-					if ( type === "first" ) { 
-						return true; 
-					}
-
-					node = elem;
-
-				case "last":
-					while ( (node = node.nextSibling) )	 {
-						if ( node.nodeType === 1 ) { 
-							return false; 
-						}
-					}
-
-					return true;
-
-				case "nth":
-					var first = match[2],
-						last = match[3];
-
-					if ( first === 1 && last === 0 ) {
-						return true;
-					}
-					
-					var doneName = match[0],
-						parent = elem.parentNode;
-	
-					if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
-						var count = 0;
-						
-						for ( node = parent.firstChild; node; node = node.nextSibling ) {
-							if ( node.nodeType === 1 ) {
-								node.nodeIndex = ++count;
-							}
-						} 
-
-						parent.sizcache = doneName;
-					}
-					
-					var diff = elem.nodeIndex - last;
-
-					if ( first === 0 ) {
-						return diff === 0;
-
-					} else {
-						return ( diff % first === 0 && diff / first >= 0 );
-					}
-			}
-		},
-
-		ID: function( elem, match ) {
-			return elem.nodeType === 1 && elem.getAttribute("id") === match;
-		},
-
-		TAG: function( elem, match ) {
-			return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
-		},
-		
-		CLASS: function( elem, match ) {
-			return (" " + (elem.className || elem.getAttribute("class")) + " ")
-				.indexOf( match ) > -1;
-		},
-
-		ATTR: function( elem, match ) {
-			var name = match[1],
-				result = Expr.attrHandle[ name ] ?
-					Expr.attrHandle[ name ]( elem ) :
-					elem[ name ] != null ?
-						elem[ name ] :
-						elem.getAttribute( name ),
-				value = result + "",
-				type = match[2],
-				check = match[4];
-
-			return result == null ?
-				type === "!=" :
-				type === "=" ?
-				value === check :
-				type === "*=" ?
-				value.indexOf(check) >= 0 :
-				type === "~=" ?
-				(" " + value + " ").indexOf(check) >= 0 :
-				!check ?
-				value && result !== false :
-				type === "!=" ?
-				value !== check :
-				type === "^=" ?
-				value.indexOf(check) === 0 :
-				type === "$=" ?
-				value.substr(value.length - check.length) === check :
-				type === "|=" ?
-				value === check || value.substr(0, check.length + 1) === check + "-" :
-				false;
-		},
-
-		POS: function( elem, match, i, array ) {
-			var name = match[2],
-				filter = Expr.setFilters[ name ];
-
-			if ( filter ) {
-				return filter( elem, i, match, array );
-			}
-		}
-	}
-};
-
-var origPOS = Expr.match.POS,
-	fescape = function(all, num){
-		return "\\" + (num - 0 + 1);
-	};
-
-for ( var type in Expr.match ) {
-	Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
-	Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
-}
-
-var makeArray = function( array, results ) {
-	array = Array.prototype.slice.call( array, 0 );
-
-	if ( results ) {
-		results.push.apply( results, array );
-		return results;
-	}
-	
-	return array;
-};
-
-// Perform a simple check to determine if the browser is capable of
-// converting a NodeList to an array using builtin methods.
-// Also verifies that the returned array holds DOM nodes
-// (which is not the case in the Blackberry browser)
-try {
-	Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
-
-// Provide a fallback method if it does not work
-} catch( e ) {
-	makeArray = function( array, results ) {
-		var i = 0,
-			ret = results || [];
-
-		if ( toString.call(array) === "[object Array]" ) {
-			Array.prototype.push.apply( ret, array );
-
-		} else {
-			if ( typeof array.length === "number" ) {
-				for ( var l = array.length; i < l; i++ ) {
-					ret.push( array[i] );
-				}
-
-			} else {
-				for ( ; array[i]; i++ ) {
-					ret.push( array[i] );
-				}
-			}
-		}
-
-		return ret;
-	};
-}
-
-var sortOrder, siblingCheck;
-
-if ( document.documentElement.compareDocumentPosition ) {
-	sortOrder = function( a, b ) {
-		if ( a === b ) {
-			hasDuplicate = true;
-			return 0;
-		}
-
-		if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
-			return a.compareDocumentPosition ? -1 : 1;
-		}
-
-		return a.compareDocumentPosition(b) & 4 ? -1 : 1;
-	};
-
-} else {
-	sortOrder = function( a, b ) {
-		// The nodes are identical, we can exit early
-		if ( a === b ) {
-			hasDuplicate = true;
-			return 0;
-
-		// Fallback to using sourceIndex (in IE) if it's available on both nodes
-		} else if ( a.sourceIndex && b.sourceIndex ) {
-			return a.sourceIndex - b.sourceIndex;
-		}
-
-		var al, bl,
-			ap = [],
-			bp = [],
-			aup = a.parentNode,
-			bup = b.parentNode,
-			cur = aup;
-
-		// If the nodes are siblings (or identical) we can do a quick check
-		if ( aup === bup ) {
-			return siblingCheck( a, b );
-
-		// If no parents were found then the nodes are disconnected
-		} else if ( !aup ) {
-			return -1;
-
-		} else if ( !bup ) {
-			return 1;
-		}
-
-		// Otherwise they're somewhere else in the tree so we need
-		// to build up a full list of the parentNodes for comparison
-		while ( cur ) {
-			ap.unshift( cur );
-			cur = cur.parentNode;
-		}
-
-		cur = bup;
-
-		while ( cur ) {
-			bp.unshift( cur );
-			cur = cur.parentNode;
-		}
-
-		al = ap.length;
-		bl = bp.length;
-
-		// Start walking down the tree looking for a discrepancy
-		for ( var i = 0; i < al && i < bl; i++ ) {
-			if ( ap[i] !== bp[i] ) {
-				return siblingCheck( ap[i], bp[i] );
-			}
-		}
-
-		// We ended someplace up the tree so do a sibling check
-		return i === al ?
-			siblingCheck( a, bp[i], -1 ) :
-			siblingCheck( ap[i], b, 1 );
-	};
-
-	siblingCheck = function( a, b, ret ) {
-		if ( a === b ) {
-			return ret;
-		}
-
-		var cur = a.nextSibling;
-
-		while ( cur ) {
-			if ( cur === b ) {
-				return -1;
-			}
-
-			cur = cur.nextSibling;
-		}
-
-		return 1;
-	};
-}
-
-// Utility function for retreiving the text value of an array of DOM nodes
-Sizzle.getText = function( elems ) {
-	var ret = "", elem;
-
-	for ( var i = 0; elems[i]; i++ ) {
-		elem = elems[i];
-
-		// Get the text from text nodes and CDATA nodes
-		if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
-			ret += elem.nodeValue;
-
-		// Traverse everything else, except comment nodes
-		} else if ( elem.nodeType !== 8 ) {
-			ret += Sizzle.getText( elem.childNodes );
-		}
-	}
-
-	return ret;
-};
-
-// Check to see if the browser returns elements by name when
-// querying by getElementById (and provide a workaround)
-(function(){
-	// We're going to inject a fake input element with a specified name
-	var form = document.createElement("div"),
-		id = "script" + (new Date()).getTime(),
-		root = document.documentElement;
-
-	form.innerHTML = "<a name='" + id + "'/>";
-
-	// Inject it into the root element, check its status, and remove it quickly
-	root.insertBefore( form, root.firstChild );
-
-	// The workaround has to do additional checks after a getElementById
-	// Which slows things down for other browsers (hence the branching)
-	if ( document.getElementById( id ) ) {
-		Expr.find.ID = function( match, context, isXML ) {
-			if ( typeof context.getElementById !== "undefined" && !isXML ) {
-				var m = context.getElementById(match[1]);
-
-				return m ?
-					m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
-						[m] :
-						undefined :
-					[];
-			}
-		};
-
-		Expr.filter.ID = function( elem, match ) {
-			var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
-
-			return elem.nodeType === 1 && node && node.nodeValue === match;
-		};
-	}
-
-	root.removeChild( form );
-
-	// release memory in IE
-	root = form = null;
-})();
-
-(function(){
-	// Check to see if the browser returns only elements
-	// when doing getElementsByTagName("*")
-
-	// Create a fake element
-	var div = document.createElement("div");
-	div.appendChild( document.createComment("") );
-
-	// Make sure no comments are found
-	if ( div.getElementsByTagName("*").length > 0 ) {
-		Expr.find.TAG = function( match, context ) {
-			var results = context.getElementsByTagName( match[1] );
-
-			// Filter out possible comments
-			if ( match[1] === "*" ) {
-				var tmp = [];
-
-				for ( var i = 0; results[i]; i++ ) {
-					if ( results[i].nodeType === 1 ) {
-						tmp.push( results[i] );
-					}
-				}
-
-				results = tmp;
-			}
-
-			return results;
-		};
-	}
-
-	// Check to see if an attribute returns normalized href attributes
-	div.innerHTML = "<a href='#'></a>";
-
-	if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
-			div.firstChild.getAttribute("href") !== "#" ) {
-
-		Expr.attrHandle.href = function( elem ) {
-			return elem.getAttribute( "href", 2 );
-		};
-	}
-
-	// release memory in IE
-	div = null;
-})();
-
-if ( document.querySelectorAll ) {
-	(function(){
-		var oldSizzle = Sizzle,
-			div = document.createElement("div"),
-			id = "__sizzle__";
-
-		div.innerHTML = "<p class='TEST'></p>";
-
-		// Safari can't handle uppercase or unicode characters when
-		// in quirks mode.
-		if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
-			return;
-		}
-	
-		Sizzle = function( query, context, extra, seed ) {
-			context = context || document;
-
-			// Only use querySelectorAll on non-XML documents
-			// (ID selectors don't work in non-HTML documents)
-			if ( !seed && !Sizzle.isXML(context) ) {
-				// See if we find a selector to speed up
-				var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
-				
-				if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
-					// Speed-up: Sizzle("TAG")
-					if ( match[1] ) {
-						return makeArray( context.getElementsByTagName( query ), extra );
-					
-					// Speed-up: Sizzle(".CLASS")
-					} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
-						return makeArray( context.getElementsByClassName( match[2] ), extra );
-					}
-				}
-				
-				if ( context.nodeType === 9 ) {
-					// Speed-up: Sizzle("body")
-					// The body element only exists once, optimize finding it
-					if ( query === "body" && context.body ) {
-						return makeArray( [ context.body ], extra );
-						
-					// Speed-up: Sizzle("#ID")
-					} else if ( match && match[3] ) {
-						var elem = context.getElementById( match[3] );
-
-						// Check parentNode to catch when Blackberry 4.6 returns
-						// nodes that are no longer in the document #6963
-						if ( elem && elem.parentNode ) {
-							// Handle the case where IE and Opera return items
-							// by name instead of ID
-							if ( elem.id === match[3] ) {
-								return makeArray( [ elem ], extra );
-							}
-							
-						} else {
-							return makeArray( [], extra );
-						}
-					}
-					
-					try {
-						return makeArray( context.querySelectorAll(query), extra );
-					} catch(qsaError) {}
-
-				// qSA works strangely on Element-rooted queries
-				// We can work around this by specifying an extra ID on the root
-				// and working up from there (Thanks to Andrew Dupont for the technique)
-				// IE 8 doesn't work on object elements
-				} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
-					var oldContext = context,
-						old = context.getAttribute( "id" ),
-						nid = old || id,
-						hasParent = context.parentNode,
-						relativeHierarchySelector = /^\s*[+~]/.test( query );
-
-					if ( !old ) {
-						context.setAttribute( "id", nid );
-					} else {
-						nid = nid.replace( /'/g, "\\$&" );
-					}
-					if ( relativeHierarchySelector && hasParent ) {
-						context = context.parentNode;
-					}
-
-					try {
-						if ( !relativeHierarchySelector || hasParent ) {
-							return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
-						}
-
-					} catch(pseudoError) {
-					} finally {
-						if ( !old ) {
-							oldContext.removeAttribute( "id" );
-						}
-					}
-				}
-			}
-		
-			return oldSizzle(query, context, extra, seed);
-		};
-
-		for ( var prop in oldSizzle ) {
-			Sizzle[ prop ] = oldSizzle[ prop ];
-		}
-
-		// release memory in IE
-		div = null;
-	})();
-}
-
-(function(){
-	var html = document.documentElement,
-		matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
-
-	if ( matches ) {
-		// Check to see if it's possible to do matchesSelector
-		// on a disconnected node (IE 9 fails this)
-		var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
-			pseudoWorks = false;
-
-		try {
-			// This should fail with an exception
-			// Gecko does not error, returns false instead
-			matches.call( document.documentElement, "[test!='']:sizzle" );
-	
-		} catch( pseudoError ) {
-			pseudoWorks = true;
-		}
-
-		Sizzle.matchesSelector = function( node, expr ) {
-			// Make sure that attribute selectors are quoted
-			expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
-
-			if ( !Sizzle.isXML( node ) ) {
-				try { 
-					if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
-						var ret = matches.call( node, expr );
-
-						// IE 9's matchesSelector returns false on disconnected nodes
-						if ( ret || !disconnectedMatch ||
-								// As well, disconnected nodes are said to be in a document
-								// fragment in IE 9, so check for that
-								node.document && node.document.nodeType !== 11 ) {
-							return ret;
-						}
-					}
-				} catch(e) {}
-			}
-
-			return Sizzle(expr, null, null, [node]).length > 0;
-		};
-	}
-})();
-
-(function(){
-	var div = document.createElement("div");
-
-	div.innerHTML = "<div class='test e'></div><div class='test'></div>";
-
-	// Opera can't find a second classname (in 9.6)
-	// Also, make sure that getElementsByClassName actually exists
-	if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
-		return;
-	}
-
-	// Safari caches class attributes, doesn't catch changes (in 3.2)
-	div.lastChild.className = "e";
-
-	if ( div.getElementsByClassName("e").length === 1 ) {
-		return;
-	}
-	
-	Expr.order.splice(1, 0, "CLASS");
-	Expr.find.CLASS = function( match, context, isXML ) {
-		if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
-			return context.getElementsByClassName(match[1]);
-		}
-	};
-
-	// release memory in IE
-	div = null;
-})();
-
-function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
-	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
-		var elem = checkSet[i];
-
-		if ( elem ) {
-			var match = false;
-
-			elem = elem[dir];
-
-			while ( elem ) {
-				if ( elem.sizcache === doneName ) {
-					match = checkSet[elem.sizset];
-					break;
-				}
-
-				if ( elem.nodeType === 1 && !isXML ){
-					elem.sizcache = doneName;
-					elem.sizset = i;
-				}
-
-				if ( elem.nodeName.toLowerCase() === cur ) {
-					match = elem;
-					break;
-				}
-
-				elem = elem[dir];
-			}
-
-			checkSet[i] = match;
-		}
-	}
-}
-
-function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
-	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
-		var elem = checkSet[i];
-
-		if ( elem ) {
-			var match = false;
-			
-			elem = elem[dir];
-
-			while ( elem ) {
-				if ( elem.sizcache === doneName ) {
-					match = checkSet[elem.sizset];
-					break;
-				}
-
-				if ( elem.nodeType === 1 ) {
-					if ( !isXML ) {
-						elem.sizcache = doneName;
-						elem.sizset = i;
-					}
-
-					if ( typeof cur !== "string" ) {
-						if ( elem === cur ) {
-							match = true;
-							break;
-						}
-
-					} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
-						match = elem;
-						break;
-					}
-				}
-
-				elem = elem[dir];
-			}
-
-			checkSet[i] = match;
-		}
-	}
-}
-
-if ( document.documentElement.contains ) {
-	Sizzle.contains = function( a, b ) {
-		return a !== b && (a.contains ? a.contains(b) : true);
-	};
-
-} else if ( document.documentElement.compareDocumentPosition ) {
-	Sizzle.contains = function( a, b ) {
-		return !!(a.compareDocumentPosition(b) & 16);
-	};
-
-} else {
-	Sizzle.contains = function() {
-		return false;
-	};
-}
-
-Sizzle.isXML = function( elem ) {
-	// documentElement is verified for cases where it doesn't yet exist
-	// (such as loading iframes in IE - #4833) 
-	var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
-
-	return documentElement ? documentElement.nodeName !== "HTML" : false;
-};
-
-var posProcess = function( selector, context ) {
-	var match,
-		tmpSet = [],
-		later = "",
-		root = context.nodeType ? [context] : context;
-
-	// Position selectors must be done after the filter
-	// And so must :not(positional) so we move all PSEUDOs to the end
-	while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
-		later += match[0];
-		selector = selector.replace( Expr.match.PSEUDO, "" );
-	}
-
-	selector = Expr.relative[selector] ? selector + "*" : selector;
-
-	for ( var i = 0, l = root.length; i < l; i++ ) {
-		Sizzle( selector, root[i], tmpSet );
-	}
-
-	return Sizzle.filter( later, tmpSet );
-};
-
-// EXPOSE
-jQuery.find = Sizzle;
-jQuery.expr = Sizzle.selectors;
-jQuery.expr[":"] = jQuery.expr.filters;
-jQuery.unique = Sizzle.uniqueSort;
-jQuery.text = Sizzle.getText;
-jQuery.isXMLDoc = Sizzle.isXML;
-jQuery.contains = Sizzle.contains;
-
-
-})();
-
-
-var runtil = /Until$/,
-	rparentsprev = /^(?:parents|prevUntil|prevAll)/,
-	// Note: This RegExp should be improved, or likely pulled from Sizzle
-	rmultiselector = /,/,
-	isSimple = /^.[^:#\[\.,]*$/,
-	slice = Array.prototype.slice,
-	POS = jQuery.expr.match.POS,
-	// methods guaranteed to produce a unique set when starting from a unique set
-	guaranteedUnique = {
-		children: true,
-		contents: true,
-		next: true,
-		prev: true
-	};
-
-jQuery.fn.extend({
-	find: function( selector ) {
-		var self = this,
-			i, l;
-
-		if ( typeof selector !== "string" ) {
-			return jQuery( selector ).filter(function() {
-				for ( i = 0, l = self.length; i < l; i++ ) {
-					if ( jQuery.contains( self[ i ], this ) ) {
-						return true;
-					}
-				}
-			});
-		}
-
-		var ret = this.pushStack( "", "find", selector ),
-			length, n, r;
-
-		for ( i = 0, l = this.length; i < l; i++ ) {
-			length = ret.length;
-			jQuery.find( selector, this[i], ret );
-
-			if ( i > 0 ) {
-				// Make sure that the results are unique
-				for ( n = length; n < ret.length; n++ ) {
-					for ( r = 0; r < length; r++ ) {
-						if ( ret[r] === ret[n] ) {
-							ret.splice(n--, 1);
-							break;
-						}
-					}
-				}
-			}
-		}
-
-		return ret;
-	},
-
-	has: function( target ) {
-		var targets = jQuery( target );
-		return this.filter(function() {
-			for ( var i = 0, l = targets.length; i < l; i++ ) {
-				if ( jQuery.contains( this, targets[i] ) ) {
-					return true;
-				}
-			}
-		});
-	},
-
-	not: function( selector ) {
-		return this.pushStack( winnow(this, selector, false), "not", selector);
-	},
-
-	filter: function( selector ) {
-		return this.pushStack( winnow(this, selector, true), "filter", selector );
-	},
-
-	is: function( selector ) {
-		return !!selector && ( typeof selector === "string" ?
-			jQuery.filter( selector, this ).length > 0 :
-			this.filter( selector ).length > 0 );
-	},
-
-	closest: function( selectors, context ) {
-		var ret = [], i, l, cur = this[0];
-		
-		// Array
-		if ( jQuery.isArray( selectors ) ) {
-			var match, selector,
-				matches = {},
-				level = 1;
-
-			if ( cur && selectors.length ) {
-				for ( i = 0, l = selectors.length; i < l; i++ ) {
-					selector = selectors[i];
-
-					if ( !matches[ selector ] ) {
-						matches[ selector ] = POS.test( selector ) ?
-							jQuery( selector, context || this.context ) :
-							selector;
-					}
-				}
-
-				while ( cur && cur.ownerDocument && cur !== context ) {
-					for ( selector in matches ) {
-						match = matches[ selector ];
-
-						if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
-							ret.push({ selector: selector, elem: cur, level: level });
-						}
-					}
-
-					cur = cur.parentNode;
-					level++;
-				}
-			}
-
-			return ret;
-		}
-
-		// String
-		var pos = POS.test( selectors ) || typeof selectors !== "string" ?
-				jQuery( selectors, context || this.context ) :
-				0;
-
-		for ( i = 0, l = this.length; i < l; i++ ) {
-			cur = this[i];
-
-			while ( cur ) {
-				if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
-					ret.push( cur );
-					break;
-
-				} else {
-					cur = cur.parentNode;
-					if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
-						break;
-					}
-				}
-			}
-		}
-
-		ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
-
-		return this.pushStack( ret, "closest", selectors );
-	},
-
-	// Determine the position of an element within
-	// the matched set of elements
-	index: function( elem ) {
-
-		// No argument, return index in parent
-		if ( !elem ) {
-			return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
-		}
-
-		// index in selector
-		if ( typeof elem === "string" ) {
-			return jQuery.inArray( this[0], jQuery( elem ) );
-		}
-
-		// Locate the position of the desired element
-		return jQuery.inArray(
-			// If it receives a jQuery object, the first element is used
-			elem.jquery ? elem[0] : elem, this );
-	},
-
-	add: function( selector, context ) {
-		var set = typeof selector === "string" ?
-				jQuery( selector, context ) :
-				jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
-			all = jQuery.merge( this.get(), set );
-
-		return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
-			all :
-			jQuery.unique( all ) );
-	},
-
-	andSelf: function() {
-		return this.add( this.prevObject );
-	}
-});
-
-// A painfully simple check to see if an element is disconnected
-// from a document (should be improved, where feasible).
-function isDisconnected( node ) {
-	return !node || !node.parentNode || node.parentNode.nodeType === 11;
-}
-
-jQuery.each({
-	parent: function( elem ) {
-		var parent = elem.parentNode;
-		return parent && parent.nodeType !== 11 ? parent : null;
-	},
-	parents: function( elem ) {
-		return jQuery.dir( elem, "parentNode" );
-	},
-	parentsUntil: function( elem, i, until ) {
-		return jQuery.dir( elem, "parentNode", until );
-	},
-	next: function( elem ) {
-		return jQuery.nth( elem, 2, "nextSibling" );
-	},
-	prev: function( elem ) {
-		return jQuery.nth( elem, 2, "previousSibling" );
-	},
-	nextAll: function( elem ) {
-		return jQuery.dir( elem, "nextSibling" );
-	},
-	prevAll: function( elem ) {
-		return jQuery.dir( elem, "previousSibling" );
-	},
-	nextUntil: function( elem, i, until ) {
-		return jQuery.dir( elem, "nextSibling", until );
-	},
-	prevUntil: function( elem, i, until ) {
-		return jQuery.dir( elem, "previousSibling", until );
-	},
-	siblings: function( elem ) {
-		return jQuery.sibling( elem.parentNode.firstChild, elem );
-	},
-	children: function( elem ) {
-		return jQuery.sibling( elem.firstChild );
-	},
-	contents: function( elem ) {
-		return jQuery.nodeName( elem, "iframe" ) ?
-			elem.contentDocument || elem.contentWindow.document :
-			jQuery.makeArray( elem.childNodes );
-	}
-}, function( name, fn ) {
-	jQuery.fn[ name ] = function( until, selector ) {
-		var ret = jQuery.map( this, fn, until ),
-			// The variable 'args' was introduced in
-			// https://github.com/jquery/jquery/commit/52a0238
-			// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
-			// http://code.google.com/p/v8/issues/detail?id=1050
-			args = slice.call(arguments);
-
-		if ( !runtil.test( name ) ) {
-			selector = until;
-		}
-
-		if ( selector && typeof selector === "string" ) {
-			ret = jQuery.filter( selector, ret );
-		}
-
-		ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
-
-		if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
-			ret = ret.reverse();
-		}
-
-		return this.pushStack( ret, name, args.join(",") );
-	};
-});
-
-jQuery.extend({
-	filter: function( expr, elems, not ) {
-		if ( not ) {
-			expr = ":not(" + expr + ")";
-		}
-
-		return elems.length === 1 ?
-			jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
-			jQuery.find.matches(expr, elems);
-	},
-
-	dir: function( elem, dir, until ) {
-		var matched = [],
-			cur = elem[ dir ];
-
-		while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
-			if ( cur.nodeType === 1 ) {
-				matched.push( cur );
-			}
-			cur = cur[dir];
-		}
-		return matched;
-	},
-
-	nth: function( cur, result, dir, elem ) {
-		result = result || 1;
-		var num = 0;
-
-		for ( ; cur; cur = cur[dir] ) {
-			if ( cur.nodeType === 1 && ++num === result ) {
-				break;
-			}
-		}
-
-		return cur;
-	},
-
-	sibling: function( n, elem ) {
-		var r = [];
-
-		for ( ; n; n = n.nextSibling ) {
-			if ( n.nodeType === 1 && n !== elem ) {
-				r.push( n );
-			}
-		}
-
-		return r;
-	}
-});
-
-// Implement the identical functionality for filter and not
-function winnow( elements, qualifier, keep ) {
-
-	// Can't pass null or undefined to indexOf in Firefox 4
-	// Set to 0 to skip string check
-	qualifier = qualifier || 0;
-
-	if ( jQuery.isFunction( qualifier ) ) {
-		return jQuery.grep(elements, function( elem, i ) {
-			var retVal = !!qualifier.call( elem, i, elem );
-			return retVal === keep;
-		});
-
-	} else if ( qualifier.nodeType ) {
-		return jQuery.grep(elements, function( elem, i ) {
-			return (elem === qualifier) === keep;
-		});
-
-	} else if ( typeof qualifier === "string" ) {
-		var filtered = jQuery.grep(elements, function( elem ) {
-			return elem.nodeType === 1;
-		});
-
-		if ( isSimple.test( qualifier ) ) {
-			return jQuery.filter(qualifier, filtered, !keep);
-		} else {
-			qualifier = jQuery.filter( qualifier, filtered );
-		}
-	}
-
-	return jQuery.grep(elements, function( elem, i ) {
-		return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
-	});
-}
-
-
-
-
-var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
-	rleadingWhitespace = /^\s+/,
-	rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
-	rtagName = /<([\w:]+)/,
-	rtbody = /<tbody/i,
-	rhtml = /<|&#?\w+;/,
-	rnocache = /<(?:script|object|embed|option|style)/i,
-	// checked="checked" or checked
-	rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
-	rscriptType = /\/(java|ecma)script/i,
-	rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
-	wrapMap = {
-		option: [ 1, "<select multiple='multiple'>", "</select>" ],
-		legend: [ 1, "<fieldset>", "</fieldset>" ],
-		thead: [ 1, "<table>", "</table>" ],
-		tr: [ 2, "<table><tbody>", "</tbody></table>" ],
-		td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
-		col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
-		area: [ 1, "<map>", "</map>" ],
-		_default: [ 0, "", "" ]
-	};
-
-wrapMap.optgroup = wrapMap.option;
-wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
-wrapMap.th = wrapMap.td;
-
-// IE can't serialize <link> and <script> tags normally
-if ( !jQuery.support.htmlSerialize ) {
-	wrapMap._default = [ 1, "div<div>", "</div>" ];
-}
-
-jQuery.fn.extend({
-	text: function( text ) {
-		if ( jQuery.isFunction(text) ) {
-			return this.each(function(i) {
-				var self = jQuery( this );
-
-				self.text( text.call(this, i, self.text()) );
-			});
-		}
-
-		if ( typeof text !== "object" && text !== undefined ) {
-			return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
-		}
-
-		return jQuery.text( this );
-	},
-
-	wrapAll: function( html ) {
-		if ( jQuery.isFunction( html ) ) {
-			return this.each(function(i) {
-				jQuery(this).wrapAll( html.call(this, i) );
-			});
-		}
-
-		if ( this[0] ) {
-			// The elements to wrap the target around
-			var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
-
-			if ( this[0].parentNode ) {
-				wrap.insertBefore( this[0] );
-			}
-
-			wrap.map(function() {
-				var elem = this;
-
-				while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
-					elem = elem.firstChild;
-				}
-
-				return elem;
-			}).append( this );
-		}
-
-		return this;
-	},
-
-	wrapInner: function( html ) {
-		if ( jQuery.isFunction( html ) ) {
-			return this.each(function(i) {
-				jQuery(this).wrapInner( html.call(this, i) );
-			});
-		}
-
-		return this.each(function() {
-			var self = jQuery( this ),
-				contents = self.contents();
-
-			if ( contents.length ) {
-				contents.wrapAll( html );
-
-			} else {
-				self.append( html );
-			}
-		});
-	},
-
-	wrap: function( html ) {
-		return this.each(function() {
-			jQuery( this ).wrapAll( html );
-		});
-	},
-
-	unwrap: function() {
-		return this.parent().each(function() {
-			if ( !jQuery.nodeName( this, "body" ) ) {
-				jQuery( this ).replaceWith( this.childNodes );
-			}
-		}).end();
-	},
-
-	append: function() {
-		return this.domManip(arguments, true, function( elem ) {
-			if ( this.nodeType === 1 ) {
-				this.appendChild( elem );
-			}
-		});
-	},
-
-	prepend: function() {
-		return this.domManip(arguments, true, function( elem ) {
-			if ( this.nodeType === 1 ) {
-				this.insertBefore( elem, this.firstChild );
-			}
-		});
-	},
-
-	before: function() {
-		if ( this[0] && this[0].parentNode ) {
-			return this.domManip(arguments, false, function( elem ) {
-				this.parentNode.insertBefore( elem, this );
-			});
-		} else if ( arguments.length ) {
-			var set = jQuery(arguments[0]);
-			set.push.apply( set, this.toArray() );
-			return this.pushStack( set, "before", arguments );
-		}
-	},
-
-	after: function() {
-		if ( this[0] && this[0].parentNode ) {
-			return this.domManip(arguments, false, function( elem ) {
-				this.parentNode.insertBefore( elem, this.nextSibling );
-			});
-		} else if ( arguments.length ) {
-			var set = this.pushStack( this, "after", arguments );
-			set.push.apply( set, jQuery(arguments[0]).toArray() );
-			return set;
-		}
-	},
-
-	// keepData is for internal use only--do not document
-	remove: function( selector, keepData ) {
-		for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
-			if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
-				if ( !keepData && elem.nodeType === 1 ) {
-					jQuery.cleanData( elem.getElementsByTagName("*") );
-					jQuery.cleanData( [ elem ] );
-				}
-
-				if ( elem.parentNode ) {
-					elem.parentNode.removeChild( elem );
-				}
-			}
-		}
-
-		return this;
-	},
-
-	empty: function() {
-		for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
-			// Remove element nodes and prevent memory leaks
-			if ( elem.nodeType === 1 ) {
-				jQuery.cleanData( elem.getElementsByTagName("*") );
-			}
-
-			// Remove any remaining nodes
-			while ( elem.firstChild ) {
-				elem.removeChild( elem.firstChild );
-			}
-		}
-
-		return this;
-	},
-
-	clone: function( dataAndEvents, deepDataAndEvents ) {
-		dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
-		deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
-
-		return this.map( function () {
-			return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
-		});
-	},
-
-	html: function( value ) {
-		if ( value === undefined ) {
-			return this[0] && this[0].nodeType === 1 ?
-				this[0].innerHTML.replace(rinlinejQuery, "") :
-				null;
-
-		// See if we can take a shortcut and just use innerHTML
-		} else if ( typeof value === "string" && !rnocache.test( value ) &&
-			(jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
-			!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
-
-			value = value.replace(rxhtmlTag, "<$1></$2>");
-
-			try {
-				for ( var i = 0, l = this.length; i < l; i++ ) {
-					// Remove element nodes and prevent memory leaks
-					if ( this[i].nodeType === 1 ) {
-						jQuery.cleanData( this[i].getElementsByTagName("*") );
-						this[i].innerHTML = value;
-					}
-				}
-
-			// If using innerHTML throws an exception, use the fallback method
-			} catch(e) {
-				this.empty().append( value );
-			}
-
-		} else if ( jQuery.isFunction( value ) ) {
-			this.each(function(i){
-				var self = jQuery( this );
-
-				self.html( value.call(this, i, self.html()) );
-			});
-
-		} else {
-			this.empty().append( value );
-		}
-
-		return this;
-	},
-
-	replaceWith: function( value ) {
-		if ( this[0] && this[0].parentNode ) {
-			// Make sure that the elements are removed from the DOM before they are inserted
-			// this can help fix replacing a parent with child elements
-			if ( jQuery.isFunction( value ) ) {
-				return this.each(function(i) {
-					var self = jQuery(this), old = self.html();
-					self.replaceWith( value.call( this, i, old ) );
-				});
-			}
-
-			if ( typeof value !== "string" ) {
-				value = jQuery( value ).detach();
-			}
-
-			return this.each(function() {
-				var next = this.nextSibling,
-					parent = this.parentNode;
-
-				jQuery( this ).remove();
-
-				if ( next ) {
-					jQuery(next).before( value );
-				} else {
-					jQuery(parent).append( value );
-				}
-			});
-		} else {
-			return this.length ?
-				this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
-				this;
-		}
-	},
-
-	detach: function( selector ) {
-		return this.remove( selector, true );
-	},
-
-	domManip: function( args, table, callback ) {
-		var results, first, fragment, parent,
-			value = args[0],
-			scripts = [];
-
-		// We can't cloneNode fragments that contain checked, in WebKit
-		if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
-			return this.each(function() {
-				jQuery(this).domManip( args, table, callback, true );
-			});
-		}
-
-		if ( jQuery.isFunction(value) ) {
-			return this.each(function(i) {
-				var self = jQuery(this);
-				args[0] = value.call(this, i, table ? self.html() : undefined);
-				self.domManip( args, table, callback );
-			});
-		}
-
-		if ( this[0] ) {
-			parent = value && value.parentNode;
-
-			// If we're in a fragment, just use that instead of building a new one
-			if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
-				results = { fragment: parent };
-
-			} else {
-				results = jQuery.buildFragment( args, this, scripts );
-			}
-
-			fragment = results.fragment;
-
-			if ( fragment.childNodes.length === 1 ) {
-				first = fragment = fragment.firstChild;
-			} else {
-				first = fragment.firstChild;
-			}
-
-			if ( first ) {
-				table = table && jQuery.nodeName( first, "tr" );
-
-				for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
-					callback.call(
-						table ?
-							root(this[i], first) :
-							this[i],
-						// Make sure that we do not leak memory by inadvertently discarding
-						// the original fragment (which might have attached data) instead of
-						// using it; in addition, use the original fragment object for the last
-						// item instead of first because it can end up being emptied incorrectly
-						// in certain situations (Bug #8070).
-						// Fragments from the fragment cache must always be cloned and never used
-						// in place.
-						results.cacheable || (l > 1 && i < lastIndex) ?
-							jQuery.clone( fragment, true, true ) :
-							fragment
-					);
-				}
-			}
-
-			if ( scripts.length ) {
-				jQuery.each( scripts, evalScript );
-			}
-		}
-
-		return this;
-	}
-});
-
-function root( elem, cur ) {
-	return jQuery.nodeName(elem, "table") ?
-		(elem.getElementsByTagName("tbody")[0] ||
-		elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
-		elem;
-}
-
-function cloneCopyEvent( src, dest ) {
-
-	if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
-		return;
-	}
-
-	var internalKey = jQuery.expando,
-		oldData = jQuery.data( src ),
-		curData = jQuery.data( dest, oldData );
-
-	// Switch to use the internal data object, if it exists, for the next
-	// stage of data copying
-	if ( (oldData = oldData[ internalKey ]) ) {
-		var events = oldData.events;
-				curData = curData[ internalKey ] = jQuery.extend({}, oldData);
-
-		if ( events ) {
-			delete curData.handle;
-			curData.events = {};
-
-			for ( var type in events ) {
-				for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
-					jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
-				}
-			}
-		}
-	}
-}
-
-function cloneFixAttributes( src, dest ) {
-	var nodeName;
-
-	// We do not need to do anything for non-Elements
-	if ( dest.nodeType !== 1 ) {
-		return;
-	}
-
-	// clearAttributes removes the attributes, which we don't want,
-	// but also removes the attachEvent events, which we *do* want
-	if ( dest.clearAttributes ) {
-		dest.clearAttributes();
-	}
-
-	// mergeAttributes, in contrast, only merges back on the
-	// original attributes, not the events
-	if ( dest.mergeAttributes ) {
-		dest.mergeAttributes( src );
-	}
-
-	nodeName = dest.nodeName.toLowerCase();
-
-	// IE6-8 fail to clone children inside object elements that use
-	// the proprietary classid attribute value (rather than the type
-	// attribute) to identify the type of content to display
-	if ( nodeName === "object" ) {
-		dest.outerHTML = src.outerHTML;
-
-	} else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
-		// IE6-8 fails to persist the checked state of a cloned checkbox
-		// or radio button. Worse, IE6-7 fail to give the cloned element
-		// a checked appearance if the defaultChecked value isn't also set
-		if ( src.checked ) {
-			dest.defaultChecked = dest.checked = src.checked;
-		}
-
-		// IE6-7 get confused and end up setting the value of a cloned
-		// checkbox/radio button to an empty string instead of "on"
-		if ( dest.value !== src.value ) {
-			dest.value = src.value;
-		}
-
-	// IE6-8 fails to return the selected option to the default selected
-	// state when cloning options
-	} else if ( nodeName === "option" ) {
-		dest.selected = src.defaultSelected;
-
-	// IE6-8 fails to set the defaultValue to the correct value when
-	// cloning other types of input fields
-	} else if ( nodeName === "input" || nodeName === "textarea" ) {
-		dest.defaultValue = src.defaultValue;
-	}
-
-	// Event data gets referenced instead of copied if the expando
-	// gets copied too
-	dest.removeAttribute( jQuery.expando );
-}
-
-jQuery.buildFragment = function( args, nodes, scripts ) {
-	var fragment, cacheable, cacheresults, doc;
-
-  // nodes may contain either an explicit document object,
-  // a jQuery collection or context object.
-  // If nodes[0] contains a valid object to assign to doc
-  if ( nodes && nodes[0] ) {
-    doc = nodes[0].ownerDocument || nodes[0];
-  }
-
-  // Ensure that an attr object doesn't incorrectly stand in as a document object
-	// Chrome and Firefox seem to allow this to occur and will throw exception
-	// Fixes #8950
-	if ( !doc.createDocumentFragment ) {
-		doc = document;
-	}
-
-	// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
-	// Cloning options loses the selected state, so don't cache them
-	// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
-	// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
-	if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
-		args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
-
-		cacheable = true;
-
-		cacheresults = jQuery.fragments[ args[0] ];
-		if ( cacheresults && cacheresults !== 1 ) {
-			fragment = cacheresults;
-		}
-	}
-
-	if ( !fragment ) {
-		fragment = doc.createDocumentFragment();
-		jQuery.clean( args, doc, fragment, scripts );
-	}
-
-	if ( cacheable ) {
-		jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
-	}
-
-	return { fragment: fragment, cacheable: cacheable };
-};
-
-jQuery.fragments = {};
-
-jQuery.each({
-	appendTo: "append",
-	prependTo: "prepend",
-	insertBefore: "before",
-	insertAfter: "after",
-	replaceAll: "replaceWith"
-}, function( name, original ) {
-	jQuery.fn[ name ] = function( selector ) {
-		var ret = [],
-			insert = jQuery( selector ),
-			parent = this.length === 1 && this[0].parentNode;
-
-		if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
-			insert[ original ]( this[0] );
-			return this;
-
-		} else {
-			for ( var i = 0, l = insert.length; i < l; i++ ) {
-				var elems = (i > 0 ? this.clone(true) : this).get();
-				jQuery( insert[i] )[ original ]( elems );
-				ret = ret.concat( elems );
-			}
-
-			return this.pushStack( ret, name, insert.selector );
-		}
-	};
-});
-
-function getAll( elem ) {
-	if ( "getElementsByTagName" in elem ) {
-		return elem.getElementsByTagName( "*" );
-
-	} else if ( "querySelectorAll" in elem ) {
-		return elem.querySelectorAll( "*" );
-
-	} else {
-		return [];
-	}
-}
-
-// Used in clean, fixes the defaultChecked property
-function fixDefaultChecked( elem ) {
-	if ( elem.type === "checkbox" || elem.type === "radio" ) {
-		elem.defaultChecked = elem.checked;
-	}
-}
-// Finds all inputs and passes them to fixDefaultChecked
-function findInputs( elem ) {
-	if ( jQuery.nodeName( elem, "input" ) ) {
-		fixDefaultChecked( elem );
-	} else if ( "getElementsByTagName" in elem ) {
-		jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
-	}
-}
-
-jQuery.extend({
-	clone: function( elem, dataAndEvents, deepDataAndEvents ) {
-		var clone = elem.cloneNode(true),
-				srcElements,
-				destElements,
-				i;
-
-		if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
-				(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
-			// IE copies events bound via attachEvent when using cloneNode.
-			// Calling detachEvent on the clone will also remove the events
-			// from the original. In order to get around this, we use some
-			// proprietary methods to clear the events. Thanks to MooTools
-			// guys for this hotness.
-
-			cloneFixAttributes( elem, clone );
-
-			// Using Sizzle here is crazy slow, so we use getElementsByTagName
-			// instead
-			srcElements = getAll( elem );
-			destElements = getAll( clone );
-
-			// Weird iteration because IE will replace the length property
-			// with an element if you are cloning the body and one of the
-			// elements on the page has a name or id of "length"
-			for ( i = 0; srcElements[i]; ++i ) {
-				// Ensure that the destination node is not null; Fixes #9587
-				if ( destElements[i] ) {
-					cloneFixAttributes( srcElements[i], destElements[i] );
-				}
-			}
-		}
-
-		// Copy the events from the original to the clone
-		if ( dataAndEvents ) {
-			cloneCopyEvent( elem, clone );
-
-			if ( deepDataAndEvents ) {
-				srcElements = getAll( elem );
-				destElements = getAll( clone );
-
-				for ( i = 0; srcElements[i]; ++i ) {
-					cloneCopyEvent( srcElements[i], destElements[i] );
-				}
-			}
-		}
-
-		srcElements = destElements = null;
-
-		// Return the cloned set
-		return clone;
-	},
-
-	clean: function( elems, context, fragment, scripts ) {
-		var checkScriptType;
-
-		context = context || document;
-
-		// !context.createElement fails in IE with an error but returns typeof 'object'
-		if ( typeof context.createElement === "undefined" ) {
-			context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
-		}
-
-		var ret = [], j;
-
-		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
-			if ( typeof elem === "number" ) {
-				elem += "";
-			}
-
-			if ( !elem ) {
-				continue;
-			}
-
-			// Convert html string into DOM nodes
-			if ( typeof elem === "string" ) {
-				if ( !rhtml.test( elem ) ) {
-					elem = context.createTextNode( elem );
-				} else {
-					// Fix "XHTML"-style tags in all browsers
-					elem = elem.replace(rxhtmlTag, "<$1></$2>");
-
-					// Trim whitespace, otherwise indexOf won't work as expected
-					var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
-						wrap = wrapMap[ tag ] || wrapMap._default,
-						depth = wrap[0],
-						div = context.createElement("div");
-
-					// Go to html and back, then peel off extra wrappers
-					div.innerHTML = wrap[1] + elem + wrap[2];
-
-					// Move to the right depth
-					while ( depth-- ) {
-						div = div.lastChild;
-					}
-
-					// Remove IE's autoinserted <tbody> from table fragments
-					if ( !jQuery.support.tbody ) {
-
-						// String was a <table>, *may* have spurious <tbody>
-						var hasBody = rtbody.test(elem),
-							tbody = tag === "table" && !hasBody ?
-								div.firstChild && div.firstChild.childNodes :
-
-								// String was a bare <thead> or <tfoot>
-								wrap[1] === "<table>" && !hasBody ?
-									div.childNodes :
-									[];
-
-						for ( j = tbody.length - 1; j >= 0 ; --j ) {
-							if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
-								tbody[ j ].parentNode.removeChild( tbody[ j ] );
-							}
-						}
-					}
-
-					// IE completely kills leading whitespace when innerHTML is used
-					if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
-						div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
-					}
-
-					elem = div.childNodes;
-				}
-			}
-
-			// Resets defaultChecked for any radios and checkboxes
-			// about to be appended to the DOM in IE 6/7 (#8060)
-			var len;
-			if ( !jQuery.support.appendChecked ) {
-				if ( elem[0] && typeof (len = elem.length) === "number" ) {
-					for ( j = 0; j < len; j++ ) {
-						findInputs( elem[j] );
-					}
-				} else {
-					findInputs( elem );
-				}
-			}
-
-			if ( elem.nodeType ) {
-				ret.push( elem );
-			} else {
-				ret = jQuery.merge( ret, elem );
-			}
-		}
-
-		if ( fragment ) {
-			checkScriptType = function( elem ) {
-				return !elem.type || rscriptType.test( elem.type );
-			};
-			for ( i = 0; ret[i]; i++ ) {
-				if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
-					scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
-
-				} else {
-					if ( ret[i].nodeType === 1 ) {
-						var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
-
-						ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
-					}
-					fragment.appendChild( ret[i] );
-				}
-			}
-		}
-
-		return ret;
-	},
-
-	cleanData: function( elems ) {
-		var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
-			deleteExpando = jQuery.support.deleteExpando;
-
-		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
-			if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
-				continue;
-			}
-
-			id = elem[ jQuery.expando ];
-
-			if ( id ) {
-				data = cache[ id ] && cache[ id ][ internalKey ];
-
-				if ( data && data.events ) {
-					for ( var type in data.events ) {
-						if ( special[ type ] ) {
-							jQuery.event.remove( elem, type );
-
-						// This is a shortcut to avoid jQuery.event.remove's overhead
-						} else {
-							jQuery.removeEvent( elem, type, data.handle );
-						}
-					}
-
-					// Null the DOM reference to avoid IE6/7/8 leak (#7054)
-					if ( data.handle ) {
-						data.handle.elem = null;
-					}
-				}
-
-				if ( deleteExpando ) {
-					delete elem[ jQuery.expando ];
-
-				} else if ( elem.removeAttribute ) {
-					elem.removeAttribute( jQuery.expando );
-				}
-
-				delete cache[ id ];
-			}
-		}
-	}
-});
-
-function evalScript( i, elem ) {
-	if ( elem.src ) {
-		jQuery.ajax({
-			url: elem.src,
-			async: false,
-			dataType: "script"
-		});
-	} else {
-		jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
-	}
-
-	if ( elem.parentNode ) {
-		elem.parentNode.removeChild( elem );
-	}
-}
-
-
-
-
-var ralpha = /alpha\([^)]*\)/i,
-	ropacity = /opacity=([^)]*)/,
-	// fixed for IE9, see #8346
-	rupper = /([A-Z]|^ms)/g,
-	rnumpx = /^-?\d+(?:px)?$/i,
-	rnum = /^-?\d/,
-	rrelNum = /^([\-+])=([\-+.\de]+)/,
-
-	cssShow = { position: "absolute", visibility: "hidden", display: "block" },
-	cssWidth = [ "Left", "Right" ],
-	cssHeight = [ "Top", "Bottom" ],
-	curCSS,
-
-	getComputedStyle,
-	currentStyle;
-
-jQuery.fn.css = function( name, value ) {
-	// Setting 'undefined' is a no-op
-	if ( arguments.length === 2 && value === undefined ) {
-		return this;
-	}
-
-	return jQuery.access( this, name, value, true, function( elem, name, value ) {
-		return value !== undefined ?
-			jQuery.style( elem, name, value ) :
-			jQuery.css( elem, name );
-	});
-};
-
-jQuery.extend({
-	// Add in style property hooks for overriding the default
-	// behavior of getting and setting a style property
-	cssHooks: {
-		opacity: {
-			get: function( elem, computed ) {
-				if ( computed ) {
-					// We should always get a number back from opacity
-					var ret = curCSS( elem, "opacity", "opacity" );
-					return ret === "" ? "1" : ret;
-
-				} else {
-					return elem.style.opacity;
-				}
-			}
-		}
-	},
-
-	// Exclude the following css properties to add px
-	cssNumber: {
-		"fillOpacity": true,
-		"fontWeight": true,
-		"lineHeight": true,
-		"opacity": true,
-		"orphans": true,
-		"widows": true,
-		"zIndex": true,
-		"zoom": true
-	},
-
-	// Add in properties whose names you wish to fix before
-	// setting or getting the value
-	cssProps: {
-		// normalize float css property
-		"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
-	},
-
-	// Get and set the style property on a DOM Node
-	style: function( elem, name, value, extra ) {
-		// Don't set styles on text and comment nodes
-		if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
-			return;
-		}
-
-		// Make sure that we're working with the right name
-		var ret, type, origName = jQuery.camelCase( name ),
-			style = elem.style, hooks = jQuery.cssHooks[ origName ];
-
-		name = jQuery.cssProps[ origName ] || origName;
-
-		// Check if we're setting a value
-		if ( value !== undefined ) {
-			type = typeof value;
-
-			// convert relative number strings (+= or -=) to relative numbers. #7345
-			if ( type === "string" && (ret = rrelNum.exec( value )) ) {
-				value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
-				// Fixes bug #9237
-				type = "number";
-			}
-
-			// Make sure that NaN and null values aren't set. See: #7116
-			if ( value == null || type === "number" && isNaN( value ) ) {
-				return;
-			}
-
-			// If a number was passed in, add 'px' to the (except for certain CSS properties)
-			if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
-				value += "px";
-			}
-
-			// If a hook was provided, use that value, otherwise just set the specified value
-			if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
-				// Wrapped to prevent IE from throwing errors when 'invalid' values are provided
-				// Fixes bug #5509
-				try {
-					style[ name ] = value;
-				} catch(e) {}
-			}
-
-		} else {
-			// If a hook was provided get the non-computed value from there
-			if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
-				return ret;
-			}
-
-			// Otherwise just get the value from the style object
-			return style[ name ];
-		}
-	},
-
-	css: function( elem, name, extra ) {
-		var ret, hooks;
-
-		// Make sure that we're working with the right name
-		name = jQuery.camelCase( name );
-		hooks = jQuery.cssHooks[ name ];
-		name = jQuery.cssProps[ name ] || name;
-
-		// cssFloat needs a special treatment
-		if ( name === "cssFloat" ) {
-			name = "float";
-		}
-
-		// If a hook was provided get the computed value from there
-		if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
-			return ret;
-
-		// Otherwise, if a way to get the computed value exists, use that
-		} else if ( curCSS ) {
-			return curCSS( elem, name );
-		}
-	},
-
-	// A method for quickly swapping in/out CSS properties to get correct calculations
-	swap: function( elem, options, callback ) {
-		var old = {};
-
-		// Remember the old values, and insert the new ones
-		for ( var name in options ) {
-			old[ name ] = elem.style[ name ];
-			elem.style[ name ] = options[ name ];
-		}
-
-		callback.call( elem );
-
-		// Revert the old values
-		for ( name in options ) {
-			elem.style[ name ] = old[ name ];
-		}
-	}
-});
-
-// DEPRECATED, Use jQuery.css() instead
-jQuery.curCSS = jQuery.css;
-
-jQuery.each(["height", "width"], function( i, name ) {
-	jQuery.cssHooks[ name ] = {
-		get: function( elem, computed, extra ) {
-			var val;
-
-			if ( computed ) {
-				if ( elem.offsetWidth !== 0 ) {
-					return getWH( elem, name, extra );
-				} else {
-					jQuery.swap( elem, cssShow, function() {
-						val = getWH( elem, name, extra );
-					});
-				}
-
-				return val;
-			}
-		},
-
-		set: function( elem, value ) {
-			if ( rnumpx.test( value ) ) {
-				// ignore negative width and height values #1599
-				value = parseFloat( value );
-
-				if ( value >= 0 ) {
-					return value + "px";
-				}
-
-			} else {
-				return value;
-			}
-		}
-	};
-});
-
-if ( !jQuery.support.opacity ) {
-	jQuery.cssHooks.opacity = {
-		get: function( elem, computed ) {
-			// IE uses filters for opacity
-			return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
-				( parseFloat( RegExp.$1 ) / 100 ) + "" :
-				computed ? "1" : "";
-		},
-
-		set: function( elem, value ) {
-			var style = elem.style,
-				currentStyle = elem.currentStyle,
-				opacity = jQuery.isNaN( value ) ? "" : "alpha(opacity=" + value * 100 + ")",
-				filter = currentStyle && currentStyle.filter || style.filter || "";
-
-			// IE has trouble with opacity if it does not have layout
-			// Force it by setting the zoom level
-			style.zoom = 1;
-
-			// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
-			if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
-
-				// Setting style.filter to null, "" & " " still leave "filter:" in the cssText
-				// if "filter:" is present at all, clearType is disabled, we want to avoid this
-				// style.removeAttribute is IE Only, but so apparently is this code path...
-				style.removeAttribute( "filter" );
-
-				// if there there is no filter style applied in a css rule, we are done
-				if ( currentStyle && !currentStyle.filter ) {
-					return;
-				}
-			}
-
-			// otherwise, set new filter values
-			style.filter = ralpha.test( filter ) ?
-				filter.replace( ralpha, opacity ) :
-				filter + " " + opacity;
-		}
-	};
-}
-
-jQuery(function() {
-	// This hook cannot be added until DOM ready because the support test
-	// for it is not run until after DOM ready
-	if ( !jQuery.support.reliableMarginRight ) {
-		jQuery.cssHooks.marginRight = {
-			get: function( elem, computed ) {
-				// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
-				// Work around by temporarily setting element display to inline-block
-				var ret;
-				jQuery.swap( elem, { "display": "inline-block" }, function() {
-					if ( computed ) {
-						ret = curCSS( elem, "margin-right", "marginRight" );
-					} else {
-						ret = elem.style.marginRight;
-					}
-				});
-				return ret;
-			}
-		};
-	}
-});
-
-if ( document.defaultView && document.defaultView.getComputedStyle ) {
-	getComputedStyle = function( elem, name ) {
-		var ret, defaultView, computedStyle;
-
-		name = name.replace( rupper, "-$1" ).toLowerCase();
-
-		if ( !(defaultView = elem.ownerDocument.defaultView) ) {
-			return undefined;
-		}
-
-		if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
-			ret = computedStyle.getPropertyValue( name );
-			if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
-				ret = jQuery.style( elem, name );
-			}
-		}
-
-		return ret;
-	};
-}
-
-if ( document.documentElement.currentStyle ) {
-	currentStyle = function( elem, name ) {
-		var left,
-			ret = elem.currentStyle && elem.currentStyle[ name ],
-			rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
-			style = elem.style;
-
-		// From the awesome hack by Dean Edwards
-		// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
-
-		// If we're not dealing with a regular pixel number
-		// but a number that has a weird ending, we need to convert it to pixels
-		if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
-			// Remember the original values
-			left = style.left;
-
-			// Put in the new values to get a computed value out
-			if ( rsLeft ) {
-				elem.runtimeStyle.left = elem.currentStyle.left;
-			}
-			style.left = name === "fontSize" ? "1em" : (ret || 0);
-			ret = style.pixelLeft + "px";
-
-			// Revert the changed values
-			style.left = left;
-			if ( rsLeft ) {
-				elem.runtimeStyle.left = rsLeft;
-			}
-		}
-
-		return ret === "" ? "auto" : ret;
-	};
-}
-
-curCSS = getComputedStyle || currentStyle;
-
-function getWH( elem, name, extra ) {
-
-	// Start with offset property
-	var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
-		which = name === "width" ? cssWidth : cssHeight;
-
-	if ( val > 0 ) {
-		if ( extra !== "border" ) {
-			jQuery.each( which, function() {
-				if ( !extra ) {
-					val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
-				}
-				if ( extra === "margin" ) {
-					val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
-				} else {
-					val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
-				}
-			});
-		}
-
-		return val + "px";
-	}
-
-	// Fall back to computed then uncomputed css if necessary
-	val = curCSS( elem, name, name );
-	if ( val < 0 || val == null ) {
-		val = elem.style[ name ] || 0;
-	}
-	// Normalize "", auto, and prepare for extra
-	val = parseFloat( val ) || 0;
-
-	// Add padding, border, margin
-	if ( extra ) {
-		jQuery.each( which, function() {
-			val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
-			if ( extra !== "padding" ) {
-				val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
-			}
-			if ( extra === "margin" ) {
-				val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
-			}
-		});
-	}
-
-	return val + "px";
-}
-
-if ( jQuery.expr && jQuery.expr.filters ) {
-	jQuery.expr.filters.hidden = function( elem ) {
-		var width = elem.offsetWidth,
-			height = elem.offsetHeight;
-
-		return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
-	};
-
-	jQuery.expr.filters.visible = function( elem ) {
-		return !jQuery.expr.filters.hidden( elem );
-	};
-}
-
-
-
-
-var r20 = /%20/g,
-	rbracket = /\[\]$/,
-	rCRLF = /\r?\n/g,
-	rhash = /#.*$/,
-	rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
-	rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
-	// #7653, #8125, #8152: local protocol detection
-	rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
-	rnoContent = /^(?:GET|HEAD)$/,
-	rprotocol = /^\/\//,
-	rquery = /\?/,
-	rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
-	rselectTextarea = /^(?:select|textarea)/i,
-	rspacesAjax = /\s+/,
-	rts = /([?&])_=[^&]*/,
-	rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
-
-	// Keep a copy of the old load method
-	_load = jQuery.fn.load,
-
-	/* Prefilters
-	 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
-	 * 2) These are called:
-	 *    - BEFORE asking for a transport
-	 *    - AFTER param serialization (s.data is a string if s.processData is true)
-	 * 3) key is the dataType
-	 * 4) the catchall symbol "*" can be used
-	 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
-	 */
-	prefilters = {},
-
-	/* Transports bindings
-	 * 1) key is the dataType
-	 * 2) the catchall symbol "*" can be used
-	 * 3) selection will start with transport dataType and THEN go to "*" if needed
-	 */
-	transports = {},
-
-	// Document location
-	ajaxLocation,
-
-	// Document location segments
-	ajaxLocParts,
-	
-	// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
-	allTypes = ["*/"] + ["*"];
-
-// #8138, IE may throw an exception when accessing
-// a field from window.location if document.domain has been set
-try {
-	ajaxLocation = location.href;
-} catch( e ) {
-	// Use the href attribute of an A element
-	// since IE will modify it given document.location
-	ajaxLocation = document.createElement( "a" );
-	ajaxLocation.href = "";
-	ajaxLocation = ajaxLocation.href;
-}
-
-// Segment location into parts
-ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
-
-// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
-function addToPrefiltersOrTransports( structure ) {
-
-	// dataTypeExpression is optional and defaults to "*"
-	return function( dataTypeExpression, func ) {
-
-		if ( typeof dataTypeExpression !== "string" ) {
-			func = dataTypeExpression;
-			dataTypeExpression = "*";
-		}
-
-		if ( jQuery.isFunction( func ) ) {
-			var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
-				i = 0,
-				length = dataTypes.length,
-				dataType,
-				list,
-				placeBefore;
-
-			// For each dataType in the dataTypeExpression
-			for(; i < length; i++ ) {
-				dataType = dataTypes[ i ];
-				// We control if we're asked to add before
-				// any existing element
-				placeBefore = /^\+/.test( dataType );
-				if ( placeBefore ) {
-					dataType = dataType.substr( 1 ) || "*";
-				}
-				list = structure[ dataType ] = structure[ dataType ] || [];
-				// then we add to the structure accordingly
-				list[ placeBefore ? "unshift" : "push" ]( func );
-			}
-		}
-	};
-}
-
-// Base inspection function for prefilters and transports
-function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
-		dataType /* internal */, inspected /* internal */ ) {
-
-	dataType = dataType || options.dataTypes[ 0 ];
-	inspected = inspected || {};
-
-	inspected[ dataType ] = true;
-
-	var list = structure[ dataType ],
-		i = 0,
-		length = list ? list.length : 0,
-		executeOnly = ( structure === prefilters ),
-		selection;
-
-	for(; i < length && ( executeOnly || !selection ); i++ ) {
-		selection = list[ i ]( options, originalOptions, jqXHR );
-		// If we got redirected to another dataType
-		// we try there if executing only and not done already
-		if ( typeof selection === "string" ) {
-			if ( !executeOnly || inspected[ selection ] ) {
-				selection = undefined;
-			} else {
-				options.dataTypes.unshift( selection );
-				selection = inspectPrefiltersOrTransports(
-						structure, options, originalOptions, jqXHR, selection, inspected );
-			}
-		}
-	}
-	// If we're only executing or nothing was selected
-	// we try the catchall dataType if not done already
-	if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
-		selection = inspectPrefiltersOrTransports(
-				structure, options, originalOptions, jqXHR, "*", inspected );
-	}
-	// unnecessary when only executing (prefilters)
-	// but it'll be ignored by the caller in that case
-	return selection;
-}
-
-// A special extend for ajax options
-// that takes "flat" options (not to be deep extended)
-// Fixes #9887
-function ajaxExtend( target, src ) {
-	var key, deep,
-		flatOptions = jQuery.ajaxSettings.flatOptions || {};
-	for( key in src ) {
-		if ( src[ key ] !== undefined ) {
-			( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
-		}
-	}
-	if ( deep ) {
-		jQuery.extend( true, target, deep );
-	}
-}
-
-jQuery.fn.extend({
-	load: function( url, params, callback ) {
-		if ( typeof url !== "string" && _load ) {
-			return _load.apply( this, arguments );
-
-		// Don't do a request if no elements are being requested
-		} else if ( !this.length ) {
-			return this;
-		}
-
-		var off = url.indexOf( " " );
-		if ( off >= 0 ) {
-			var selector = url.slice( off, url.length );
-			url = url.slice( 0, off );
-		}
-
-		// Default to a GET request
-		var type = "GET";
-
-		// If the second parameter was provided
-		if ( params ) {
-			// If it's a function
-			if ( jQuery.isFunction( params ) ) {
-				// We assume that it's the callback
-				callback = params;
-				params = undefined;
-
-			// Otherwise, build a param string
-			} else if ( typeof params === "object" ) {
-				params = jQuery.param( params, jQuery.ajaxSettings.traditional );
-				type = "POST";
-			}
-		}
-
-		var self = this;
-
-		// Request the remote document
-		jQuery.ajax({
-			url: url,
-			type: type,
-			dataType: "html",
-			data: params,
-			// Complete callback (responseText is used internally)
-			complete: function( jqXHR, status, responseText ) {
-				// Store the response as specified by the jqXHR object
-				responseText = jqXHR.responseText;
-				// If successful, inject the HTML into all the matched elements
-				if ( jqXHR.isResolved() ) {
-					// #4825: Get the actual response in case
-					// a dataFilter is present in ajaxSettings
-					jqXHR.done(function( r ) {
-						responseText = r;
-					});
-					// See if a selector was specified
-					self.html( selector ?
-						// Create a dummy div to hold the results
-						jQuery("<div>")
-							// inject the contents of the document in, removing the scripts
-							// to avoid any 'Permission Denied' errors in IE
-							.append(responseText.replace(rscript, ""))
-
-							// Locate the specified elements
-							.find(selector) :
-
-						// If not, just inject the full result
-						responseText );
-				}
-
-				if ( callback ) {
-					self.each( callback, [ responseText, status, jqXHR ] );
-				}
-			}
-		});
-
-		return this;
-	},
-
-	serialize: function() {
-		return jQuery.param( this.serializeArray() );
-	},
-
-	serializeArray: function() {
-		return this.map(function(){
-			return this.elements ? jQuery.makeArray( this.elements ) : this;
-		})
-		.filter(function(){
-			return this.name && !this.disabled &&
-				( this.checked || rselectTextarea.test( this.nodeName ) ||
-					rinput.test( this.type ) );
-		})
-		.map(function( i, elem ){
-			var val = jQuery( this ).val();
-
-			return val == null ?
-				null :
-				jQuery.isArray( val ) ?
-					jQuery.map( val, function( val, i ){
-						return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
-					}) :
-					{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
-		}).get();
-	}
-});
-
-// Attach a bunch of functions for handling common AJAX events
-jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
-	jQuery.fn[ o ] = function( f ){
-		return this.bind( o, f );
-	};
-});
-
-jQuery.each( [ "get", "post" ], function( i, method ) {
-	jQuery[ method ] = function( url, data, callback, type ) {
-		// shift arguments if data argument was omitted
-		if ( jQuery.isFunction( data ) ) {
-			type = type || callback;
-			callback = data;
-			data = undefined;
-		}
-
-		return jQuery.ajax({
-			type: method,
-			url: url,
-			data: data,
-			success: callback,
-			dataType: type
-		});
-	};
-});
-
-jQuery.extend({
-
-	getScript: function( url, callback ) {
-		return jQuery.get( url, undefined, callback, "script" );
-	},
-
-	getJSON: function( url, data, callback ) {
-		return jQuery.get( url, data, callback, "json" );
-	},
-
-	// Creates a full fledged settings object into target
-	// with both ajaxSettings and settings fields.
-	// If target is omitted, writes into ajaxSettings.
-	ajaxSetup: function( target, settings ) {
-		if ( settings ) {
-			// Building a settings object
-			ajaxExtend( target, jQuery.ajaxSettings );
-		} else {
-			// Extending ajaxSettings
-			settings = target;
-			target = jQuery.ajaxSettings;
-		}
-		ajaxExtend( target, settings );
-		return target;
-	},
-
-	ajaxSettings: {
-		url: ajaxLocation,
-		isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
-		global: true,
-		type: "GET",
-		contentType: "application/x-www-form-urlencoded",
-		processData: true,
-		async: true,
-		/*
-		timeout: 0,
-		data: null,
-		dataType: null,
-		username: null,
-		password: null,
-		cache: null,
-		traditional: false,
-		headers: {},
-		*/
-
-		accepts: {
-			xml: "application/xml, text/xml",
-			html: "text/html",
-			text: "text/plain",
-			json: "application/json, text/javascript",
-			"*": allTypes
-		},
-
-		contents: {
-			xml: /xml/,
-			html: /html/,
-			json: /json/
-		},
-
-		responseFields: {
-			xml: "responseXML",
-			text: "responseText"
-		},
-
-		// List of data converters
-		// 1) key format is "source_type destination_type" (a single space in-between)
-		// 2) the catchall symbol "*" can be used for source_type
-		converters: {
-
-			// Convert anything to text
-			"* text": window.String,
-
-			// Text to html (true = no transformation)
-			"text html": true,
-
-			// Evaluate text as a json expression
-			"text json": jQuery.parseJSON,
-
-			// Parse text as xml
-			"text xml": jQuery.parseXML
-		},
-
-		// For options that shouldn't be deep extended:
-		// you can add your own custom options here if
-		// and when you create one that shouldn't be
-		// deep extended (see ajaxExtend)
-		flatOptions: {
-			context: true,
-			url: true
-		}
-	},
-
-	ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
-	ajaxTransport: addToPrefiltersOrTransports( transports ),
-
-	// Main method
-	ajax: function( url, options ) {
-
-		// If url is an object, simulate pre-1.5 signature
-		if ( typeof url === "object" ) {
-			options = url;
-			url = undefined;
-		}
-
-		// Force options to be an object
-		options = options || {};
-
-		var // Create the final options object
-			s = jQuery.ajaxSetup( {}, options ),
-			// Callbacks context
-			callbackContext = s.context || s,
-			// Context for global events
-			// It's the callbackContext if one was provided in the options
-			// and if it's a DOM node or a jQuery collection
-			globalEventContext = callbackContext !== s &&
-				( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
-						jQuery( callbackContext ) : jQuery.event,
-			// Deferreds
-			deferred = jQuery.Deferred(),
-			completeDeferred = jQuery._Deferred(),
-			// Status-dependent callbacks
-			statusCode = s.statusCode || {},
-			// ifModified key
-			ifModifiedKey,
-			// Headers (they are sent all at once)
-			requestHeaders = {},
-			requestHeadersNames = {},
-			// Response headers
-			responseHeadersString,
-			responseHeaders,
-			// transport
-			transport,
-			// timeout handle
-			timeoutTimer,
-			// Cross-domain detection vars
-			parts,
-			// The jqXHR state
-			state = 0,
-			// To know if global events are to be dispatched
-			fireGlobals,
-			// Loop variable
-			i,
-			// Fake xhr
-			jqXHR = {
-
-				readyState: 0,
-
-				// Caches the header
-				setRequestHeader: function( name, value ) {
-					if ( !state ) {
-						var lname = name.toLowerCase();
-						name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
-						requestHeaders[ name ] = value;
-					}
-					return this;
-				},
-
-				// Raw string
-				getAllResponseHeaders: function() {
-					return state === 2 ? responseHeadersString : null;
-				},
-
-				// Builds headers hashtable if needed
-				getResponseHeader: function( key ) {
-					var match;
-					if ( state === 2 ) {
-						if ( !responseHeaders ) {
-							responseHeaders = {};
-							while( ( match = rheaders.exec( responseHeadersString ) ) ) {
-								responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
-							}
-						}
-						match = responseHeaders[ key.toLowerCase() ];
-					}
-					return match === undefined ? null : match;
-				},
-
-				// Overrides response content-type header
-				overrideMimeType: function( type ) {
-					if ( !state ) {
-						s.mimeType = type;
-					}
-					return this;
-				},
-
-				// Cancel the request
-				abort: function( statusText ) {
-					statusText = statusText || "abort";
-					if ( transport ) {
-						transport.abort( statusText );
-					}
-					done( 0, statusText );
-					return this;
-				}
-			};
-
-		// Callback for when everything is done
-		// It is defined here because jslint complains if it is declared
-		// at the end of the function (which would be more logical and readable)
-		function done( status, nativeStatusText, responses, headers ) {
-
-			// Called once
-			if ( state === 2 ) {
-				return;
-			}
-
-			// State is "done" now
-			state = 2;
-
-			// Clear timeout if it exists
-			if ( timeoutTimer ) {
-				clearTimeout( timeoutTimer );
-			}
-
-			// Dereference transport for early garbage collection
-			// (no matter how long the jqXHR object will be used)
-			transport = undefined;
-
-			// Cache response headers
-			responseHeadersString = headers || "";
-
-			// Set readyState
-			jqXHR.readyState = status > 0 ? 4 : 0;
-
-			var isSuccess,
-				success,
-				error,
-				statusText = nativeStatusText,
-				response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
-				lastModified,
-				etag;
-
-			// If successful, handle type chaining
-			if ( status >= 200 && status < 300 || status === 304 ) {
-
-				// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
-				if ( s.ifModified ) {
-
-					if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
-						jQuery.lastModified[ ifModifiedKey ] = lastModified;
-					}
-					if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
-						jQuery.etag[ ifModifiedKey ] = etag;
-					}
-				}
-
-				// If not modified
-				if ( status === 304 ) {
-
-					statusText = "notmodified";
-					isSuccess = true;
-
-				// If we have data
-				} else {
-
-					try {
-						success = ajaxConvert( s, response );
-						statusText = "success";
-						isSuccess = true;
-					} catch(e) {
-						// We have a parsererror
-						statusText = "parsererror";
-						error = e;
-					}
-				}
-			} else {
-				// We extract error from statusText
-				// then normalize statusText and status for non-aborts
-				error = statusText;
-				if( !statusText || status ) {
-					statusText = "error";
-					if ( status < 0 ) {
-						status = 0;
-					}
-				}
-			}
-
-			// Set data for the fake xhr object
-			jqXHR.status = status;
-			jqXHR.statusText = "" + ( nativeStatusText || statusText );
-
-			// Success/Error
-			if ( isSuccess ) {
-				deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
-			} else {
-				deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
-			}
-
-			// Status-dependent callbacks
-			jqXHR.statusCode( statusCode );
-			statusCode = undefined;
-
-			if ( fireGlobals ) {
-				globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
-						[ jqXHR, s, isSuccess ? success : error ] );
-			}
-
-			// Complete
-			completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
-
-			if ( fireGlobals ) {
-				globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
-				// Handle the global AJAX counter
-				if ( !( --jQuery.active ) ) {
-					jQuery.event.trigger( "ajaxStop" );
-				}
-			}
-		}
-
-		// Attach deferreds
-		deferred.promise( jqXHR );
-		jqXHR.success = jqXHR.done;
-		jqXHR.error = jqXHR.fail;
-		jqXHR.complete = completeDeferred.done;
-
-		// Status-dependent callbacks
-		jqXHR.statusCode = function( map ) {
-			if ( map ) {
-				var tmp;
-				if ( state < 2 ) {
-					for( tmp in map ) {
-						statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
-					}
-				} else {
-					tmp = map[ jqXHR.status ];
-					jqXHR.then( tmp, tmp );
-				}
-			}
-			return this;
-		};
-
-		// Remove hash character (#7531: and string promotion)
-		// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
-		// We also use the url parameter if available
-		s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
-
-		// Extract dataTypes list
-		s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
-
-		// Determine if a cross-domain request is in order
-		if ( s.crossDomain == null ) {
-			parts = rurl.exec( s.url.toLowerCase() );
-			s.crossDomain = !!( parts &&
-				( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
-					( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
-						( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
-			);
-		}
-
-		// Convert data if not already a string
-		if ( s.data && s.processData && typeof s.data !== "string" ) {
-			s.data = jQuery.param( s.data, s.traditional );
-		}
-
-		// Apply prefilters
-		inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
-
-		// If request was aborted inside a prefiler, stop there
-		if ( state === 2 ) {
-			return false;
-		}
-
-		// We can fire global events as of now if asked to
-		fireGlobals = s.global;
-
-		// Uppercase the type
-		s.type = s.type.toUpperCase();
-
-		// Determine if request has content
-		s.hasContent = !rnoContent.test( s.type );
-
-		// Watch for a new set of requests
-		if ( fireGlobals && jQuery.active++ === 0 ) {
-			jQuery.event.trigger( "ajaxStart" );
-		}
-
-		// More options handling for requests with no content
-		if ( !s.hasContent ) {
-
-			// If data is available, append data to url
-			if ( s.data ) {
-				s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
-				// #9682: remove data so that it's not used in an eventual retry
-				delete s.data;
-			}
-
-			// Get ifModifiedKey before adding the anti-cache parameter
-			ifModifiedKey = s.url;
-
-			// Add anti-cache in url if needed
-			if ( s.cache === false ) {
-
-				var ts = jQuery.now(),
-					// try replacing _= if it is there
-					ret = s.url.replace( rts, "$1_=" + ts );
-
-				// if nothing was replaced, add timestamp to the end
-				s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
-			}
-		}
-
-		// Set the correct header, if data is being sent
-		if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
-			jqXHR.setRequestHeader( "Content-Type", s.contentType );
-		}
-
-		// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
-		if ( s.ifModified ) {
-			ifModifiedKey = ifModifiedKey || s.url;
-			if ( jQuery.lastModified[ ifModifiedKey ] ) {
-				jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
-			}
-			if ( jQuery.etag[ ifModifiedKey ] ) {
-				jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
-			}
-		}
-
-		// Set the Accepts header for the server, depending on the dataType
-		jqXHR.setRequestHeader(
-			"Accept",
-			s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
-				s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
-				s.accepts[ "*" ]
-		);
-
-		// Check for headers option
-		for ( i in s.headers ) {
-			jqXHR.setRequestHeader( i, s.headers[ i ] );
-		}
-
-		// Allow custom headers/mimetypes and early abort
-		if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
-				// Abort if not done already
-				jqXHR.abort();
-				return false;
-
-		}
-
-		// Install callbacks on deferreds
-		for ( i in { success: 1, error: 1, complete: 1 } ) {
-			jqXHR[ i ]( s[ i ] );
-		}
-
-		// Get transport
-		transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
-
-		// If no transport, we auto-abort
-		if ( !transport ) {
-			done( -1, "No Transport" );
-		} else {
-			jqXHR.readyState = 1;
-			// Send global event
-			if ( fireGlobals ) {
-				globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
-			}
-			// Timeout
-			if ( s.async && s.timeout > 0 ) {
-				timeoutTimer = setTimeout( function(){
-					jqXHR.abort( "timeout" );
-				}, s.timeout );
-			}
-
-			try {
-				state = 1;
-				transport.send( requestHeaders, done );
-			} catch (e) {
-				// Propagate exception as error if not done
-				if ( state < 2 ) {
-					done( -1, e );
-				// Simply rethrow otherwise
-				} else {
-					jQuery.error( e );
-				}
-			}
-		}
-
-		return jqXHR;
-	},
-
-	// Serialize an array of form elements or a set of
-	// key/values into a query string
-	param: function( a, traditional ) {
-		var s = [],
-			add = function( key, value ) {
-				// If value is a function, invoke it and return its value
-				value = jQuery.isFunction( value ) ? value() : value;
-				s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
-			};
-
-		// Set traditional to true for jQuery <= 1.3.2 behavior.
-		if ( traditional === undefined ) {
-			traditional = jQuery.ajaxSettings.traditional;
-		}
-
-		// If an array was passed in, assume that it is an array of form elements.
-		if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
-			// Serialize the form elements
-			jQuery.each( a, function() {
-				add( this.name, this.value );
-			});
-
-		} else {
-			// If traditional, encode the "old" way (the way 1.3.2 or older
-			// did it), otherwise encode params recursively.
-			for ( var prefix in a ) {
-				buildParams( prefix, a[ prefix ], traditional, add );
-			}
-		}
-
-		// Return the resulting serialization
-		return s.join( "&" ).replace( r20, "+" );
-	}
-});
-
-function buildParams( prefix, obj, traditional, add ) {
-	if ( jQuery.isArray( obj ) ) {
-		// Serialize array item.
-		jQuery.each( obj, function( i, v ) {
-			if ( traditional || rbracket.test( prefix ) ) {
-				// Treat each array item as a scalar.
-				add( prefix, v );
-
-			} else {
-				// If array item is non-scalar (array or object), encode its
-				// numeric index to resolve deserialization ambiguity issues.
-				// Note that rack (as of 1.0.0) can't currently deserialize
-				// nested arrays properly, and attempting to do so may cause
-				// a server error. Possible fixes are to modify rack's
-				// deserialization algorithm or to provide an option or flag
-				// to force array serialization to be shallow.
-				buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
-			}
-		});
-
-	} else if ( !traditional && obj != null && typeof obj === "object" ) {
-		// Serialize object item.
-		for ( var name in obj ) {
-			buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
-		}
-
-	} else {
-		// Serialize scalar item.
-		add( prefix, obj );
-	}
-}
-
-// This is still on the jQuery object... for now
-// Want to move this to jQuery.ajax some day
-jQuery.extend({
-
-	// Counter for holding the number of active queries
-	active: 0,
-
-	// Last-Modified header cache for next request
-	lastModified: {},
-	etag: {}
-
-});
-
-/* Handles responses to an ajax request:
- * - sets all responseXXX fields accordingly
- * - finds the right dataType (mediates between content-type and expected dataType)
- * - returns the corresponding response
- */
-function ajaxHandleResponses( s, jqXHR, responses ) {
-
-	var contents = s.contents,
-		dataTypes = s.dataTypes,
-		responseFields = s.responseFields,
-		ct,
-		type,
-		finalDataType,
-		firstDataType;
-
-	// Fill responseXXX fields
-	for( type in responseFields ) {
-		if ( type in responses ) {
-			jqXHR[ responseFields[type] ] = responses[ type ];
-		}
-	}
-
-	// Remove auto dataType and get content-type in the process
-	while( dataTypes[ 0 ] === "*" ) {
-		dataTypes.shift();
-		if ( ct === undefined ) {
-			ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
-		}
-	}
-
-	// Check if we're dealing with a known content-type
-	if ( ct ) {
-		for ( type in contents ) {
-			if ( contents[ type ] && contents[ type ].test( ct ) ) {
-				dataTypes.unshift( type );
-				break;
-			}
-		}
-	}
-
-	// Check to see if we have a response for the expected dataType
-	if ( dataTypes[ 0 ] in responses ) {
-		finalDataType = dataTypes[ 0 ];
-	} else {
-		// Try convertible dataTypes
-		for ( type in responses ) {
-			if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
-				finalDataType = type;
-				break;
-			}
-			if ( !firstDataType ) {
-				firstDataType = type;
-			}
-		}
-		// Or just use first one
-		finalDataType = finalDataType || firstDataType;
-	}
-
-	// If we found a dataType
-	// We add the dataType to the list if needed
-	// and return the corresponding response
-	if ( finalDataType ) {
-		if ( finalDataType !== dataTypes[ 0 ] ) {
-			dataTypes.unshift( finalDataType );
-		}
-		return responses[ finalDataType ];
-	}
-}
-
-// Chain conversions given the request and the original response
-function ajaxConvert( s, response ) {
-
-	// Apply the dataFilter if provided
-	if ( s.dataFilter ) {
-		response = s.dataFilter( response, s.dataType );
-	}
-
-	var dataTypes = s.dataTypes,
-		converters = {},
-		i,
-		key,
-		length = dataTypes.length,
-		tmp,
-		// Current and previous dataTypes
-		current = dataTypes[ 0 ],
-		prev,
-		// Conversion expression
-		conversion,
-		// Conversion function
-		conv,
-		// Conversion functions (transitive conversion)
-		conv1,
-		conv2;
-
-	// For each dataType in the chain
-	for( i = 1; i < length; i++ ) {
-
-		// Create converters map
-		// with lowercased keys
-		if ( i === 1 ) {
-			for( key in s.converters ) {
-				if( typeof key === "string" ) {
-					converters[ key.toLowerCase() ] = s.converters[ key ];
-				}
-			}
-		}
-
-		// Get the dataTypes
-		prev = current;
-		current = dataTypes[ i ];
-
-		// If current is auto dataType, update it to prev
-		if( current === "*" ) {
-			current = prev;
-		// If no auto and dataTypes are actually different
-		} else if ( prev !== "*" && prev !== current ) {
-
-			// Get the converter
-			conversion = prev + " " + current;
-			conv = converters[ conversion ] || converters[ "* " + current ];
-
-			// If there is no direct converter, search transitively
-			if ( !conv ) {
-				conv2 = undefined;
-				for( conv1 in converters ) {
-					tmp = conv1.split( " " );
-					if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
-						conv2 = converters[ tmp[1] + " " + current ];
-						if ( conv2 ) {
-							conv1 = converters[ conv1 ];
-							if ( conv1 === true ) {
-								conv = conv2;
-							} else if ( conv2 === true ) {
-								conv = conv1;
-							}
-							break;
-						}
-					}
-				}
-			}
-			// If we found no converter, dispatch an error
-			if ( !( conv || conv2 ) ) {
-				jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
-			}
-			// If found converter is not an equivalence
-			if ( conv !== true ) {
-				// Convert with 1 or 2 converters accordingly
-				response = conv ? conv( response ) : conv2( conv1(response) );
-			}
-		}
-	}
-	return response;
-}
-
-
-
-
-var jsc = jQuery.now(),
-	jsre = /(\=)\?(&|$)|\?\?/i;
-
-// Default jsonp settings
-jQuery.ajaxSetup({
-	jsonp: "callback",
-	jsonpCallback: function() {
-		return jQuery.expando + "_" + ( jsc++ );
-	}
-});
-
-// Detect, normalize options and install callbacks for jsonp requests
-jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
-
-	var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
-		( typeof s.data === "string" );
-
-	if ( s.dataTypes[ 0 ] === "jsonp" ||
-		s.jsonp !== false && ( jsre.test( s.url ) ||
-				inspectData && jsre.test( s.data ) ) ) {
-
-		var responseContainer,
-			jsonpCallback = s.jsonpCallback =
-				jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
-			previous = window[ jsonpCallback ],
-			url = s.url,
-			data = s.data,
-			replace = "$1" + jsonpCallback + "$2";
-
-		if ( s.jsonp !== false ) {
-			url = url.replace( jsre, replace );
-			if ( s.url === url ) {
-				if ( inspectData ) {
-					data = data.replace( jsre, replace );
-				}
-				if ( s.data === data ) {
-					// Add callback manually
-					url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
-				}
-			}
-		}
-
-		s.url = url;
-		s.data = data;
-
-		// Install callback
-		window[ jsonpCallback ] = function( response ) {
-			responseContainer = [ response ];
-		};
-
-		// Clean-up function
-		jqXHR.always(function() {
-			// Set callback back to previous value
-			window[ jsonpCallback ] = previous;
-			// Call if it was a function and we have a response
-			if ( responseContainer && jQuery.isFunction( previous ) ) {
-				window[ jsonpCallback ]( responseContainer[ 0 ] );
-			}
-		});
-
-		// Use data converter to retrieve json after script execution
-		s.converters["script json"] = function() {
-			if ( !responseContainer ) {
-				jQuery.error( jsonpCallback + " was not called" );
-			}
-			return responseContainer[ 0 ];
-		};
-
-		// force json dataType
-		s.dataTypes[ 0 ] = "json";
-
-		// Delegate to script
-		return "script";
-	}
-});
-
-
-
-
-// Install script dataType
-jQuery.ajaxSetup({
-	accepts: {
-		script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
-	},
-	contents: {
-		script: /javascript|ecmascript/
-	},
-	converters: {
-		"text script": function( text ) {
-			jQuery.globalEval( text );
-			return text;
-		}
-	}
-});
-
-// Handle cache's special case and global
-jQuery.ajaxPrefilter( "script", function( s ) {
-	if ( s.cache === undefined ) {
-		s.cache = false;
-	}
-	if ( s.crossDomain ) {
-		s.type = "GET";
-		s.global = false;
-	}
-});
-
-// Bind script tag hack transport
-jQuery.ajaxTransport( "script", function(s) {
-
-	// This transport only deals with cross domain requests
-	if ( s.crossDomain ) {
-
-		var script,
-			head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
-
-		return {
-
-			send: function( _, callback ) {
-
-				script = document.createElement( "script" );
-
-				script.async = "async";
-
-				if ( s.scriptCharset ) {
-					script.charset = s.scriptCharset;
-				}
-
-				script.src = s.url;
-
-				// Attach handlers for all browsers
-				script.onload = script.onreadystatechange = function( _, isAbort ) {
-
-					if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
-
-						// Handle memory leak in IE
-						script.onload = script.onreadystatechange = null;
-
-						// Remove the script
-						if ( head && script.parentNode ) {
-							head.removeChild( script );
-						}
-
-						// Dereference the script
-						script = undefined;
-
-						// Callback if not abort
-						if ( !isAbort ) {
-							callback( 200, "success" );
-						}
-					}
-				};
-				// Use insertBefore instead of appendChild  to circumvent an IE6 bug.
-				// This arises when a base node is used (#2709 and #4378).
-				head.insertBefore( script, head.firstChild );
-			},
-
-			abort: function() {
-				if ( script ) {
-					script.onload( 0, 1 );
-				}
-			}
-		};
-	}
-});
-
-
-
-
-var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
-	xhrOnUnloadAbort = window.ActiveXObject ? function() {
-		// Abort all pending requests
-		for ( var key in xhrCallbacks ) {
-			xhrCallbacks[ key ]( 0, 1 );
-		}
-	} : false,
-	xhrId = 0,
-	xhrCallbacks;
-
-// Functions to create xhrs
-function createStandardXHR() {
-	try {
-		return new window.XMLHttpRequest();
-	} catch( e ) {}
-}
-
-function createActiveXHR() {
-	try {
-		return new window.ActiveXObject( "Microsoft.XMLHTTP" );
-	} catch( e ) {}
-}
-
-// Create the request object
-// (This is still attached to ajaxSettings for backward compatibility)
-jQuery.ajaxSettings.xhr = window.ActiveXObject ?
-	/* Microsoft failed to properly
-	 * implement the XMLHttpRequest in IE7 (can't request local files),
-	 * so we use the ActiveXObject when it is available
-	 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
-	 * we need a fallback.
-	 */
-	function() {
-		return !this.isLocal && createStandardXHR() || createActiveXHR();
-	} :
-	// For all other browsers, use the standard XMLHttpRequest object
-	createStandardXHR;
-
-// Determine support properties
-(function( xhr ) {
-	jQuery.extend( jQuery.support, {
-		ajax: !!xhr,
-		cors: !!xhr && ( "withCredentials" in xhr )
-	});
-})( jQuery.ajaxSettings.xhr() );
-
-// Create transport if the browser can provide an xhr
-if ( jQuery.support.ajax ) {
-
-	jQuery.ajaxTransport(function( s ) {
-		// Cross domain only allowed if supported through XMLHttpRequest
-		if ( !s.crossDomain || jQuery.support.cors ) {
-
-			var callback;
-
-			return {
-				send: function( headers, complete ) {
-
-					// Get a new xhr
-					var xhr = s.xhr(),
-						handle,
-						i;
-
-					// Open the socket
-					// Passing null username, generates a login popup on Opera (#2865)
-					if ( s.username ) {
-						xhr.open( s.type, s.url, s.async, s.username, s.password );
-					} else {
-						xhr.open( s.type, s.url, s.async );
-					}
-
-					// Apply custom fields if provided
-					if ( s.xhrFields ) {
-						for ( i in s.xhrFields ) {
-							xhr[ i ] = s.xhrFields[ i ];
-						}
-					}
-
-					// Override mime type if needed
-					if ( s.mimeType && xhr.overrideMimeType ) {
-						xhr.overrideMimeType( s.mimeType );
-					}
-
-					// X-Requested-With header
-					// For cross-domain requests, seeing as conditions for a preflight are
-					// akin to a jigsaw puzzle, we simply never set it to be sure.
-					// (it can always be set on a per-request basis or even using ajaxSetup)
-					// For same-domain requests, won't change header if already provided.
-					if ( !s.crossDomain && !headers["X-Requested-With"] ) {
-						headers[ "X-Requested-With" ] = "XMLHttpRequest";
-					}
-
-					// Need an extra try/catch for cross domain requests in Firefox 3
-					try {
-						for ( i in headers ) {
-							xhr.setRequestHeader( i, headers[ i ] );
-						}
-					} catch( _ ) {}
-
-					// Do send the request
-					// This may raise an exception which is actually
-					// handled in jQuery.ajax (so no try/catch here)
-					xhr.send( ( s.hasContent && s.data ) || null );
-
-					// Listener
-					callback = function( _, isAbort ) {
-
-						var status,
-							statusText,
-							responseHeaders,
-							responses,
-							xml;
-
-						// Firefox throws exceptions when accessing properties
-						// of an xhr when a network error occured
-						// http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
-						try {
-
-							// Was never called and is aborted or complete
-							if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
-
-								// Only called once
-								callback = undefined;
-
-								// Do not keep as active anymore
-								if ( handle ) {
-									xhr.onreadystatechange = jQuery.noop;
-									if ( xhrOnUnloadAbort ) {
-										delete xhrCallbacks[ handle ];
-									}
-								}
-
-								// If it's an abort
-								if ( isAbort ) {
-									// Abort it manually if needed
-									if ( xhr.readyState !== 4 ) {
-										xhr.abort();
-									}
-								} else {
-									status = xhr.status;
-									responseHeaders = xhr.getAllResponseHeaders();
-									responses = {};
-									xml = xhr.responseXML;
-
-									// Construct response list
-									if ( xml && xml.documentElement /* #4958 */ ) {
-										responses.xml = xml;
-									}
-									responses.text = xhr.responseText;
-
-									// Firefox throws an exception when accessing
-									// statusText for faulty cross-domain requests
-									try {
-										statusText = xhr.statusText;
-									} catch( e ) {
-										// We normalize with Webkit giving an empty statusText
-										statusText = "";
-									}
-
-									// Filter status for non standard behaviors
-
-									// If the request is local and we have data: assume a success
-									// (success with no data won't get notified, that's the best we
-									// can do given current implementations)
-									if ( !status && s.isLocal && !s.crossDomain ) {
-										status = responses.text ? 200 : 404;
-									// IE - #1450: sometimes returns 1223 when it should be 204
-									} else if ( status === 1223 ) {
-										status = 204;
-									}
-								}
-							}
-						} catch( firefoxAccessException ) {
-							if ( !isAbort ) {
-								complete( -1, firefoxAccessException );
-							}
-						}
-
-						// Call complete if needed
-						if ( responses ) {
-							complete( status, statusText, responses, responseHeaders );
-						}
-					};
-
-					// if we're in sync mode or it's in cache
-					// and has been retrieved directly (IE6 & IE7)
-					// we need to manually fire the callback
-					if ( !s.async || xhr.readyState === 4 ) {
-						callback();
-					} else {
-						handle = ++xhrId;
-						if ( xhrOnUnloadAbort ) {
-							// Create the active xhrs callbacks list if needed
-							// and attach the unload handler
-							if ( !xhrCallbacks ) {
-								xhrCallbacks = {};
-								jQuery( window ).unload( xhrOnUnloadAbort );
-							}
-							// Add to list of active xhrs callbacks
-							xhrCallbacks[ handle ] = callback;
-						}
-						xhr.onreadystatechange = callback;
-					}
-				},
-
-				abort: function() {
-					if ( callback ) {
-						callback(0,1);
-					}
-				}
-			};
-		}
-	});
-}
-
-
-
-
-var elemdisplay = {},
-	iframe, iframeDoc,
-	rfxtypes = /^(?:toggle|show|hide)$/,
-	rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
-	timerId,
-	fxAttrs = [
-		// height animations
-		[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
-		// width animations
-		[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
-		// opacity animations
-		[ "opacity" ]
-	],
-	fxNow;
-
-jQuery.fn.extend({
-	show: function( speed, easing, callback ) {
-		var elem, display;
-
-		if ( speed || speed === 0 ) {
-			return this.animate( genFx("show", 3), speed, easing, callback);
-
-		} else {
-			for ( var i = 0, j = this.length; i < j; i++ ) {
-				elem = this[i];
-
-				if ( elem.style ) {
-					display = elem.style.display;
-
-					// Reset the inline display of this element to learn if it is
-					// being hidden by cascaded rules or not
-					if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
-						display = elem.style.display = "";
-					}
-
-					// Set elements which have been overridden with display: none
-					// in a stylesheet to whatever the default browser style is
-					// for such an element
-					if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
-						jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
-					}
-				}
-			}
-
-			// Set the display of most of the elements in a second loop
-			// to avoid the constant reflow
-			for ( i = 0; i < j; i++ ) {
-				elem = this[i];
-
-				if ( elem.style ) {
-					display = elem.style.display;
-
-					if ( display === "" || display === "none" ) {
-						elem.style.display = jQuery._data(elem, "olddisplay") || "";
-					}
-				}
-			}
-
-			return this;
-		}
-	},
-
-	hide: function( speed, easing, callback ) {
-		if ( speed || speed === 0 ) {
-			return this.animate( genFx("hide", 3), speed, easing, callback);
-
-		} else {
-			for ( var i = 0, j = this.length; i < j; i++ ) {
-				if ( this[i].style ) {
-					var display = jQuery.css( this[i], "display" );
-
-					if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
-						jQuery._data( this[i], "olddisplay", display );
-					}
-				}
-			}
-
-			// Set the display of the elements in a second loop
-			// to avoid the constant reflow
-			for ( i = 0; i < j; i++ ) {
-				if ( this[i].style ) {
-					this[i].style.display = "none";
-				}
-			}
-
-			return this;
-		}
-	},
-
-	// Save the old toggle function
-	_toggle: jQuery.fn.toggle,
-
-	toggle: function( fn, fn2, callback ) {
-		var bool = typeof fn === "boolean";
-
-		if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
-			this._toggle.apply( this, arguments );
-
-		} else if ( fn == null || bool ) {
-			this.each(function() {
-				var state = bool ? fn : jQuery(this).is(":hidden");
-				jQuery(this)[ state ? "show" : "hide" ]();
-			});
-
-		} else {
-			this.animate(genFx("toggle", 3), fn, fn2, callback);
-		}
-
-		return this;
-	},
-
-	fadeTo: function( speed, to, easing, callback ) {
-		return this.filter(":hidden").css("opacity", 0).show().end()
-					.animate({opacity: to}, speed, easing, callback);
-	},
-
-	animate: function( prop, speed, easing, callback ) {
-		var optall = jQuery.speed(speed, easing, callback);
-
-		if ( jQuery.isEmptyObject( prop ) ) {
-			return this.each( optall.complete, [ false ] );
-		}
-
-		// Do not change referenced properties as per-property easing will be lost
-		prop = jQuery.extend( {}, prop );
-
-		return this[ optall.queue === false ? "each" : "queue" ](function() {
-			// XXX 'this' does not always have a nodeName when running the
-			// test suite
-
-			if ( optall.queue === false ) {
-				jQuery._mark( this );
-			}
-
-			var opt = jQuery.extend( {}, optall ),
-				isElement = this.nodeType === 1,
-				hidden = isElement && jQuery(this).is(":hidden"),
-				name, val, p,
-				display, e,
-				parts, start, end, unit;
-
-			// will store per property easing and be used to determine when an animation is complete
-			opt.animatedProperties = {};
-
-			for ( p in prop ) {
-
-				// property name normalization
-				name = jQuery.camelCase( p );
-				if ( p !== name ) {
-					prop[ name ] = prop[ p ];
-					delete prop[ p ];
-				}
-
-				val = prop[ name ];
-
-				// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
-				if ( jQuery.isArray( val ) ) {
-					opt.animatedProperties[ name ] = val[ 1 ];
-					val = prop[ name ] = val[ 0 ];
-				} else {
-					opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
-				}
-
-				if ( val === "hide" && hidden || val === "show" && !hidden ) {
-					return opt.complete.call( this );
-				}
-
-				if ( isElement && ( name === "height" || name === "width" ) ) {
-					// Make sure that nothing sneaks out
-					// Record all 3 overflow attributes because IE does not
-					// change the overflow attribute when overflowX and
-					// overflowY are set to the same value
-					opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
-
-					// Set display property to inline-block for height/width
-					// animations on inline elements that are having width/height
-					// animated
-					if ( jQuery.css( this, "display" ) === "inline" &&
-							jQuery.css( this, "float" ) === "none" ) {
-						if ( !jQuery.support.inlineBlockNeedsLayout ) {
-							this.style.display = "inline-block";
-
-						} else {
-							display = defaultDisplay( this.nodeName );
-
-							// inline-level elements accept inline-block;
-							// block-level elements need to be inline with layout
-							if ( display === "inline" ) {
-								this.style.display = "inline-block";
-
-							} else {
-								this.style.display = "inline";
-								this.style.zoom = 1;
-							}
-						}
-					}
-				}
-			}
-
-			if ( opt.overflow != null ) {
-				this.style.overflow = "hidden";
-			}
-
-			for ( p in prop ) {
-				e = new jQuery.fx( this, opt, p );
-				val = prop[ p ];
-
-				if ( rfxtypes.test(val) ) {
-					e[ val === "toggle" ? hidden ? "show" : "hide" : val ]();
-
-				} else {
-					parts = rfxnum.exec( val );
-					start = e.cur();
-
-					if ( parts ) {
-						end = parseFloat( parts[2] );
-						unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
-
-						// We need to compute starting value
-						if ( unit !== "px" ) {
-							jQuery.style( this, p, (end || 1) + unit);
-							start = ((end || 1) / e.cur()) * start;
-							jQuery.style( this, p, start + unit);
-						}
-
-						// If a +=/-= token was provided, we're doing a relative animation
-						if ( parts[1] ) {
-							end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
-						}
-
-						e.custom( start, end, unit );
-
-					} else {
-						e.custom( start, val, "" );
-					}
-				}
-			}
-
-			// For JS strict compliance
-			return true;
-		});
-	},
-
-	stop: function( clearQueue, gotoEnd ) {
-		if ( clearQueue ) {
-			this.queue([]);
-		}
-
-		this.each(function() {
-			var timers = jQuery.timers,
-				i = timers.length;
-			// clear marker counters if we know they won't be
-			if ( !gotoEnd ) {
-				jQuery._unmark( true, this );
-			}
-			while ( i-- ) {
-				if ( timers[i].elem === this ) {
-					if (gotoEnd) {
-						// force the next step to be the last
-						timers[i](true);
-					}
-
-					timers.splice(i, 1);
-				}
-			}
-		});
-
-		// start the next in the queue if the last step wasn't forced
-		if ( !gotoEnd ) {
-			this.dequeue();
-		}
-
-		return this;
-	}
-
-});
-
-// Animations created synchronously will run synchronously
-function createFxNow() {
-	setTimeout( clearFxNow, 0 );
-	return ( fxNow = jQuery.now() );
-}
-
-function clearFxNow() {
-	fxNow = undefined;
-}
-
-// Generate parameters to create a standard animation
-function genFx( type, num ) {
-	var obj = {};
-
-	jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
-		obj[ this ] = type;
-	});
-
-	return obj;
-}
-
-// Generate shortcuts for custom animations
-jQuery.each({
-	slideDown: genFx("show", 1),
-	slideUp: genFx("hide", 1),
-	slideToggle: genFx("toggle", 1),
-	fadeIn: { opacity: "show" },
-	fadeOut: { opacity: "hide" },
-	fadeToggle: { opacity: "toggle" }
-}, function( name, props ) {
-	jQuery.fn[ name ] = function( speed, easing, callback ) {
-		return this.animate( props, speed, easing, callback );
-	};
-});
-
-jQuery.extend({
-	speed: function( speed, easing, fn ) {
-		var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
-			complete: fn || !fn && easing ||
-				jQuery.isFunction( speed ) && speed,
-			duration: speed,
-			easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
-		};
-
-		opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
-			opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
-
-		// Queueing
-		opt.old = opt.complete;
-		opt.complete = function( noUnmark ) {
-			if ( jQuery.isFunction( opt.old ) ) {
-				opt.old.call( this );
-			}
-
-			if ( opt.queue !== false ) {
-				jQuery.dequeue( this );
-			} else if ( noUnmark !== false ) {
-				jQuery._unmark( this );
-			}
-		};
-
-		return opt;
-	},
-
-	easing: {
-		linear: function( p, n, firstNum, diff ) {
-			return firstNum + diff * p;
-		},
-		swing: function( p, n, firstNum, diff ) {
-			return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
-		}
-	},
-
-	timers: [],
-
-	fx: function( elem, options, prop ) {
-		this.options = options;
-		this.elem = elem;
-		this.prop = prop;
-
-		options.orig = options.orig || {};
-	}
-
-});
-
-jQuery.fx.prototype = {
-	// Simple function for setting a style value
-	update: function() {
-		if ( this.options.step ) {
-			this.options.step.call( this.elem, this.now, this );
-		}
-
-		(jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
-	},
-
-	// Get the current size
-	cur: function() {
-		if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
-			return this.elem[ this.prop ];
-		}
-
-		var parsed,
-			r = jQuery.css( this.elem, this.prop );
-		// Empty strings, null, undefined and "auto" are converted to 0,
-		// complex values such as "rotate(1rad)" are returned as is,
-		// simple values such as "10px" are parsed to Float.
-		return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
-	},
-
-	// Start an animation from one number to another
-	custom: function( from, to, unit ) {
-		var self = this,
-			fx = jQuery.fx;
-
-		this.startTime = fxNow || createFxNow();
-		this.start = from;
-		this.end = to;
-		this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
-		this.now = this.start;
-		this.pos = this.state = 0;
-
-		function t( gotoEnd ) {
-			return self.step(gotoEnd);
-		}
-
-		t.elem = this.elem;
-
-		if ( t() && jQuery.timers.push(t) && !timerId ) {
-			timerId = setInterval( fx.tick, fx.interval );
-		}
-	},
-
-	// Simple 'show' function
-	show: function() {
-		// Remember where we started, so that we can go back to it later
-		this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
-		this.options.show = true;
-
-		// Begin the animation
-		// Make sure that we start at a small width/height to avoid any
-		// flash of content
-		this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
-
-		// Start by showing the element
-		jQuery( this.elem ).show();
-	},
-
-	// Simple 'hide' function
-	hide: function() {
-		// Remember where we started, so that we can go back to it later
-		this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
-		this.options.hide = true;
-
-		// Begin the animation
-		this.custom(this.cur(), 0);
-	},
-
-	// Each step of an animation
-	step: function( gotoEnd ) {
-		var t = fxNow || createFxNow(),
-			done = true,
-			elem = this.elem,
-			options = this.options,
-			i, n;
-
-		if ( gotoEnd || t >= options.duration + this.startTime ) {
-			this.now = this.end;
-			this.pos = this.state = 1;
-			this.update();
-
-			options.animatedProperties[ this.prop ] = true;
-
-			for ( i in options.animatedProperties ) {
-				if ( options.animatedProperties[i] !== true ) {
-					done = false;
-				}
-			}
-
-			if ( done ) {
-				// Reset the overflow
-				if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
-
-					jQuery.each( [ "", "X", "Y" ], function (index, value) {
-						elem.style[ "overflow" + value ] = options.overflow[index];
-					});
-				}
-
-				// Hide the element if the "hide" operation was done
-				if ( options.hide ) {
-					jQuery(elem).hide();
-				}
-
-				// Reset the properties, if the item has been hidden or shown
-				if ( options.hide || options.show ) {
-					for ( var p in options.animatedProperties ) {
-						jQuery.style( elem, p, options.orig[p] );
-					}
-				}
-
-				// Execute the complete function
-				options.complete.call( elem );
-			}
-
-			return false;
-
-		} else {
-			// classical easing cannot be used with an Infinity duration
-			if ( options.duration == Infinity ) {
-				this.now = t;
-			} else {
-				n = t - this.startTime;
-				this.state = n / options.duration;
-
-				// Perform the easing function, defaults to swing
-				this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration );
-				this.now = this.start + ((this.end - this.start) * this.pos);
-			}
-			// Perform the next step of the animation
-			this.update();
-		}
-
-		return true;
-	}
-};
-
-jQuery.extend( jQuery.fx, {
-	tick: function() {
-		for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) {
-			if ( !timers[i]() ) {
-				timers.splice(i--, 1);
-			}
-		}
-
-		if ( !timers.length ) {
-			jQuery.fx.stop();
-		}
-	},
-
-	interval: 13,
-
-	stop: function() {
-		clearInterval( timerId );
-		timerId = null;
-	},
-
-	speeds: {
-		slow: 600,
-		fast: 200,
-		// Default speed
-		_default: 400
-	},
-
-	step: {
-		opacity: function( fx ) {
-			jQuery.style( fx.elem, "opacity", fx.now );
-		},
-
-		_default: function( fx ) {
-			if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
-				fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
-			} else {
-				fx.elem[ fx.prop ] = fx.now;
-			}
-		}
-	}
-});
-
-if ( jQuery.expr && jQuery.expr.filters ) {
-	jQuery.expr.filters.animated = function( elem ) {
-		return jQuery.grep(jQuery.timers, function( fn ) {
-			return elem === fn.elem;
-		}).length;
-	};
-}
-
-// Try to restore the default display value of an element
-function defaultDisplay( nodeName ) {
-
-	if ( !elemdisplay[ nodeName ] ) {
-
-		var body = document.body,
-			elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
-			display = elem.css( "display" );
-
-		elem.remove();
-
-		// If the simple way fails,
-		// get element's real default display by attaching it to a temp iframe
-		if ( display === "none" || display === "" ) {
-			// No iframe to use yet, so create it
-			if ( !iframe ) {
-				iframe = document.createElement( "iframe" );
-				iframe.frameBorder = iframe.width = iframe.height = 0;
-			}
-
-			body.appendChild( iframe );
-
-			// Create a cacheable copy of the iframe document on first call.
-			// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
-			// document to it; WebKit & Firefox won't allow reusing the iframe document.
-			if ( !iframeDoc || !iframe.createElement ) {
-				iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
-				iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
-				iframeDoc.close();
-			}
-
-			elem = iframeDoc.createElement( nodeName );
-
-			iframeDoc.body.appendChild( elem );
-
-			display = jQuery.css( elem, "display" );
-
-			body.removeChild( iframe );
-		}
-
-		// Store the correct default display
-		elemdisplay[ nodeName ] = display;
-	}
-
-	return elemdisplay[ nodeName ];
-}
-
-
-
-
-var rtable = /^t(?:able|d|h)$/i,
-	rroot = /^(?:body|html)$/i;
-
-if ( "getBoundingClientRect" in document.documentElement ) {
-	jQuery.fn.offset = function( options ) {
-		var elem = this[0], box;
-
-		if ( options ) {
-			return this.each(function( i ) {
-				jQuery.offset.setOffset( this, options, i );
-			});
-		}
-
-		if ( !elem || !elem.ownerDocument ) {
-			return null;
-		}
-
-		if ( elem === elem.ownerDocument.body ) {
-			return jQuery.offset.bodyOffset( elem );
-		}
-
-		try {
-			box = elem.getBoundingClientRect();
-		} catch(e) {}
-
-		var doc = elem.ownerDocument,
-			docElem = doc.documentElement;
-
-		// Make sure we're not dealing with a disconnected DOM node
-		if ( !box || !jQuery.contains( docElem, elem ) ) {
-			return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
-		}
-
-		var body = doc.body,
-			win = getWindow(doc),
-			clientTop  = docElem.clientTop  || body.clientTop  || 0,
-			clientLeft = docElem.clientLeft || body.clientLeft || 0,
-			scrollTop  = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop  || body.scrollTop,
-			scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
-			top  = box.top  + scrollTop  - clientTop,
-			left = box.left + scrollLeft - clientLeft;
-
-		return { top: top, left: left };
-	};
-
-} else {
-	jQuery.fn.offset = function( options ) {
-		var elem = this[0];
-
-		if ( options ) {
-			return this.each(function( i ) {
-				jQuery.offset.setOffset( this, options, i );
-			});
-		}
-
-		if ( !elem || !elem.ownerDocument ) {
-			return null;
-		}
-
-		if ( elem === elem.ownerDocument.body ) {
-			return jQuery.offset.bodyOffset( elem );
-		}
-
-		jQuery.offset.initialize();
-
-		var computedStyle,
-			offsetParent = elem.offsetParent,
-			prevOffsetParent = elem,
-			doc = elem.ownerDocument,
-			docElem = doc.documentElement,
-			body = doc.body,
-			defaultView = doc.defaultView,
-			prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
-			top = elem.offsetTop,
-			left = elem.offsetLeft;
-
-		while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
-			if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
-				break;
-			}
-
-			computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
-			top  -= elem.scrollTop;
-			left -= elem.scrollLeft;
-
-			if ( elem === offsetParent ) {
-				top  += elem.offsetTop;
-				left += elem.offsetLeft;
-
-				if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
-					top  += parseFloat( computedStyle.borderTopWidth  ) || 0;
-					left += parseFloat( computedStyle.borderLeftWidth ) || 0;
-				}
-
-				prevOffsetParent = offsetParent;
-				offsetParent = elem.offsetParent;
-			}
-
-			if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
-				top  += parseFloat( computedStyle.borderTopWidth  ) || 0;
-				left += parseFloat( computedStyle.borderLeftWidth ) || 0;
-			}
-
-			prevComputedStyle = computedStyle;
-		}
-
-		if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
-			top  += body.offsetTop;
-			left += body.offsetLeft;
-		}
-
-		if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
-			top  += Math.max( docElem.scrollTop, body.scrollTop );
-			left += Math.max( docElem.scrollLeft, body.scrollLeft );
-		}
-
-		return { top: top, left: left };
-	};
-}
-
-jQuery.offset = {
-	initialize: function() {
-		var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
-			html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
-
-		jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
-
-		container.innerHTML = html;
-		body.insertBefore( container, body.firstChild );
-		innerDiv = container.firstChild;
-		checkDiv = innerDiv.firstChild;
-		td = innerDiv.nextSibling.firstChild.firstChild;
-
-		this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
-		this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
-
-		checkDiv.style.position = "fixed";
-		checkDiv.style.top = "20px";
-
-		// safari subtracts parent border width here which is 5px
-		this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
-		checkDiv.style.position = checkDiv.style.top = "";
-
-		innerDiv.style.overflow = "hidden";
-		innerDiv.style.position = "relative";
-
-		this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
-
-		this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
-
-		body.removeChild( container );
-		jQuery.offset.initialize = jQuery.noop;
-	},
-
-	bodyOffset: function( body ) {
-		var top = body.offsetTop,
-			left = body.offsetLeft;
-
-		jQuery.offset.initialize();
-
-		if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
-			top  += parseFloat( jQuery.css(body, "marginTop") ) || 0;
-			left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
-		}
-
-		return { top: top, left: left };
-	},
-
-	setOffset: function( elem, options, i ) {
-		var position = jQuery.css( elem, "position" );
-
-		// set position first, in-case top/left are set even on static elem
-		if ( position === "static" ) {
-			elem.style.position = "relative";
-		}
-
-		var curElem = jQuery( elem ),
-			curOffset = curElem.offset(),
-			curCSSTop = jQuery.css( elem, "top" ),
-			curCSSLeft = jQuery.css( elem, "left" ),
-			calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
-			props = {}, curPosition = {}, curTop, curLeft;
-
-		// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
-		if ( calculatePosition ) {
-			curPosition = curElem.position();
-			curTop = curPosition.top;
-			curLeft = curPosition.left;
-		} else {
-			curTop = parseFloat( curCSSTop ) || 0;
-			curLeft = parseFloat( curCSSLeft ) || 0;
-		}
-
-		if ( jQuery.isFunction( options ) ) {
-			options = options.call( elem, i, curOffset );
-		}
-
-		if (options.top != null) {
-			props.top = (options.top - curOffset.top) + curTop;
-		}
-		if (options.left != null) {
-			props.left = (options.left - curOffset.left) + curLeft;
-		}
-
-		if ( "using" in options ) {
-			options.using.call( elem, props );
-		} else {
-			curElem.css( props );
-		}
-	}
-};
-
-
-jQuery.fn.extend({
-	position: function() {
-		if ( !this[0] ) {
-			return null;
-		}
-
-		var elem = this[0],
-
-		// Get *real* offsetParent
-		offsetParent = this.offsetParent(),
-
-		// Get correct offsets
-		offset       = this.offset(),
-		parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
-
-		// Subtract element margins
-		// note: when an element has margin: auto the offsetLeft and marginLeft
-		// are the same in Safari causing offset.left to incorrectly be 0
-		offset.top  -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
-		offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
-
-		// Add offsetParent borders
-		parentOffset.top  += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
-		parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
-
-		// Subtract the two offsets
-		return {
-			top:  offset.top  - parentOffset.top,
-			left: offset.left - parentOffset.left
-		};
-	},
-
-	offsetParent: function() {
-		return this.map(function() {
-			var offsetParent = this.offsetParent || document.body;
-			while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
-				offsetParent = offsetParent.offsetParent;
-			}
-			return offsetParent;
-		});
-	}
-});
-
-
-// Create scrollLeft and scrollTop methods
-jQuery.each( ["Left", "Top"], function( i, name ) {
-	var method = "scroll" + name;
-
-	jQuery.fn[ method ] = function( val ) {
-		var elem, win;
-
-		if ( val === undefined ) {
-			elem = this[ 0 ];
-
-			if ( !elem ) {
-				return null;
-			}
-
-			win = getWindow( elem );
-
-			// Return the scroll offset
-			return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
-				jQuery.support.boxModel && win.document.documentElement[ method ] ||
-					win.document.body[ method ] :
-				elem[ method ];
-		}
-
-		// Set the scroll offset
-		return this.each(function() {
-			win = getWindow( this );
-
-			if ( win ) {
-				win.scrollTo(
-					!i ? val : jQuery( win ).scrollLeft(),
-					 i ? val : jQuery( win ).scrollTop()
-				);
-
-			} else {
-				this[ method ] = val;
-			}
-		});
-	};
-});
-
-function getWindow( elem ) {
-	return jQuery.isWindow( elem ) ?
-		elem :
-		elem.nodeType === 9 ?
-			elem.defaultView || elem.parentWindow :
-			false;
-}
-
-
-
-
-// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
-jQuery.each([ "Height", "Width" ], function( i, name ) {
-
-	var type = name.toLowerCase();
-
-	// innerHeight and innerWidth
-	jQuery.fn[ "inner" + name ] = function() {
-		var elem = this[0];
-		return elem && elem.style ?
-			parseFloat( jQuery.css( elem, type, "padding" ) ) :
-			null;
-	};
-
-	// outerHeight and outerWidth
-	jQuery.fn[ "outer" + name ] = function( margin ) {
-		var elem = this[0];
-		return elem && elem.style ?
-			parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
-			null;
-	};
-
-	jQuery.fn[ type ] = function( size ) {
-		// Get window width or height
-		var elem = this[0];
-		if ( !elem ) {
-			return size == null ? null : this;
-		}
-
-		if ( jQuery.isFunction( size ) ) {
-			return this.each(function( i ) {
-				var self = jQuery( this );
-				self[ type ]( size.call( this, i, self[ type ]() ) );
-			});
-		}
-
-		if ( jQuery.isWindow( elem ) ) {
-			// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
-			// 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
-			var docElemProp = elem.document.documentElement[ "client" + name ],
-				body = elem.document.body;
-			return elem.document.compatMode === "CSS1Compat" && docElemProp ||
-				body && body[ "client" + name ] || docElemProp;
-
-		// Get document width or height
-		} else if ( elem.nodeType === 9 ) {
-			// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
-			return Math.max(
-				elem.documentElement["client" + name],
-				elem.body["scroll" + name], elem.documentElement["scroll" + name],
-				elem.body["offset" + name], elem.documentElement["offset" + name]
-			);
-
-		// Get or set width or height on the element
-		} else if ( size === undefined ) {
-			var orig = jQuery.css( elem, type ),
-				ret = parseFloat( orig );
-
-			return jQuery.isNaN( ret ) ? orig : ret;
-
-		// Set the width or height on the element (default to pixels if value is unitless)
-		} else {
-			return this.css( type, typeof size === "string" ? size : size + "px" );
-		}
-	};
-
-});
-
-
-// Expose jQuery to the global object
-window.jQuery = window.$ = jQuery;
-})(window);
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.min.js
deleted file mode 100644
index 628ed9b..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/jquery.min.js
+++ /dev/null
@@ -1,4 +0,0 @@
-/*! jQuery v1.6.4 http://jquery.com/ | http://jquery.org/license */
-(function(a,b){function cu(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cr(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>"),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cq(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cp(){cn=b}function co(){setTimeout(cp,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function bZ(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function bY(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bA.test(a)?d(a,e):bY(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)bY(a+"["+e+"]",b[e],c,d);else d(a,b)}function bX(a,c){var d,e,g=f.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((g[d]?a:e||(e={}))[d]=c[d]);e&&f.extend(!0,a,e)}function bW(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bP,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bW(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bW(a,c,d,e,"*",g));return l}function bV(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bL),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function by(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?bt:bu;if(d>0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bv(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bl(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bd,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bk(a){f.nodeName(a,"input")?bj(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bj)}function bj(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bi(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bh(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bg(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i<j;i++)f.event.add(b,h+(g[h][i].namespace?".":"")+g[h][i].namespace,g[h][i],g[h][i].data)}}}}function bf(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function V(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(Q.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function U(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function M(a,b){return(a&&a!=="*"?a+".":"")+b.replace(y,"`").replace(z,"&")}function L(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;i<s.length;i++)g=s[i],g.origType.replace(w,"")===a.type?q.push(g.selector):s.splice(i--,1);e=f(a.target).closest(q,a.currentTarget);for(j=0,k=e.length;j<k;j++){m=e[j];for(i=0;i<s.length;i++){g=s[i];if(m.selector===g.selector&&(!n||n.test(g.namespace))&&!m.elem.disabled){h=m.elem,d=null;if(g.preType==="mouseenter"||g.preType==="mouseleave")a.type=g.preType,d=f(a.relatedTarget).closest(g.selector)[0],d&&f.contains(h,d)&&(d=h);(!d||d!==h)&&p.push({elem:h,handleObj:g,level:m.level})}}}for(j=0,k=p.length;j<k;j++){e=p[j];if(c&&e.level>c)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function J(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function D(){return!0}function C(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function K(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(K,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z]|[0-9])/ig,x=/^-ms-/,y=function(a,b){return(b+"").toUpperCase()},z=d.userAgent,A,B,C,D=Object.prototype.toString,E=Object.prototype.hasOwnProperty,F=Array.prototype.push,G=Array.prototype.slice,H=String.prototype.trim,I=Array.prototype.indexOf,J={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.4",length:0,size:function(){return this.length},toArray:function(){return G.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?F.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),B.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(G.apply(this,arguments),"slice",G.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:F,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;B.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!B){B=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",C,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",C),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&K()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):J[D.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!E.call(a,"constructor")&&!E.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||E.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(x,"ms-").replace(w,y)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:H?function(a){return a==null?"":H.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?F.call(c,a):e.merge(c,a)}return c},inArray:function(a,b){if(!b)return-1;if(I)return I.call(b,a);for(var c=0,d=b.length;c<d;c++)if(b[c]===a)return c;return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=G.call(arguments,2),g=function(){return a.apply(c,f.concat(G.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h){var i=a.length;if(typeof c=="object"){for(var j in c)e.access(a,j,c[j],f,g,d);return a}if(d!==b){f=!h&&f&&e.isFunction(d);for(var k=0;k<i;k++)g(a[k],c,f?d.call(a[k],k,g(a[k],c)):d,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=s.exec(a)||t.exec(a)||u.exec(a)||a.indexOf("compatible")<0&&v.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){J["[object "+b+"]"]=b.toLowerCase()}),A=e.uaMatch(z),A.browser&&(e.browser[A.browser]=!0,e.browser.version=A.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?C=function(){c.removeEventListener("DOMContentLoaded",C,!1),e.ready()}:c.attachEvent&&(C=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",C),e.ready())});return e}(),g="done fail isResolved isRejected promise then always pipe".split(" "),h=[].slice;f.extend({_Deferred:function(){var a=[],b,c,d,e={done:function(){if(!d){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=f.type(i),j==="array"?e.done.apply(e,i):j==="function"&&a.push(i);k&&e.resolveWith(k[0],k[1])}return this},resolveWith:function(e,f){if(!d&&!b&&!c){f=f||[],c=1;try{while(a[0])a.shift().apply(e,f)}finally{b=[e,f],c=0}}return this},resolve:function(){e.resolveWith(this,arguments);return this},isResolved:function(){return!!c||!!b},cancel:function(){d=1,a=[];return this}};return e},Deferred:function(a){var b=f._Deferred(),c=f._Deferred(),d;f.extend(b,{then:function(a,c){b.done(a).fail(c);return this},always:function(){return b.done.apply(b,arguments).fail.apply(this,arguments)},fail:c.done,rejectWith:c.resolveWith,reject:c.resolve,isRejected:c.isResolved,pipe:function(a,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[c,"reject"]},function(a,c){var e=c[0],g=c[1],h;f.isFunction(e)?b[a](function(){h=e.apply(this,arguments),h&&f.isFunction(h.promise)?h.promise().then(d.resolve,d.reject):d[g+"With"](this===b?d:this,[h])}):b[a](d[g])})}).promise()},promise:function(a){if(a==null){if(d)return d;d=a={}}var c=g.length;while(c--)a[g[c]]=b[g[c]];return a}}),b.done(c.cancel).fail(b.cancel),delete b.cancel,a&&a.call(b,b);return b},when:function(a){function i(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c<d;c++)b[c]&&f.isFunction(b[c].promise)?b[c].promise().then(i(c),g.reject):--e;e||g.resolveWith(g,b)}else g!==a&&g.resolveWith(g,d?[a]:[]);return g.promise()}}),f.support=function(){var a=c.createElement("div"),b=c.documentElement,d,e,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;a.setAttribute("className","t"),a.innerHTML="   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},m&&f.extend(p,{position:"absolute",left:"-1000px",top:"-1000px"});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="<div style='width:4px;'></div>",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i=f.expando,j=typeof c=="string",k=a.nodeType,l=k?f.cache:a,m=k?a[f.expando]:a[f.expando]&&f.expando;if((!m||e&&m&&l[m]&&!l[m][i])&&j&&d===b)return;m||(k?a[f.expando]=m=++f.uuid:m=f.expando),l[m]||(l[m]={},k||(l[m].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?l[m][i]=f.extend(l[m][i],c):l[m]=f.extend(l[m],c);g=l[m],e&&(g[i]||(g[i]={}),g=g[i]),d!==b&&(g[f.camelCase(c)]=d);if(c==="events"&&!g[c])return g[i]&&g[i].events;j?(h=g[c],h==null&&(h=g[f.camelCase(c)])):h=g;return h}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e=f.expando,g=a.nodeType,h=g?f.cache:a,i=g?a[f.expando]:f.expando;if(!h[i])return;if(b){d=c?h[i][e]:h[i];if(d){d[b]||(b=f.camelCase(b)),delete d[b];if(!l(d))return}}if(c){delete h[i][e];if(!l(h[i]))return}var j=h[i][e];f.support.deleteExpando||!h.setInterval?delete h[i]:h[i]=null,j?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=j):g&&(f.support.deleteExpando?delete a[f.expando]:a.removeAttribute?a.removeAttribute(f.expando):a[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h<i;h++)g=e[h].name,g.indexOf("data-")===0&&(g=f.camelCase(g.substring(5)),k(this[0],g,d[g]))}}return d}if(typeof a=="object")return this.each(function(){f.data(this,a)});var j=a.split(".");j[1]=j[1]?"."+j[1]:"";if(c===b){d=this.triggerHandler("getData"+j[1]+"!",[j[0]]),d===b&&this.length&&(d=f.data(this[0],a),d=k(this[0],a,d));return d===b&&j[1]?this.data(j[0]):d}return this.each(function(){var b=f(this),d=[j[0],c];b.triggerHandler("setData"+j[1]+"!",d),f.data(this,a,c),b.triggerHandler("changeData"+j[1]+"!",d)})},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,c){a&&(c=(c||"fx")+"mark",f.data(a,c,(f.data(a,c,b,!0)||0)+1,!0))},_unmark:function(a,c,d){a!==!0&&(d=c,c=a,a=!1);if(c){d=d||"fx";var e=d+"mark",g=a?0:(f.data(c,e,b,!0)||1)-1;g?f.data(c,e,g,!0):(f.removeData(c,e,!0),m(c,d,"mark"))}},queue:function(a,c,d){if(a){c=(c||"fx")+"queue";var e=f.data(a,c,b,!0);d&&(!e||f.isArray(d)?e=f.data(a,c,f.makeArray(d),!0):e.push(d));return e||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e;d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),d.call(a,function(){f.dequeue(a,b)})),c.length||(f.removeData(a,b+"queue",!0),m(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){typeof a!="string"&&(c=a,a="fx");if(c===b)return f.queue(this[0],a);return this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(){var c=this;setTimeout(function(){f.dequeue(c,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f._Deferred(),!0))h++,l.done(m);m();return d.promise()}});var n=/[\n\t\r]/g,o=/\s+/,p=/\r/g,q=/^(?:button|input)$/i,r=/^(?:button|input|object|select|textarea)$/i,s=/^a(?:rea)?$/i,t=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,u,v;f.fn.extend({attr:function(a,b){return f.access(this,a,b,!0,f.attr)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,a,b,!0,f.prop)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(o);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{g=" "+e.className+" ";for(h=0,i=b.length;h<i;h++)~g.indexOf(" "+b[h]+" ")||(g+=b[h]+" ");e.className=f.trim(g)}}}return this},removeClass:function(a){var c,d,e,g,h,i,j;if(f.isFunction(a))return this.each(function(b){f(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(o);for(d=0,e=this.length;d<e;d++){g=this[d];if(g.nodeType===1&&g.className)if(a){h=(" "+g.className+" ").replace(n," ");for(i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){f(this).toggleClass(a.call(this,c,this.className,b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(o);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ";for(var c=0,d=this.length;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(n," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h<i;h++){var j=e[h];if(j.selected&&(f.support.optDisabled?!j.disabled:j.getAttribute("disabled")===null)&&(!j.parentNode.disabled||!f.nodeName(j.parentNode,"optgroup"))){b=f(j).val();if(g)return b;d.push(b)}}if(g&&!d.length&&e.length)return f(e[c]).val();return d},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=v:u&&(i=u)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.attr(a,b,""),a.removeAttribute(b),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(u&&f.nodeName(a,"button"))return u.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(u&&f.nodeName(a,"button"))return u.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==null?g:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabIndex=f.propHooks.tabIndex,v={get:function(a,c){var d;return f.prop(a,c)===!0||(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(u=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var w=/\.(.*)$/,x=/^(?:textarea|input|select)$/i,y=/\./g,z=/ /g,A=/[^\w\s.|`]/g,B=function(a){return a.replace(A,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=C;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=C);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),B).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j<p.length;j++){q=p[j];if(l||n.test(q.namespace))f.event.remove(a,r,q.handler,j),p.splice(j--,1)}continue}o=f.event.special[h]||{};for(j=e||0;j<p.length;j++){q=p[j];if(d.guid===q.guid){if(l||n.test(q.namespace))e==null&&p.splice(j--,1),o.remove&&o.remove.call(a,q);if(e!=null)break}}if(p.length===0||e!=null&&p.length===1)(!o.teardown||o.teardown.call(a,m)===!1)&&f.removeEvent(a,h,s.handle),g=null,delete 
-t[h]}if(f.isEmptyObject(t)){var u=s.handle;u&&(u.elem=null),delete s.events,delete s.handle,f.isEmptyObject(s)&&f.removeData(a,b,!0)}}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){var h=c.type||c,i=[],j;h.indexOf("!")>=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h<i;h++){var j=d[h];if(e||c.namespace_re.test(j.namespace)){c.handler=j.handler,c.data=j.data,c.handleObj=j;var k=j.handler.apply(this,g);k!==b&&(c.result=k,k===!1&&(c.preventDefault(),c.stopPropagation()));if(c.isImmediatePropagationStopped())break}}return c.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(a){if(a[f.expando])return a;var d=a;a=f.Event(d);for(var e=this.props.length,g;e;)g=this.props[--e],a[g]=d[g];a.target||(a.target=a.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),!a.relatedTarget&&a.fromElement&&(a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement);if(a.pageX==null&&a.clientX!=null){var h=a.target.ownerDocument||c,i=h.documentElement,j=h.body;a.pageX=a.clientX+(i&&i.scrollLeft||j&&j.scrollLeft||0)-(i&&i.clientLeft||j&&j.clientLeft||0),a.pageY=a.clientY+(i&&i.scrollTop||j&&j.scrollTop||0)-(i&&i.clientTop||j&&j.clientTop||0)}a.which==null&&(a.charCode!=null||a.keyCode!=null)&&(a.which=a.charCode!=null?a.charCode:a.keyCode),!a.metaKey&&a.ctrlKey&&(a.metaKey=a.ctrlKey),!a.which&&a.button!==b&&(a.which=a.button&1?1:a.button&2?3:a.button&4?2:0);return a},guid:1e8,proxy:f.proxy,special:{ready:{setup:f.bindReady,teardown:f.noop},live:{add:function(a){f.event.add(this,M(a.origType,a.selector),f.extend({},a,{handler:L,guid:a.handler.guid}))},remove:function(a){f.event.remove(this,M(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}}},f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!this.preventDefault)return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?D:C):this.type=a,b&&f.extend(this,b),this.timeStamp=f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=D;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=D;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=D,this.stopPropagation()},isDefaultPrevented:C,isPropagationStopped:C,isImmediatePropagationStopped:C};var E=function(a){var b=a.relatedTarget,c=!1,d=a.type;a.type=a.data,b!==this&&(b&&(c=f.contains(this,b)),c||(f.event.handle.apply(this,arguments),a.type=d))},F=function(a){a.type=a.data,f.event.handle.apply(this,arguments)};f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={setup:function(c){f.event.add(this,b,c&&c.selector?F:E,a)},teardown:function(a){f.event.remove(this,b,a&&a.selector?F:E)}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(a,b){if(!f.nodeName(this,"form"))f.event.add(this,"click.specialSubmit",function(a){var b=a.target,c=f.nodeName(b,"input")||f.nodeName(b,"button")?b.type:"";(c==="submit"||c==="image")&&f(b).closest("form").length&&J("submit",this,arguments)}),f.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,c=f.nodeName(b,"input")||f.nodeName(b,"button")?b.type:"";(c==="text"||c==="password")&&f(b).closest("form").length&&a.keyCode===13&&J("submit",this,arguments)});else return!1},teardown:function(a){f.event.remove(this,".specialSubmit")}});if(!f.support.changeBubbles){var G,H=function(a){var b=f.nodeName(a,"input")?a.type:"",c=a.value;b==="radio"||b==="checkbox"?c=a.checked:b==="select-multiple"?c=a.selectedIndex>-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},I=function(c){var d=c.target,e,g;if(!!x.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=H(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:I,beforedeactivate:I,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&I.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&I.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",H(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in G)f.event.add(this,c+".specialChange",G[c]);return x.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return x.test(this.nodeName)}},G=f.event.special.change.filters,G.focus=G.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i<j;i++)f.event.add(this[i],a,g,d);return this}}),f.fn.extend({unbind:function(a,b){if(typeof a=="object"&&!a.preventDefault)for(var c in a)this.unbind(c,a[c]);else for(var d=0,e=this.length;d<e;d++)f.event.remove(this[d],a,b);return this},delegate:function(a,b,c,d){return this.live(b,c,d,a)},undelegate:function(a,b,c){return arguments.length===0?this.unbind("live"):this.die(b,null,c,a)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f.data(this,"lastToggle"+a.guid)||0)%d;f.data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var K={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};f.each(["live","die"],function(a,c){f.fn[c]=function(a,d,e,g){var h,i=0,j,k,l,m=g||this.selector,n=g?this:f(this.context);if(typeof a=="object"&&!a.preventDefault){for(var o in a)n[c](o,d,a[o],m);return this}if(c==="die"&&!a&&g&&g.charAt(0)==="."){n.unbind(g);return this}if(d===!1||f.isFunction(d))e=d||C,d=b;a=(a||"").split(" ");while((h=a[i++])!=null){j=w.exec(h),k="",j&&(k=j[0],h=h.replace(w,""));if(h==="hover"){a.push("mouseenter"+k,"mouseleave"+k);continue}l=h,K[h]?(a.push(K[h]+k),h=h+k):h=(K[h]||h)+k;if(c==="live")for(var p=0,q=n.length;p<q;p++)f.event.add(n[p],"live."+M(h,m),{data:d,selector:m,handler:e,origType:h,origHandler:e,preType:l});else n.unbind("live."+M(h,m),e)}return this}}),f.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}if(i.nodeType===1){f||(i.sizcache=c,i.sizset=g);if(typeof b!="string"){if(i===b){j=!0;break}}else if(k.filter(b,[i]).length>0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}i.nodeType===1&&!f&&(i.sizcache=c,i.sizset=g);if(i.nodeName.toLowerCase()===b){j=i;break}i=i[a]}d[g]=j}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},k.matches=function(a,b){return k(a,null,null,b)},k.matchesSelector=function(a,b){return k(b,null,null,[a]).length>0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e<f;e++){var g,h=l.order[e];if(g=l.leftMatch[h].exec(a)){var j=g[1];g.splice(1,1);if(j.substr(j.length-1)!=="\\"){g[1]=(g[1]||"").replace(i,""),d=l.find[h](g,b,c);if(d!=null){a=a.replace(l.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},k.filter=function(a,c,d,e){var f,g,h=a,i=[],j=c,m=c&&c[0]&&k.isXML(c[0]);while(a&&c.length){for(var n in l.filter)if((f=l.leftMatch[n].exec(a))!=null&&f[2]){var o,p,q=l.filter[n],r=f[1];g=!1,f.splice(1,1);if(r.substr(r.length-1)==="\\")continue;j===i&&(i=[]);if(l.preFilter[n]){f=l.preFilter[n](f,j,d,i,e,m);if(!f)g=o=!0;else if(f===!0)continue}if(f)for(var s=0;(p=j[s])!=null;s++)if(p){o=q(p,f,s,j);var t=e^!!o;d&&o!=null?t?g=!0:j[s]=!1:t&&(i.push(p),g=!0)}if(o!==b){d||(j=i),a=a.replace(l.match[n],"");if(!g)return[];break}}if(a===h)if(g==null)k.error(a);else break;h=a}return j},k.error=function(a){throw"Syntax error, unrecognized expression: "+a};var l=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!j.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&k.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&k.filter(b,a,!0)}},"":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("parentNode",b,f,a,e,c)},"~":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("previousSibling",b,f,a,e,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(i,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}k.error(e)},CHILD:function(a,b){var c=b[1],d=a;switch(c){case"only":case"first":while(d=d.previousSibling)if(d.nodeType===1)return!1;if(c==="first")return!0;d=a;case"last":while(d=d.nextSibling)if(d.nodeType===1)return!1;return!0;case"nth":var e=b[2],f=b[3];if(e===1&&f===0)return!0;var g=b[0],h=a.parentNode;if(h&&(h.sizcache!==g||!a.nodeIndex)){var i=0;for(d=h.firstChild;d;d=d.nextSibling)d.nodeType===1&&(d.nodeIndex=++i);h.sizcache=g}var j=a.nodeIndex-f;return e===0?j===0:j%e===0&&j/e>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c<f;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var r,s;c.documentElement.compareDocumentPosition?r=function(a,b){if(a===b){g=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(r=function(a,b){if(a===b){g=!0;return 0}if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],h=a.parentNode,i=b.parentNode,j=h;if(h===i)return s(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return s(e[k],f[k]);return k===c?s(a,f[k],-1):s(e[k],b,1)},s=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),k.getText=function(a){var b="",c;for(var d=0;a[d];d++)c=a[d],c.nodeType===3||c.nodeType===4?b+=c.nodeValue:c.nodeType!==8&&(b+=k.getText(c.childNodes));return b},function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g<h;g++)k(a,f[g],d);return k.filter(e,d)};f.find=k,f.expr=k.selectors,f.expr[":"]=f.expr.filters,f.unique=k.uniqueSort,f.text=k.getText,f.isXMLDoc=k.isXML,f.contains=k.contains}();var N=/Until$/,O=/^(?:parents|prevUntil|prevAll)/,P=/,/,Q=/^.[^:#\[\.,]*$/,R=Array.prototype.slice,S=f.expr.match.POS,T={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(V(this,a,!1),"not",a)},filter:function(a){return this.pushStack(V(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d<e;d++)i=a[d],j[i]||(j[i]=S.test(i)?f(i,b||this.context):i);while(g&&g.ownerDocument&&g!==b){for(i in j)h=j[i],(h.jquery?h.index(g)>-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=S.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(l?l.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(U(c[0])||U(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=R.call(arguments);N.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!T[a]?f.unique(e):e,(this.length>1||P.test(d))&&O.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/<tbody/i,_=/<|&#?\w+;/,ba=/<(?:script|object|embed|option|style)/i,bb=/checked\s*(?:[^=]|=\s*.checked.)/i,bc=/\/(java|ecma)script/i,bd=/^\s*<!(?:\[CDATA\[|\-\-)/,be={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};be.optgroup=be.option,be.tbody=be.tfoot=be.colgroup=be.caption=be.thead,be.th=be.td,f.support.htmlSerialize||(be._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!be[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1></$2>");try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else f.isFunction(a)?this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bb.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bf(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,bl)}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i;b&&b[0]&&(i=b[0].ownerDocument||b[0]),i.createDocumentFragment||(i=c),a.length===1&&typeof a[0]=="string"&&a[0].length<512&&i===c&&a[0].charAt(0)==="<"&&!ba.test(a[0])&&(f.support.checkClone||!bb.test(a[0]))&&(g=!0,h=f.fragments[a[0]],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean
-(a,i,e,d)),g&&(f.fragments[a[0]]=h?e:1);return{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bh(a,d),e=bi(a),g=bi(d);for(h=0;e[h];++h)g[h]&&bh(e[h],g[h])}if(b){bg(a,d);if(c){e=bi(a),g=bi(d);for(h=0;e[h];++h)bg(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1></$2>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=be[l]||be._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]==="<table>"&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i<r;i++)bk(k[i]);else bk(k);k.nodeType?h.push(k):h=f.merge(h,k)}if(d){g=function(a){return!a.type||bc.test(a.type)};for(j=0;h[j];j++)if(e&&f.nodeName(h[j],"script")&&(!h[j].type||h[j].type.toLowerCase()==="text/javascript"))e.push(h[j].parentNode?h[j].parentNode.removeChild(h[j]):h[j]);else{if(h[j].nodeType===1){var s=f.grep(h[j].getElementsByTagName("script"),g);h.splice.apply(h,[j+1,0].concat(s))}d.appendChild(h[j])}}return h},cleanData:function(a){var b,c,d=f.cache,e=f.expando,g=f.event.special,h=f.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&f.noData[j.nodeName.toLowerCase()])continue;c=j[f.expando];if(c){b=d[c]&&d[c][e];if(b&&b.events){for(var k in b.events)g[k]?f.event.remove(j,k):f.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[f.expando]:j.removeAttribute&&j.removeAttribute(f.expando),delete d[c]}}}});var bm=/alpha\([^)]*\)/i,bn=/opacity=([^)]*)/,bo=/([A-Z]|^ms)/g,bp=/^-?\d+(?:px)?$/i,bq=/^-?\d/,br=/^([\-+])=([\-+.\de]+)/,bs={position:"absolute",visibility:"hidden",display:"block"},bt=["Left","Right"],bu=["Top","Bottom"],bv,bw,bx;f.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return f.access(this,a,c,!0,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)})},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bv(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=br.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(bv)return bv(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]}}),f.curCSS=f.css,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){var e;if(c){if(a.offsetWidth!==0)return by(a,b,d);f.swap(a,bs,function(){e=by(a,b,d)});return e}},set:function(a,b){if(!bp.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bn.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bm,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bm.test(g)?g.replace(bm,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bv(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bw=function(a,c){var d,e,g;c=c.replace(bo,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bx=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bp.test(d)&&bq.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bv=bw||bx,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bz=/%20/g,bA=/\[\]$/,bB=/\r?\n/g,bC=/#.*$/,bD=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bE=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bF=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bG=/^(?:GET|HEAD)$/,bH=/^\/\//,bI=/\?/,bJ=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bK=/^(?:select|textarea)/i,bL=/\s+/,bM=/([?&])_=[^&]*/,bN=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bO=f.fn.load,bP={},bQ={},bR,bS,bT=["*/"]+["*"];try{bR=e.href}catch(bU){bR=c.createElement("a"),bR.href="",bR=bR.href}bS=bN.exec(bR.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bO)return bO.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bJ,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bK.test(this.nodeName)||bE.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bB,"\r\n")}}):{name:b.name,value:c.replace(bB,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?bX(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),bX(a,b);return a},ajaxSettings:{url:bR,isLocal:bF.test(bS[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bT},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bV(bP),ajaxTransport:bV(bQ),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?bZ(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=b$(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bD.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bC,"").replace(bH,bS[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bL),d.crossDomain==null&&(r=bN.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bS[1]&&r[2]==bS[2]&&(r[3]||(r[1]==="http:"?80:443))==(bS[3]||(bS[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bW(bP,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bG.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bI.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bM,"$1_="+x);d.url=y+(y===d.url?(bI.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bT+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bW(bQ,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){s<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bz,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cq("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),e===""&&f.css(d,"display")==="none"&&f._data(d,"olddisplay",cr(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(cq("hide",3),a,b,c);for(var d=0,e=this.length;d<e;d++)if(this[d].style){var g=f.css(this[d],"display");g!=="none"&&!f._data(this[d],"olddisplay")&&f._data(this[d],"olddisplay",g)}for(d=0;d<e;d++)this[d].style&&(this[d].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(cq("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=f.speed(b,c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);a=f.extend({},a);return this[e.queue===!1?"each":"queue"](function(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n,o;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&(a[g]=a[i],delete a[i]),h=a[g],f.isArray(h)?(b.animatedProperties[g]=h[1],h=a[g]=h[0]):b.animatedProperties[g]=b.specialEasing&&b.specialEasing[g]||b.easing||"swing";if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(f.support.inlineBlockNeedsLayout?(j=cr(this.nodeName),j==="inline"?this.style.display="inline-block":(this.style.display="inline",this.style.zoom=1)):this.style.display="inline-block"))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)k=new f.fx(this,b,i),h=a[i],cj.test(h)?k[h==="toggle"?d?"show":"hide":h]():(l=ck.exec(h),m=k.cur(),l?(n=parseFloat(l[2]),o=l[3]||(f.cssNumber[i]?"":"px"),o!=="px"&&(f.style(this,i,(n||1)+o),m=(n||1)/k.cur()*m,f.style(this,i,m+o)),l[1]&&(n=(l[1]==="-="?-1:1)*n+m),k.custom(m,n,o)):k.custom(m,h,""));return!0})},stop:function(a,b){a&&this.queue([]),this.each(function(){var a=f.timers,c=a.length;b||f._unmark(!0,this);while(c--)a[c].elem===this&&(b&&a[c](!0),a.splice(c,1))}),b||this.dequeue();return this}}),f.each({slideDown:cq("show",1),slideUp:cq("hide",1),slideToggle:cq("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default,d.old=d.complete,d.complete=function(a){f.isFunction(d.old)&&d.old.call(this),d.queue!==!1?f.dequeue(this):a!==!1&&f._unmark(this)};return d},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,b,c){function g(a){return d.step(a)}var d=this,e=f.fx;this.startTime=cn||co(),this.start=a,this.end=b,this.unit=c||this.unit||(f.cssNumber[this.prop]?"":"px"),this.now=this.start,this.pos=this.state=0,g.elem=this.elem,g()&&f.timers.push(g)&&!cl&&(cl=setInterval(e.tick,e.interval))},show:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.show=!0,this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b=cn||co(),c=!0,d=this.elem,e=this.options,g,h;if(a||b>=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b<a.length;++b)a[b]()||a.splice(b--,1);a.length||f.fx.stop()},interval:13,stop:function(){clearInterval(cl),cl=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit:a.elem[a.prop]=a.now}}}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cs=/^t(?:able|d|h)$/i,ct=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?f.fn.offset=function(a){var b=this[0],c;if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);try{c=b.getBoundingClientRect()}catch(d){}var e=b.ownerDocument,g=e.documentElement;if(!c||!f.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};var h=e.body,i=cu(e),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||f.support.boxModel&&g.scrollTop||h.scrollTop,m=i.pageXOffset||f.support.boxModel&&g.scrollLeft||h.scrollLeft,n=c.top+l-j,o=c.left+m-k;return{top:n,left:o}}:f.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);f.offset.initialize();var c,d=b.offsetParent,e=b,g=b.ownerDocument,h=g.documentElement,i=g.body,j=g.defaultView,k=j?j.getComputedStyle(b,null):b.currentStyle,l=b.offsetTop,m=b.offsetLeft;while((b=b.parentNode)&&b!==i&&b!==h){if(f.offset.supportsFixedPosition&&k.position==="fixed")break;c=j?j.getComputedStyle(b,null):b.currentStyle,l-=b.scrollTop,m-=b.scrollLeft,b===d&&(l+=b.offsetTop,m+=b.offsetLeft,f.offset.doesNotAddBorder&&(!f.offset.doesAddBorderForTableAndCells||!cs.test(b.nodeName))&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),f.offset.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),k=c}if(k.position==="relative"||k.position==="static")l+=i.offsetTop,m+=i.offsetLeft;f.offset.supportsFixedPosition&&k.position==="fixed"&&(l+=Math.max(h.scrollTop,i.scrollTop),m+=Math.max(h.scrollLeft,i.scrollLeft));return{top:l,left:m}},f.offset={initialize:function(){var a=c.body,b=c.createElement("div"),d,e,g,h,i=parseFloat(f.css(a,"marginTop"))||0,j="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=ct.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!ct.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cu(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cu(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNaN(j)?i:j}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.BezierCurveRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.BezierCurveRenderer.js
deleted file mode 100644
index 8bb205e..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.BezierCurveRenderer.js
+++ /dev/null
@@ -1,312 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    // Class: $.jqplot.BezierCurveRenderer.js
-    // Renderer which draws lines as stacked bezier curves.
-    // Data for the line will not be specified as an array of
-    // [x, y] data point values, but as a an array of [start piont, bezier curve]
-    // So, the line is specified as: [[xstart, ystart], [cp1x, cp1y, cp2x, cp2y, xend, yend]].
-    $.jqplot.BezierCurveRenderer = function(){
-        $.jqplot.LineRenderer.call(this);
-    };
-    
-    $.jqplot.BezierCurveRenderer.prototype = new $.jqplot.LineRenderer();
-    $.jqplot.BezierCurveRenderer.prototype.constructor = $.jqplot.BezierCurveRenderer;
-
-    
-    // Method: setGridData
-    // converts the user data values to grid coordinates and stores them
-    // in the gridData array.
-    // Called with scope of a series.
-    $.jqplot.BezierCurveRenderer.prototype.setGridData = function(plot) {
-        // recalculate the grid data
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        // this._plotData should be same as this.data
-        var data = this.data;
-        this.gridData = [];
-        this._prevGridData = [];
-        // if seriesIndex = 0, fill to x axis.
-        // if seriesIndex > 0, fill to previous series data.
-        var idx = this.index;
-        if (data.length == 2) {
-            if (idx == 0) {
-                this.gridData = [
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], 
-                    [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), 
-                        xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]),  
-                        xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])],
-                    [xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, this._yaxis.min)],
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)]
-                ];
-            }
-            else {
-                var psd = plot.series[idx-1].data;
-                this.gridData = [
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], 
-                    [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), 
-                        xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]),  
-                        xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])],
-                    [xp.call(this._xaxis, psd[1][4]), yp.call(this._yaxis, psd[1][5])],
-                    [xp.call(this._xaxis, psd[1][2]), yp.call(this._yaxis, psd[1][3]), 
-                        xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]),  
-                        xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])]
-                ];
-            }
-        }
-        else {
-            if (idx == 0) {
-                this.gridData = [
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], 
-                    [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), 
-                        xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]),  
-                        xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])],
-                    [xp.call(this._xaxis, data[3][1]), yp.call(this._yaxis, this._yaxis.min)],
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)]
-                ];
-            }
-            else {
-                var psd = plot.series[idx-1].data;
-                this.gridData = [
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], 
-                    [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), 
-                        xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]),  
-                        xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])],
-                    [xp.call(this._xaxis, psd[3][0]), yp.call(this._yaxis, psd[3][1])],
-                    [xp.call(this._xaxis, psd[2][0]), yp.call(this._yaxis, psd[2][1]), 
-                        xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]),  
-                        xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])]
-                ];
-            }
-        }
-    };
-    
-    // Method: makeGridData
-    // converts any arbitrary data values to grid coordinates and
-    // returns them.  This method exists so that plugins can use a series'
-    // linerenderer to generate grid data points without overwriting the
-    // grid data associated with that series.
-    // Called with scope of a series.
-    $.jqplot.BezierCurveRenderer.prototype.makeGridData = function(data, plot) {
-        // recalculate the grid data
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var gd = [];
-        var pgd = [];
-        // if seriesIndex = 0, fill to x axis.
-        // if seriesIndex > 0, fill to previous series data.
-        var idx = this.index;
-        if (data.length == 2) {
-            if (idx == 0) {
-                gd = [
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], 
-                    [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), 
-                        xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]),  
-                        xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])],
-                    [xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, this._yaxis.min)],
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)]
-                ];
-            }
-            else {
-                var psd = plot.series[idx-1].data;
-                gd = [
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], 
-                    [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), 
-                        xp.call(this._xaxis, data[1][2]), yp.call(this._yaxis, data[1][3]),  
-                        xp.call(this._xaxis, data[1][4]), yp.call(this._yaxis, data[1][5])],
-                    [xp.call(this._xaxis, psd[1][4]), yp.call(this._yaxis, psd[1][5])],
-                    [xp.call(this._xaxis, psd[1][2]), yp.call(this._yaxis, psd[1][3]), 
-                        xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]),  
-                        xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])]
-                ];
-            }
-        }
-        else {
-            if (idx == 0) {
-                gd = [
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], 
-                    [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), 
-                        xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]),  
-                        xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])],
-                    [xp.call(this._xaxis, data[3][1]), yp.call(this._yaxis, this._yaxis.min)],
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, this._yaxis.min)]
-                ];
-            }
-            else {
-                var psd = plot.series[idx-1].data;
-                gd = [
-                    [xp.call(this._xaxis, data[0][0]), yp.call(this._yaxis, data[0][1])], 
-                    [xp.call(this._xaxis, data[1][0]), yp.call(this._yaxis, data[1][1]), 
-                        xp.call(this._xaxis, data[2][0]), yp.call(this._yaxis, data[2][1]),  
-                        xp.call(this._xaxis, data[3][0]), yp.call(this._yaxis, data[3][1])],
-                    [xp.call(this._xaxis, psd[3][0]), yp.call(this._yaxis, psd[3][1])],
-                    [xp.call(this._xaxis, psd[2][0]), yp.call(this._yaxis, psd[2][1]), 
-                        xp.call(this._xaxis, psd[1][0]), yp.call(this._yaxis, psd[1][1]),  
-                        xp.call(this._xaxis, psd[0][0]), yp.call(this._yaxis, psd[0][1])]
-                ];
-            }
-        }
-        return gd;
-    };
-    
-
-    // called within scope of series.
-    $.jqplot.BezierCurveRenderer.prototype.draw = function(ctx, gd, options) {
-        var i;
-        ctx.save();
-        if (gd.length) {
-            if (this.showLine) {
-                ctx.save();
-                var opts = (options != null) ? options : {};
-                ctx.fillStyle = opts.fillStyle || this.color;
-                ctx.beginPath();
-                ctx.moveTo(gd[0][0], gd[0][1]);
-                ctx.bezierCurveTo(gd[1][0], gd[1][1], gd[1][2], gd[1][3], gd[1][4], gd[1][5]);
-                ctx.lineTo(gd[2][0], gd[2][1]);
-                if (gd[3].length == 2) {
-                    ctx.lineTo(gd[3][0], gd[3][1]);
-                }
-                else {
-                    ctx.bezierCurveTo(gd[3][0], gd[3][1], gd[3][2], gd[3][3], gd[3][4], gd[3][5]);
-                }
-                ctx.closePath();
-                ctx.fill();
-                ctx.restore();
-            }
-        }
-        
-        ctx.restore();
-    };  
-    
-    $.jqplot.BezierCurveRenderer.prototype.drawShadow = function(ctx, gd, options) {
-        // This is a no-op, shadows drawn with lines.
-    };
-    
-    $.jqplot.BezierAxisRenderer = function() {
-        $.jqplot.LinearAxisRenderer.call(this);
-    };
-    
-    $.jqplot.BezierAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
-    $.jqplot.BezierAxisRenderer.prototype.constructor = $.jqplot.BezierAxisRenderer;
-        
-    
-    // Axes on a plot with Bezier Curves
-    $.jqplot.BezierAxisRenderer.prototype.init = function(options){
-        $.extend(true, this, options);
-        var db = this._dataBounds;
-        // Go through all the series attached to this axis and find
-        // the min/max bounds for this axis.
-        for (var i=0; i<this._series.length; i++) {
-            var s = this._series[i];
-            var d = s.data;  
-            if (d.length == 4) {
-                for (var j=0; j<d.length; j++) { 
-                    if (this.name == 'xaxis' || this.name == 'x2axis') {
-                        if (d[j][0] < db.min || db.min == null) {
-                            db.min = d[j][0];
-                        }
-                        if (d[j][0] > db.max || db.max == null) {
-                            db.max = d[j][0];
-                        }
-                    }              
-                    else {
-                        if (d[j][1] < db.min || db.min == null) {
-                            db.min = d[j][1];
-                        }
-                        if (d[j][1] > db.max || db.max == null) {
-                            db.max = d[j][1];
-                        }
-                    }              
-                }
-            }          
-            else {    
-                if (this.name == 'xaxis' || this.name == 'x2axis') {
-                    if (d[0][0] < db.min || db.min == null) {
-                        db.min = d[0][0];
-                    }
-                    if (d[0][0] > db.max || db.max == null) {
-                        db.max = d[0][0];
-                    }
-                    for (var j=0; j<5; j+=2) {
-                        if (d[1][j] < db.min || db.min == null) {
-                            db.min = d[1][j];
-                        }
-                        if (d[1][j] > db.max || db.max == null) {
-                            db.max = d[1][j];
-                        }
-                    }
-                }              
-                else {
-                    if (d[0][1] < db.min || db.min == null) {
-                        db.min = d[0][1];
-                    }
-                    if (d[0][1] > db.max || db.max == null) {
-                        db.max = d[0][1];
-                    }
-                    for (var j=1; j<6; j+=2) {
-                        if (d[1][j] < db.min || db.min == null) {
-                            db.min = d[1][j];
-                        }
-                        if (d[1][j] > db.max || db.max == null) {
-                            db.max = d[1][j];
-                        }
-                    }
-                }           
-            }
-        }
-    };
-    
-    // setup default renderers for axes and legend so user doesn't have to
-    // called with scope of plot
-    function preInit(target, data, options) {
-        options = options || {};
-        options.axesDefaults = $.extend(true, {pad:0}, options.axesDefaults);
-        options.legend = $.extend(true, {placement:'outside'}, options.legend);
-        // only set these if there is a pie series
-        var setopts = false;
-        if (options.seriesDefaults.renderer == $.jqplot.BezierCurveRenderer) {
-            setopts = true;
-        }
-        else if (options.series) {
-            for (var i=0; i < options.series.length; i++) {
-                if (options.series[i].renderer == $.jqplot.BezierCurveRenderer) {
-                    setopts = true;
-                }
-            }
-        }
-        
-        if (setopts) {
-            options.axesDefaults.renderer = $.jqplot.BezierAxisRenderer;
-        }
-    }
-    
-    $.jqplot.preInitHooks.push(preInit);
-    
-})(jQuery);    
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.BezierCurveRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.BezierCurveRenderer.min.js
deleted file mode 100644
index 70fdd32..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.BezierCurveRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(b){b.jqplot.BezierCurveRenderer=function(){b.jqplot.LineRenderer.call(this)};b.jqplot.BezierCurveRenderer.prototype=new b.jqplot.LineRenderer();b.jqplot.BezierCurveRenderer.prototype.constructor=b.jqplot.BezierCurveRenderer;b.jqplot.BezierCurveRenderer.prototype.setGridData=function(h){var e=this._xaxis.series_u2p;var g=this._yaxis.series_u2p;var f=this.data;this.gridData=[];this._prevGridData=[];var d=this.index;if(f.length==2){if(d==0){this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[1][2]),g.call(this._yaxis,f[1][3]),e.call(this._xaxis,f[1][4]),g.call(this._yaxis,f[1][5])],[e.call(this._xaxis,f[1][4]),g.call(this._yaxis,this._yaxis.min)],[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,this._yaxis.min)]]}else{var c=h.series[d-1].data;this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[1][2]),g.call(this._yaxis,f[1][3]),e.call(this._xaxis,f[1][4]),g.call(this._yaxis,f[1][5])],[e.call(this._xaxis,c[1][4]),g.call(this._yaxis,c[1][5])],[e.call(this._xaxis,c[1][2]),g.call(this._yaxis,c[1][3]),e.call(this._xaxis,c[1][0]),g.call(this._yaxis,c[1][1]),e.call(this._xaxis,c[0][0]),g.call(this._yaxis,c[0][1])]]}}else{if(d==0){this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[2][0]),g.call(this._yaxis,f[2][1]),e.call(this._xaxis,f[3][0]),g.call(this._yaxis,f[3][1])],[e.call(this._xaxis,f[3][1]),g.call(this._yaxis,this._yaxis.min)],[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,this._yaxis.min)]]}else{var c=h.series[d-1].data;this.gridData=[[e.call(this._xaxis,f[0][0]),g.call(this._yaxis,f[0][1])],[e.call(this._xaxis,f[1][0]),g.call(this._yaxis,f[1][1]),e.call(this._xaxis,f[2][0]),g.call(this._yaxis,f[2][1]),e.call(this._xaxis,f[3][0]),g.call(this._yaxis,f[3][1])],[e.call(this._xaxis,c[3][0]),g.call(this._yaxis,c[3][1])],[e.call(this._xaxis,c[2][0]),g.call(this._yaxis,c[2][1]),e.call(this._xaxis,c[1][0]),g.call(this._yaxis,c[1][1]),e.call(this._xaxis,c[0][0]),g.call(this._yaxis,c[0][1])]]}}};b.jqplot.BezierCurveRenderer.prototype.makeGridData=function(g,i){var f=this._xaxis.series_u2p;var h=this._yaxis.series_u2p;var e=[];var j=[];var d=this.index;if(g.length==2){if(d==0){e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[1][2]),h.call(this._yaxis,g[1][3]),f.call(this._xaxis,g[1][4]),h.call(this._yaxis,g[1][5])],[f.call(this._xaxis,g[1][4]),h.call(this._yaxis,this._yaxis.min)],[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,this._yaxis.min)]]}else{var c=i.series[d-1].data;e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[1][2]),h.call(this._yaxis,g[1][3]),f.call(this._xaxis,g[1][4]),h.call(this._yaxis,g[1][5])],[f.call(this._xaxis,c[1][4]),h.call(this._yaxis,c[1][5])],[f.call(this._xaxis,c[1][2]),h.call(this._yaxis,c[1][3]),f.call(this._xaxis,c[1][0]),h.call(this._yaxis,c[1][1]),f.call(this._xaxis,c[0][0]),h.call(this._yaxis,c[0][1])]]}}else{if(d==0){e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[2][0]),h.call(this._yaxis,g[2][1]),f.call(this._xaxis,g[3][0]),h.call(this._yaxis,g[3][1])],[f.call(this._xaxis,g[3][1]),h.call(this._yaxis,this._yaxis.min)],[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,this._yaxis.min)]]}else{var c=i.series[d-1].data;e=[[f.call(this._xaxis,g[0][0]),h.call(this._yaxis,g[0][1])],[f.call(this._xaxis,g[1][0]),h.call(this._yaxis,g[1][1]),f.call(this._xaxis,g[2][0]),h.call(this._yaxis,g[2][1]),f.call(this._xaxis,g[3][0]),h.call(this._yaxis,g[3][1])],[f.call(this._xaxis,c[3][0]),h.call(this._yaxis,c[3][1])],[f.call(this._xaxis,c[2][0]),h.call(this._yaxis,c[2][1]),f.call(this._xaxis,c[1][0]),h.call(this._yaxis,c[1][1]),f.call(this._xaxis,c[0][0]),h.call(this._yaxis,c[0][1])]]}}return e};b.jqplot.BezierCurveRenderer.prototype.draw=function(c,g,d){var e;c.save();if(g.length){if(this.showLine){c.save();var f=(d!=null)?d:{};c.fillStyle=f.fillStyle||this.color;c.beginPath();c.moveTo(g[0][0],g[0][1]);c.bezierCurveTo(g[1][0],g[1][1],g[1][2],g[1][3],g[1][4],g[1][5]);c.lineTo(g[2][0],g[2][1]);if(g[3].length==2){c.lineTo(g[3][0],g[3][1])}else{c.bezierCurveTo(g[3][0],g[3][1],g[3][2],g[3][3],g[3][4],g[3][5])}c.closePath();c.fill();c.restore()}}c.restore()};b.jqplot.BezierCurveRenderer.prototype.drawShadow=function(c,e,d){};b.jqplot.BezierAxisRenderer=function(){b.jqplot.LinearAxisRenderer.call(this)};b.jqplot.BezierAxisRenderer.prototype=new b.jqplot.LinearAxisRenderer();b.jqplot.BezierAxisRenderer.prototype.constructor=b.jqplot.BezierAxisRenderer;b.jqplot.BezierAxisRenderer.prototype.init=function(f){b.extend(true,this,f);var c=this._dataBounds;for(var g=0;g<this._series.length;g++){var h=this._series[g];var k=h.data;if(k.length==4){for(var e=0;e<k.length;e++){if(this.name=="xaxis"||this.name=="x2axis"){if(k[e][0]<c.min||c.min==null){c.min=k[e][0]}if(k[e][0]>c.max||c.max==null){c.max=k[e][0]}}else{if(k[e][1]<c.min||c.min==null){c.min=k[e][1]}if(k[e][1]>c.max||c.max==null){c.max=k[e][1]}}}}else{if(this.name=="xaxis"||this.name=="x2axis"){if(k[0][0]<c.min||c.min==null){c.min=k[0][0]}if(k[0][0]>c.max||c.max==null){c.max=k[0][0]}for(var e=0;e<5;e+=2){if(k[1][e]<c.min||c.min==null){c.min=k[1][e]}if(k[1][e]>c.max||c.max==null){c.max=k[1][e]}}}else{if(k[0][1]<c.min||c.min==null){c.min=k[0][1]}if(k[0][1]>c.max||c.max==null){c.max=k[0][1]}for(var e=1;e<6;e+=2){if(k[1][e]<c.min||c.min==null){c.min=k[1][e]}if(k[1][e]>c.max||c.max==null){c.max=k[1][e]}}}}}};function a(g,f,d){d=d||{};d.axesDefaults=b.extend(true,{pad:0},d.axesDefaults);d.legend=b.extend(true,{placement:"outside"},d.legend);var c=false;if(d.seriesDefaults.renderer==b.jqplot.BezierCurveRenderer){c=true}else{if(d.series){for(var e=0;e<d.series.length;e++){if(d.series[e].renderer==b.jqplot.BezierCurveRenderer){c=true}}}}if(c){d.axesDefaults.renderer=b.jqplot.BezierAxisRenderer}}b.jqplot.preInitHooks.push(a)})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.barRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.barRenderer.js
deleted file mode 100644
index 039c043..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.barRenderer.js
+++ /dev/null
@@ -1,726 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    
-    // Class: $.jqplot.BarRenderer
-    // A plugin renderer for jqPlot to draw a bar plot.
-    // Draws series as a line.
-    
-    $.jqplot.BarRenderer = function(){
-        $.jqplot.LineRenderer.call(this);
-    };
-    
-    $.jqplot.BarRenderer.prototype = new $.jqplot.LineRenderer();
-    $.jqplot.BarRenderer.prototype.constructor = $.jqplot.BarRenderer;
-    
-    // called with scope of series.
-    $.jqplot.BarRenderer.prototype.init = function(options, plot) {
-        // Group: Properties
-        //
-        // prop: barPadding
-        // Number of pixels between adjacent bars at the same axis value.
-        this.barPadding = 8;
-        // prop: barMargin
-        // Number of pixels between groups of bars at adjacent axis values.
-        this.barMargin = 10;
-        // prop: barDirection
-        // 'vertical' = up and down bars, 'horizontal' = side to side bars
-        this.barDirection = 'vertical';
-        // prop: barWidth
-        // Width of the bar in pixels (auto by devaul).  null = calculated automatically.
-        this.barWidth = null;
-        // prop: shadowOffset
-        // offset of the shadow from the slice and offset of 
-        // each succesive stroke of the shadow from the last.
-        this.shadowOffset = 2;
-        // prop: shadowDepth
-        // number of strokes to apply to the shadow, 
-        // each stroke offset shadowOffset from the last.
-        this.shadowDepth = 5;
-        // prop: shadowAlpha
-        // transparency of the shadow (0 = transparent, 1 = opaque)
-        this.shadowAlpha = 0.08;
-        // prop: waterfall
-        // true to enable waterfall plot.
-        this.waterfall = false;
-        // prop: groups
-        // group bars into this many groups
-        this.groups = 1;
-        // prop: varyBarColor
-        // true to color each bar of a series separately rather than
-        // have every bar of a given series the same color.
-        // If used for non-stacked multiple series bar plots, user should
-        // specify a separate 'seriesColors' array for each series.
-        // Otherwise, each series will set their bars to the same color array.
-        // This option has no Effect for stacked bar charts and is disabled.
-        this.varyBarColor = false;
-        // prop: highlightMouseOver
-        // True to highlight slice when moused over.
-        // This must be false to enable highlightMouseDown to highlight when clicking on a slice.
-        this.highlightMouseOver = true;
-        // prop: highlightMouseDown
-        // True to highlight when a mouse button is pressed over a slice.
-        // This will be disabled if highlightMouseOver is true.
-        this.highlightMouseDown = false;
-        // prop: highlightColors
-        // an array of colors to use when highlighting a bar.
-        this.highlightColors = [];
-        // prop: transposedData
-        // NOT IMPLEMENTED YET.  True if this is a horizontal bar plot and 
-        // x and y values are "transposed".  Tranposed, or "swapped", data is 
-        // required prior to rev. 894 builds of jqPlot with horizontal bars. 
-        // Allows backward compatability of bar renderer horizontal bars with 
-        // old style data sets.
-        this.transposedData = true;
-        this._type = 'bar';
-        
-        // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
-        if (options.highlightMouseDown && options.highlightMouseOver == null) {
-            options.highlightMouseOver = false;
-        }
-        
-        $.extend(true, this, options);
-        // fill is still needed to properly draw the legend.
-        // bars have to be filled.
-        this.fill = true;
-        
-        if (this.waterfall) {
-            this.fillToZero = false;
-            this.disableStack = true;
-        }
-        
-        if (this.barDirection == 'vertical' ) {
-            this._primaryAxis = '_xaxis';
-            this._stackAxis = 'y';
-            this.fillAxis = 'y';
-        }
-        else {
-            this._primaryAxis = '_yaxis';
-            this._stackAxis = 'x';
-            this.fillAxis = 'x';
-        }
-        // index of the currenty highlighted point, if any
-        this._highlightedPoint = null;
-        // total number of values for all bar series, total number of bar series, and position of this series
-        this._plotSeriesInfo = null;
-        // Array of actual data colors used for each data point.
-        this._dataColors = [];
-        this._barPoints = [];
-        
-        // set the shape renderer options
-        var opts = {lineJoin:'miter', lineCap:'round', fill:true, isarc:false, strokeStyle:this.color, fillStyle:this.color, closePath:this.fill};
-        this.renderer.shapeRenderer.init(opts);
-        // set the shadow renderer options
-        var sopts = {lineJoin:'miter', lineCap:'round', fill:true, isarc:false, angle:this.shadowAngle, offset:this.shadowOffset, alpha:this.shadowAlpha, depth:this.shadowDepth, closePath:this.fill};
-        this.renderer.shadowRenderer.init(sopts);
-        
-        plot.postInitHooks.addOnce(postInit);
-        plot.postDrawHooks.addOnce(postPlotDraw);
-        plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
-        plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
-        plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
-        plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
-        plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick); 
-    };
-    
-    // called with scope of series
-    function barPreInit(target, data, seriesDefaults, options) {
-        if (this.rendererOptions.barDirection == 'horizontal') {
-            this._stackAxis = 'x';
-            this._primaryAxis = '_yaxis';
-        }
-        if (this.rendererOptions.waterfall == true) {
-            this._data = $.extend(true, [], this.data);
-            var sum = 0;
-            var pos = (!this.rendererOptions.barDirection || this.rendererOptions.barDirection === 'vertical' || this.transposedData === false) ? 1 : 0;
-            for(var i=0; i<this.data.length; i++) {
-                sum += this.data[i][pos];
-                if (i>0) {
-                    this.data[i][pos] += this.data[i-1][pos];
-                }
-            }
-            this.data[this.data.length] = (pos == 1) ? [this.data.length+1, sum] : [sum, this.data.length+1];
-            this._data[this._data.length] = (pos == 1) ? [this._data.length+1, sum] : [sum, this._data.length+1];
-        }
-        if (this.rendererOptions.groups > 1) {
-            this.breakOnNull = true;
-            var l = this.data.length;
-            var skip = parseInt(l/this.rendererOptions.groups, 10);
-            var count = 0;
-            for (var i=skip; i<l; i+=skip) {
-                this.data.splice(i+count, 0, [null, null]);
-                count++;
-            }
-            for (i=0; i<this.data.length; i++) {
-                if (this._primaryAxis == '_xaxis') {
-                    this.data[i][0] = i+1;
-                }
-                else {
-                    this.data[i][1] = i+1;
-                }
-            }
-        }
-    }
-    
-    $.jqplot.preSeriesInitHooks.push(barPreInit);
-    
-    // needs to be called with scope of series, not renderer.
-    $.jqplot.BarRenderer.prototype.calcSeriesNumbers = function() {
-        var nvals = 0;
-        var nseries = 0;
-        var paxis = this[this._primaryAxis];
-        var s, series, pos;
-        // loop through all series on this axis
-        for (var i=0; i < paxis._series.length; i++) {
-            series = paxis._series[i];
-            if (series === this) {
-                pos = i;
-            }
-            // is the series rendered as a bar?
-            if (series.renderer.constructor == $.jqplot.BarRenderer) {
-                // gridData may not be computed yet, use data length insted
-                nvals += series.data.length;
-                nseries += 1;
-            }
-        }
-        // return total number of values for all bar series, total number of bar series, and position of this series
-        return [nvals, nseries, pos];
-    };
-
-    $.jqplot.BarRenderer.prototype.setBarWidth = function() {
-        // need to know how many data values we have on the approprate axis and figure it out.
-        var i;
-        var nvals = 0;
-        var nseries = 0;
-        var paxis = this[this._primaryAxis];
-        var s, series, pos;
-        var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this);
-        nvals = temp[0];
-        nseries = temp[1];
-        var nticks = paxis.numberTicks;
-        var nbins = (nticks-1)/2;
-        // so, now we have total number of axis values.
-        if (paxis.name == 'xaxis' || paxis.name == 'x2axis') {
-            if (this._stack) {
-                this.barWidth = (paxis._offsets.max - paxis._offsets.min) / nvals * nseries - this.barMargin;
-            }
-            else {
-                this.barWidth = ((paxis._offsets.max - paxis._offsets.min)/nbins  - this.barPadding * (nseries-1) - this.barMargin*2)/nseries;
-                // this.barWidth = (paxis._offsets.max - paxis._offsets.min) / nvals - this.barPadding - this.barMargin/nseries;
-            }
-        }
-        else {
-            if (this._stack) {
-                this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals * nseries - this.barMargin;
-            }
-            else {
-                this.barWidth = ((paxis._offsets.min - paxis._offsets.max)/nbins  - this.barPadding * (nseries-1) - this.barMargin*2)/nseries;
-                // this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals - this.barPadding - this.barMargin/nseries;
-            }
-        }
-        return [nvals, nseries];
-    };
-
-    function computeHighlightColors (colors) {
-        var ret = [];
-        for (var i=0; i<colors.length; i++){
-            var rgba = $.jqplot.getColorComponents(colors[i]);
-            var newrgb = [rgba[0], rgba[1], rgba[2]];
-            var sum = newrgb[0] + newrgb[1] + newrgb[2];
-            for (var j=0; j<3; j++) {
-                // when darkening, lowest color component can be is 60.
-                newrgb[j] = (sum > 570) ?  newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]);
-                newrgb[j] = parseInt(newrgb[j], 10);
-            }
-            ret.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')');
-        }
-        return ret;
-    }
-    
-    $.jqplot.BarRenderer.prototype.draw = function(ctx, gridData, options) {
-        var i;
-        // Ughhh, have to make a copy of options b/c it may be modified later.
-        var opts = $.extend({}, options);
-        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
-        var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
-        var fill = (opts.fill != undefined) ? opts.fill : this.fill;
-        var xaxis = this.xaxis;
-        var yaxis = this.yaxis;
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var pointx, pointy;
-        // clear out data colors.
-        this._dataColors = [];
-        this._barPoints = [];
-        
-        if (this.barWidth == null) {
-            this.renderer.setBarWidth.call(this);
-        }
-        
-        var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this);
-        var nvals = temp[0];
-        var nseries = temp[1];
-        var pos = temp[2];
-		var points = [];
-        
-        if (this._stack) {
-            this._barNudge = 0;
-        }
-        else {
-            this._barNudge = (-Math.abs(nseries/2 - 0.5) + pos) * (this.barWidth + this.barPadding);
-        }
-        if (showLine) {
-            var negativeColors = new $.jqplot.ColorGenerator(this.negativeSeriesColors);
-            var positiveColors = new $.jqplot.ColorGenerator(this.seriesColors);
-            var negativeColor = negativeColors.get(this.index);
-            if (! this.useNegativeColors) {
-                negativeColor = opts.fillStyle;
-            }
-            var positiveColor = opts.fillStyle;
-			var base;
-			var xstart; 
-			var ystart;
-            
-            if (this.barDirection == 'vertical') {
-                for (var i=0; i<gridData.length; i++) {
-                    if (this.data[i][1] == null) {
-                        continue;
-                    }
-                    points = [];
-                    base = gridData[i][0] + this._barNudge;
-                    ystart;
-                    
-                    // stacked
-                    if (this._stack && this._prevGridData.length) {
-                        ystart = this._prevGridData[i][1];
-                    }
-                    // not stacked and first series in stack
-                    else {
-                        if (this.fillToZero) {
-                            ystart = this._yaxis.series_u2p(0);
-                        }
-                        else if (this.waterfall && i > 0 && i < this.gridData.length-1) {
-                            ystart = this.gridData[i-1][1];
-                        }
-                        else if (this.waterfall && i == 0 && i < this.gridData.length-1) {
-                            if (this._yaxis.min <= 0 && this._yaxis.max >= 0) {
-                                ystart = this._yaxis.series_u2p(0);
-                            }
-                            else if (this._yaxis.min > 0) {
-                                ystart = ctx.canvas.height;
-                            }
-                            else {
-                                ystart = 0;
-                            }
-                        }
-                        else if (this.waterfall && i == this.gridData.length - 1) {
-                            if (this._yaxis.min <= 0 && this._yaxis.max >= 0) {
-                                ystart = this._yaxis.series_u2p(0);
-                            }
-                            else if (this._yaxis.min > 0) {
-                                ystart = ctx.canvas.height;
-                            }
-                            else {
-                                ystart = 0;
-                            }
-                        }
-                        else {
-                            ystart = ctx.canvas.height;
-                        }
-                    }
-                    if ((this.fillToZero && this._plotData[i][1] < 0) || (this.waterfall && this._data[i][1] < 0)) {
-                        if (this.varyBarColor && !this._stack) {
-                            if (this.useNegativeColors) {
-                                opts.fillStyle = negativeColors.next();
-                            }
-                            else {
-                                opts.fillStyle = positiveColors.next();
-                            }
-                        }
-                        else {
-                            opts.fillStyle = negativeColor;
-                        }
-                    }
-                    else {
-                        if (this.varyBarColor && !this._stack) {
-                            opts.fillStyle = positiveColors.next();
-                        }
-                        else {
-                            opts.fillStyle = positiveColor;
-                        }
-                    }
-					
-					if (!this.fillToZero || this._plotData[i][1] >= 0) { 
-						points.push([base-this.barWidth/2, ystart]);
-						points.push([base-this.barWidth/2, gridData[i][1]]);
-						points.push([base+this.barWidth/2, gridData[i][1]]);
-						points.push([base+this.barWidth/2, ystart]);
-					}
-					// for negative bars make sure points are always ordered clockwise
-					else {              
-						points.push([base-this.barWidth/2, gridData[i][1]]);
-						points.push([base-this.barWidth/2, ystart]);
-						points.push([base+this.barWidth/2, ystart]);
-						points.push([base+this.barWidth/2, gridData[i][1]]);
-					}
-                    this._barPoints.push(points);
-                    // now draw the shadows if not stacked.
-                    // for stacked plots, they are predrawn by drawShadow
-                    if (shadow && !this._stack) {
-                        var sopts = $.extend(true, {}, opts);
-                        // need to get rid of fillStyle on shadow.
-                        delete sopts.fillStyle;
-                        this.renderer.shadowRenderer.draw(ctx, points, sopts);
-                    }
-                    var clr = opts.fillStyle || this.color;
-                    this._dataColors.push(clr);
-                    this.renderer.shapeRenderer.draw(ctx, points, opts); 
-                }
-            }
-            
-            else if (this.barDirection == 'horizontal'){
-                for (var i=0; i<gridData.length; i++) {
-                    if (this.data[i][0] == null) {
-                        continue;
-                    }
-                    points = [];
-                    base = gridData[i][1] - this._barNudge;
-                    xstart;
-                    
-                    if (this._stack && this._prevGridData.length) {
-                        xstart = this._prevGridData[i][0];
-                    }
-                    // not stacked and first series in stack
-                    else {
-                        if (this.fillToZero) {
-                            xstart = this._xaxis.series_u2p(0);
-                        }
-                        else if (this.waterfall && i > 0 && i < this.gridData.length-1) {
-                            xstart = this.gridData[i-1][1];
-                        }
-                        else if (this.waterfall && i == 0 && i < this.gridData.length-1) {
-                            if (this._xaxis.min <= 0 && this._xaxis.max >= 0) {
-                                xstart = this._xaxis.series_u2p(0);
-                            }
-                            else if (this._xaxis.min > 0) {
-                                xstart = 0;
-                            }
-                            else {
-                                xstart = ctx.canvas.width;
-                            }
-                        }
-                        else if (this.waterfall && i == this.gridData.length - 1) {
-                            if (this._xaxis.min <= 0 && this._xaxis.max >= 0) {
-                                xstart = this._xaxis.series_u2p(0);
-                            }
-                            else if (this._xaxis.min > 0) {
-                                xstart = 0;
-                            }
-                            else {
-                                xstart = ctx.canvas.width;
-                            }
-                        }
-                        else {
-                            xstart = 0;
-                        }
-                    }
-                    if ((this.fillToZero && this._plotData[i][1] < 0) || (this.waterfall && this._data[i][1] < 0)) {
-                        if (this.varyBarColor && !this._stack) {
-                            if (this.useNegativeColors) {
-                                opts.fillStyle = negativeColors.next();
-                            }
-                            else {
-                                opts.fillStyle = positiveColors.next();
-                            }
-                        }
-                    }
-                    else {
-                        if (this.varyBarColor && !this._stack) {
-                            opts.fillStyle = positiveColors.next();
-                        }
-                        else {
-                            opts.fillStyle = positiveColor;
-                        }                    
-                    }
-                    
-
-                    if (!this.fillToZero || this._plotData[i][0] >= 0) {
-                        points.push([xstart, base + this.barWidth / 2]);
-                        points.push([xstart, base - this.barWidth / 2]);
-                        points.push([gridData[i][0], base - this.barWidth / 2]);
-                        points.push([gridData[i][0], base + this.barWidth / 2]);
-                    }
-                    else {
-                        points.push([gridData[i][0], base + this.barWidth / 2]);
-                        points.push([gridData[i][0], base - this.barWidth / 2]);
-                        points.push([xstart, base - this.barWidth / 2]);
-                        points.push([xstart, base + this.barWidth / 2]);
-                    }
-
-                    this._barPoints.push(points);
-                    // now draw the shadows if not stacked.
-                    // for stacked plots, they are predrawn by drawShadow
-                    if (shadow && !this._stack) {
-                        var sopts = $.extend(true, {}, opts);
-                        delete sopts.fillStyle;
-                        this.renderer.shadowRenderer.draw(ctx, points, sopts);
-                    }
-                    var clr = opts.fillStyle || this.color;
-                    this._dataColors.push(clr);
-                    this.renderer.shapeRenderer.draw(ctx, points, opts); 
-                }  
-            }
-        }                
-        
-        if (this.highlightColors.length == 0) {
-            this.highlightColors = $.jqplot.computeHighlightColors(this._dataColors);
-        }
-        
-        else if (typeof(this.highlightColors) == 'string') {
-            var temp = this.highlightColors;
-            this.highlightColors = [];
-            for (var i=0; i<this._dataColors.length; i++) {
-                this.highlightColors.push(temp);
-            }
-        }
-        
-    };
-    
-     
-    // for stacked plots, shadows will be pre drawn by drawShadow.
-    $.jqplot.BarRenderer.prototype.drawShadow = function(ctx, gridData, options) {
-        var i;
-        var opts = (options != undefined) ? options : {};
-        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
-        var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
-        var fill = (opts.fill != undefined) ? opts.fill : this.fill;
-        var xaxis = this.xaxis;
-        var yaxis = this.yaxis;
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var pointx, points, pointy, nvals, nseries, pos;
-        
-        if (this._stack && this.shadow) {
-            if (this.barWidth == null) {
-                this.renderer.setBarWidth.call(this);
-            }
-        
-            var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this);
-            nvals = temp[0];
-            nseries = temp[1];
-            pos = temp[2];
-        
-            if (this._stack) {
-                this._barNudge = 0;
-            }
-            else {
-                this._barNudge = (-Math.abs(nseries/2 - 0.5) + pos) * (this.barWidth + this.barPadding);
-            }
-            if (showLine) {
-            
-                if (this.barDirection == 'vertical') {
-                    for (var i=0; i<gridData.length; i++) {
-                        if (this.data[i][1] == null) {
-                            continue;
-                        }
-                        points = [];
-                        var base = gridData[i][0] + this._barNudge;
-                        var ystart;
-                    
-                        if (this._stack && this._prevGridData.length) {
-                            ystart = this._prevGridData[i][1];
-                        }
-                        else {
-                            if (this.fillToZero) {
-                                ystart = this._yaxis.series_u2p(0);
-                            }
-                            else {
-                                ystart = ctx.canvas.height;
-                            }
-                        }
-                    
-                        points.push([base-this.barWidth/2, ystart]);
-                        points.push([base-this.barWidth/2, gridData[i][1]]);
-                        points.push([base+this.barWidth/2, gridData[i][1]]);
-                        points.push([base+this.barWidth/2, ystart]);
-                        this.renderer.shadowRenderer.draw(ctx, points, opts);
-                    }
-                }
-            
-                else if (this.barDirection == 'horizontal'){
-                    for (var i=0; i<gridData.length; i++) {
-                        if (this.data[i][0] == null) {
-                            continue;
-                        }
-                        points = [];
-                        var base = gridData[i][1] - this._barNudge;
-                        var xstart;
-                    
-                        if (this._stack && this._prevGridData.length) {
-                            xstart = this._prevGridData[i][0];
-                        }
-                        else {
-                            xstart = 0;
-                        }
-                    
-                        points.push([xstart, base+this.barWidth/2]);
-                        points.push([gridData[i][0], base+this.barWidth/2]);
-                        points.push([gridData[i][0], base-this.barWidth/2]);
-                        points.push([xstart, base-this.barWidth/2]);
-                        this.renderer.shadowRenderer.draw(ctx, points, opts);
-                    }  
-                }
-            }   
-            
-        }
-    };
-    
-    function postInit(target, data, options) {
-        for (var i=0; i<this.series.length; i++) {
-            if (this.series[i].renderer.constructor == $.jqplot.BarRenderer) {
-                // don't allow mouseover and mousedown at same time.
-                if (this.series[i].highlightMouseOver) {
-                    this.series[i].highlightMouseDown = false;
-                }
-            }
-        }
-    }
-    
-    // called within context of plot
-    // create a canvas which we can draw on.
-    // insert it before the eventCanvas, so eventCanvas will still capture events.
-    function postPlotDraw() {
-        // Memory Leaks patch    
-        if (this.plugins.barRenderer && this.plugins.barRenderer.highlightCanvas) {
-
-            this.plugins.barRenderer.highlightCanvas.resetCanvas();
-            this.plugins.barRenderer.highlightCanvas = null;
-        }
-         
-        this.plugins.barRenderer = {highlightedSeriesIndex:null};
-        this.plugins.barRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
-        
-        this.eventCanvas._elem.before(this.plugins.barRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-barRenderer-highlight-canvas', this._plotDimensions, this));
-        this.plugins.barRenderer.highlightCanvas.setContext();
-        this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
-    }   
-    
-    function highlight (plot, sidx, pidx, points) {
-        var s = plot.series[sidx];
-        var canvas = plot.plugins.barRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        s._highlightedPoint = pidx;
-        plot.plugins.barRenderer.highlightedSeriesIndex = sidx;
-        var opts = {fillStyle: s.highlightColors[pidx]};
-        s.renderer.shapeRenderer.draw(canvas._ctx, points, opts);
-        canvas = null;
-    }
-    
-    function unhighlight (plot) {
-        var canvas = plot.plugins.barRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        for (var i=0; i<plot.series.length; i++) {
-            plot.series[i]._highlightedPoint = null;
-        }
-        plot.plugins.barRenderer.highlightedSeriesIndex = null;
-        plot.target.trigger('jqplotDataUnhighlight');
-        canvas =  null;
-    }
-    
-    
-    function handleMove(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt1 = jQuery.Event('jqplotDataMouseOver');
-            evt1.pageX = ev.pageX;
-            evt1.pageY = ev.pageY;
-            plot.target.trigger(evt1, ins);
-            if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.barRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    }
-    
-    function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.barRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    }
-    
-    function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
-        var idx = plot.plugins.barRenderer.highlightedSeriesIndex;
-        if (idx != null && plot.series[idx].highlightMouseDown) {
-            unhighlight(plot);
-        }
-    }
-    
-    function handleClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt = jQuery.Event('jqplotDataClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }
-    
-    function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var idx = plot.plugins.barRenderer.highlightedSeriesIndex;
-            if (idx != null && plot.series[idx].highlightMouseDown) {
-                unhighlight(plot);
-            }
-            var evt = jQuery.Event('jqplotDataRightClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }
-    
-    
-})(jQuery);    
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.barRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.barRenderer.min.js
deleted file mode 100644
index d4a9fed..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.barRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(d){d.jqplot.BarRenderer=function(){d.jqplot.LineRenderer.call(this)};d.jqplot.BarRenderer.prototype=new d.jqplot.LineRenderer();d.jqplot.BarRenderer.prototype.constructor=d.jqplot.BarRenderer;d.jqplot.BarRenderer.prototype.init=function(n,p){this.barPadding=8;this.barMargin=10;this.barDirection="vertical";this.barWidth=null;this.shadowOffset=2;this.shadowDepth=5;this.shadowAlpha=0.08;this.waterfall=false;this.groups=1;this.varyBarColor=false;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.transposedData=true;this._type="bar";if(n.highlightMouseDown&&n.highlightMouseOver==null){n.highlightMouseOver=false}d.extend(true,this,n);this.fill=true;if(this.waterfall){this.fillToZero=false;this.disableStack=true}if(this.barDirection=="vertical"){this._primaryAxis="_xaxis";this._stackAxis="y";this.fillAxis="y"}else{this._primaryAxis="_yaxis";this._stackAxis="x";this.fillAxis="x"}this._highlightedPoint=null;this._plotSeriesInfo=null;this._dataColors=[];this._barPoints=[];var o={lineJoin:"miter",lineCap:"round",fill:true,isarc:false,strokeStyle:this.color,fillStyle:this.color,closePath:this.fill};this.renderer.shapeRenderer.init(o);var m={lineJoin:"miter",lineCap:"round",fill:true,isarc:false,angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,depth:this.shadowDepth,closePath:this.fill};this.renderer.shadowRenderer.init(m);p.postInitHooks.addOnce(h);p.postDrawHooks.addOnce(i);p.eventListenerHooks.addOnce("jqplotMouseMove",b);p.eventListenerHooks.addOnce("jqplotMouseDown",a);p.eventListenerHooks.addOnce("jqplotMouseUp",k);p.eventListenerHooks.addOnce("jqplotClick",e);p.eventListenerHooks.addOnce("jqplotRightClick",l)};function g(s,o,n,v){if(this.rendererOptions.barDirection=="horizontal"){this._stackAxis="x";this._primaryAxis="_yaxis"}if(this.rendererOptions.waterfall==true){this._data=d.extend(true,[],this.data);var r=0;var t=(!this.rendererOptions.barDirection||this.rendererOptions.barDirection==="vertical"||this.transposedData===false)?1:0;for(var p=0;p<this.data.length;p++){r+=this.data[p][t];if(p>0){this.data[p][t]+=this.data[p-1][t]}}this.data[this.data.length]=(t==1)?[this.data.length+1,r]:[r,this.data.length+1];this._data[this._data.length]=(t==1)?[this._data.length+1,r]:[r,this._data.length+1]}if(this.rendererOptions.groups>1){this.breakOnNull=true;var m=this.data.length;var u=parseInt(m/this.rendererOptions.groups,10);var q=0;for(var p=u;p<m;p+=u){this.data.splice(p+q,0,[null,null]);q++}for(p=0;p<this.data.length;p++){if(this._primaryAxis=="_xaxis"){this.data[p][0]=p+1}else{this.data[p][1]=p+1}}}}d.jqplot.preSeriesInitHooks.push(g);d.jqplot.BarRenderer.prototype.calcSeriesNumbers=function(){var q=0;var r=0;var p=this[this._primaryAxis];var o,n,t;for(var m=0;m<p._series.length;m++){n=p._series[m];if(n===this){t=m}if(n.renderer.constructor==d.jqplot.BarRenderer){q+=n.data.length;r+=1}}return[q,r,t]};d.jqplot.BarRenderer.prototype.setBarWidth=function(){var p;var m=0;var n=0;var r=this[this._primaryAxis];var w,q,u;var v=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);m=v[0];n=v[1];var t=r.numberTicks;var o=(t-1)/2;if(r.name=="xaxis"||r.name=="x2axis"){if(this._stack){this.barWidth=(r._offsets.max-r._offsets.min)/m*n-this.barMargin}else{this.barWidth=((r._offsets.max-r._offsets.min)/o-this.barPadding*(n-1)-this.barMargin*2)/n}}else{if(this._stack){this.barWidth=(r._offsets.min-r._offsets.max)/m*n-this.barMargin}else{this.barWidth=((r._offsets.min-r._offsets.max)/o-this.barPadding*(n-1)-this.barMargin*2)/n}}return[m,n]};function f(n){var p=[];for(var r=0;r<n.length;r++){var q=d.jqplot.getColorComponents(n[r]);var m=[q[0],q[1],q[2]];var s=m[0]+m[1]+m[2];for(var o=0;o<3;o++){m[o]=(s>570)?m[o]*0.8:m[o]+0.3*(255-m[o]);m[o]=parseInt(m[o],10)}p.push("rgb("+m[0]+","+m[1]+","+m[2]+")")}return p}d.jqplot.BarRenderer.prototype.draw=function(D,J,p){var G;var z=d.extend({},p);var u=(z.shadow!=undefined)?z.shadow:this.shadow;var M=(z.showLine!=undefined)?z.showLine:this.showLine;var E=(z.fill!=undefined)?z.fill:this.fill;var o=this.xaxis;var H=this.yaxis;var x=this._xaxis.series_u2p;var I=this._yaxis.series_u2p;var C,B;this._dataColors=[];this._barPoints=[];if(this.barWidth==null){this.renderer.setBarWidth.call(this)}var L=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);var w=L[0];var v=L[1];var r=L[2];var F=[];if(this._stack){this._barNudge=0}else{this._barNudge=(-Math.abs(v/2-0.5)+r)*(this.barWidth+this.barPadding)}if(M){var t=new d.jqplot.ColorGenerator(this.negativeSeriesColors);var A=new d.jqplot.ColorGenerator(this.seriesColors);var K=t.get(this.index);if(!this.useNegativeColors){K=z.fillStyle}var s=z.fillStyle;var q;var N;var n;if(this.barDirection=="vertical"){for(var G=0;G<J.length;G++){if(this.data[G][1]==null){continue}F=[];q=J[G][0]+this._barNudge;n;if(this._stack&&this._prevGridData.length){n=this._prevGridData[G][1]}else{if(this.fillToZero){n=this._yaxis.series_u2p(0)}else{if(this.waterfall&&G>0&&G<this.gridData.length-1){n=this.gridData[G-1][1]}else{if(this.waterfall&&G==0&&G<this.gridData.length-1){if(this._yaxis.min<=0&&this._yaxis.max>=0){n=this._yaxis.series_u2p(0)}else{if(this._yaxis.min>0){n=D.canvas.height}else{n=0}}}else{if(this.waterfall&&G==this.gridData.length-1){if(this._yaxis.min<=0&&this._yaxis.max>=0){n=this._yaxis.series_u2p(0)}else{if(this._yaxis.min>0){n=D.canvas.height}else{n=0}}}else{n=D.canvas.height}}}}}if((this.fillToZero&&this._plotData[G][1]<0)||(this.waterfall&&this._data[G][1]<0)){if(this.varyBarColor&&!this._stack){if(this.useNegativeColors){z.fillStyle=t.next()}else{z.fillStyle=A.next()}}else{z.fillStyle=K}}else{if(this.varyBarColor&&!this._stack){z.fillStyle=A.next()}else{z.fillStyle=s}}if(!this.fillToZero||this._plotData[G][1]>=0){F.push([q-this.barWidth/2,n]);F.push([q-this.barWidth/2,J[G][1]]);F.push([q+this.barWidth/2,J[G][1]]);F.push([q+this.barWidth/2,n])}else{F.push([q-this.barWidth/2,J[G][1]]);F.push([q-this.barWidth/2,n]);F.push([q+this.barWidth/2,n]);F.push([q+this.barWidth/2,J[G][1]])}this._barPoints.push(F);if(u&&!this._stack){var y=d.extend(true,{},z);delete y.fillStyle;this.renderer.shadowRenderer.draw(D,F,y)}var m=z.fillStyle||this.color;this._dataColors.push(m);this.renderer.shapeRenderer.draw(D,F,z)}}else{if(this.barDirection=="horizontal"){for(var G=0;G<J.length;G++){if(this.data[G][0]==null){continue}F=[];q=J[G][1]-this._barNudge;N;if(this._stack&&this._prevGridData.length){N=this._prevGridData[G][0]}else{if(this.fillToZero){N=this._xaxis.series_u2p(0)}else{if(this.waterfall&&G>0&&G<this.gridData.length-1){N=this.gridData[G-1][1]}else{if(this.waterfall&&G==0&&G<this.gridData.length-1){if(this._xaxis.min<=0&&this._xaxis.max>=0){N=this._xaxis.series_u2p(0)}else{if(this._xaxis.min>0){N=0}else{N=D.canvas.width}}}else{if(this.waterfall&&G==this.gridData.length-1){if(this._xaxis.min<=0&&this._xaxis.max>=0){N=this._xaxis.series_u2p(0)}else{if(this._xaxis.min>0){N=0}else{N=D.canvas.width}}}else{N=0}}}}}if((this.fillToZero&&this._plotData[G][1]<0)||(this.waterfall&&this._data[G][1]<0)){if(this.varyBarColor&&!this._stack){if(this.useNegativeColors){z.fillStyle=t.next()}else{z.fillStyle=A.next()}}}else{if(this.varyBarColor&&!this._stack){z.fillStyle=A.next()}else{z.fillStyle=s}}if(!this.fillToZero||this._plotData[G][0]>=0){F.push([N,q+this.barWidth/2]);F.push([N,q-this.barWidth/2]);F.push([J[G][0],q-this.barWidth/2]);F.push([J[G][0],q+this.barWidth/2])}else{F.push([J[G][0],q+this.barWidth/2]);F.push([J[G][0],q-this.barWidth/2]);F.push([N,q-this.barWidth/2]);F.push([N,q+this.barWidth/2])}this._barPoints.push(F);if(u&&!this._stack){var y=d.extend(true,{},z);delete y.fillStyle;this.renderer.shadowRenderer.draw(D,F,y)}var m=z.fillStyle||this.color;this._dataColors.push(m);this.renderer.shapeRenderer.draw(D,F,z)}}}}if(this.highlightColors.length==0){this.highlightColors=d.jqplot.computeHighlightColors(this._dataColors)}else{if(typeof(this.highlightColors)=="string"){var L=this.highlightColors;this.highlightColors=[];for(var G=0;G<this._dataColors.length;G++){this.highlightColors.push(L)}}}};d.jqplot.BarRenderer.prototype.drawShadow=function(y,E,o){var B;var v=(o!=undefined)?o:{};var r=(v.shadow!=undefined)?v.shadow:this.shadow;var G=(v.showLine!=undefined)?v.showLine:this.showLine;var z=(v.fill!=undefined)?v.fill:this.fill;var n=this.xaxis;var C=this.yaxis;var u=this._xaxis.series_u2p;var D=this._yaxis.series_u2p;var x,A,w,t,s,q;if(this._stack&&this.shadow){if(this.barWidth==null){this.renderer.setBarWidth.call(this)}var F=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);t=F[0];s=F[1];q=F[2];if(this._stack){this._barNudge=0}else{this._barNudge=(-Math.abs(s/2-0.5)+q)*(this.barWidth+this.barPadding)}if(G){if(this.barDirection=="vertical"){for(var B=0;B<E.length;B++){if(this.data[B][1]==null){continue}A=[];var p=E[B][0]+this._barNudge;var m;if(this._stack&&this._prevGridData.length){m=this._prevGridData[B][1]}else{if(this.fillToZero){m=this._yaxis.series_u2p(0)}else{m=y.canvas.height}}A.push([p-this.barWidth/2,m]);A.push([p-this.barWidth/2,E[B][1]]);A.push([p+this.barWidth/2,E[B][1]]);A.push([p+this.barWidth/2,m]);this.renderer.shadowRenderer.draw(y,A,v)}}else{if(this.barDirection=="horizontal"){for(var B=0;B<E.length;B++){if(this.data[B][0]==null){continue}A=[];var p=E[B][1]-this._barNudge;var H;if(this._stack&&this._prevGridData.length){H=this._prevGridData[B][0]}else{H=0}A.push([H,p+this.barWidth/2]);A.push([E[B][0],p+this.barWidth/2]);A.push([E[B][0],p-this.barWidth/2]);A.push([H,p-this.barWidth/2]);this.renderer.shadowRenderer.draw(y,A,v)}}}}}};function h(p,o,m){for(var n=0;n<this.series.length;n++){if(this.series[n].renderer.constructor==d.jqplot.BarRenderer){if(this.series[n].highlightMouseOver){this.series[n].highlightMouseDown=false}}}}function i(){if(this.plugins.barRenderer&&this.plugins.barRenderer.highlightCanvas){this.plugins.barRenderer.highlightCanvas.resetCanvas();this.plugins.barRenderer.highlightCanvas=null}this.plugins.barRenderer={highlightedSeriesIndex:null};this.plugins.barRenderer.highlightCanvas=new d.jqplot.GenericCanvas();this.eventCanvas._elem.before(this.plugins.barRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-barRenderer-highlight-canvas",this._plotDimensions,this));this.plugins.barRenderer.highlightCanvas.setContext();this.eventCanvas._elem.bind("mouseleave",{plot:this},function(m){j(m.data.plot)})}function c(t,r,p,o){var n=t.series[r];var m=t.plugins.barRenderer.highlightCanvas;m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);n._highlightedPoint=p;t.plugins.barRenderer.highlightedSeriesIndex=r;var q={fillStyle:n.highlightColors[p]};n.renderer.shapeRenderer.draw(m._ctx,o,q);m=null}function j(o){var m=o.plugins.barRenderer.highlightCanvas;m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);for(var n=0;n<o.series.length;n++){o.series[n]._highlightedPoint=null}o.plugins.barRenderer.highlightedSeriesIndex=null;o.target.trigger("jqplotDataUnhighlight");m=null}function b(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var n=jQuery.Event("jqplotDataMouseOver");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o);if(r.series[o[0]].highlightMouseOver&&!(o[0]==r.plugins.barRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){var m=jQuery.Event("jqplotDataHighlight");m.pageX=q.pageX;m.pageY=q.pageY;r.target.trigger(m,o);c(r,s.seriesIndex,s.pointIndex,s.points)}}else{if(s==null){j(r)}}}function a(p,o,s,r,q){if(r){var n=[r.seriesIndex,r.pointIndex,r.data];if(q.series[n[0]].highlightMouseDown&&!(n[0]==q.plugins.barRenderer.highlightedSeriesIndex&&n[1]==q.series[n[0]]._highlightedPoint)){var m=jQuery.Event("jqplotDataHighlight");m.pageX=p.pageX;m.pageY=p.pageY;q.target.trigger(m,n);c(q,r.seriesIndex,r.pointIndex,r.points)}}else{if(r==null){j(q)}}}function k(o,n,r,q,p){var m=p.plugins.barRenderer.highlightedSeriesIndex;if(m!=null&&p.series[m].highlightMouseDown){j(p)}}function e(p,o,s,r,q){if(r){var n=[r.seriesIndex,r.pointIndex,r.data];var m=jQuery.Event("jqplotDataClick");m.pageX=p.pageX;m.pageY=p.pageY;q.target.trigger(m,n)}}function l(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var m=r.plugins.barRenderer.highlightedSeriesIndex;if(m!=null&&r.series[m].highlightMouseDown){j(r)}var n=jQuery.Event("jqplotDataRightClick");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o)}}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.blockRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.blockRenderer.js
deleted file mode 100644
index 2028ee6..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.blockRenderer.js
+++ /dev/null
@@ -1,234 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-     * Class: $.jqplot.BlockRenderer
-     * Plugin renderer to draw a x-y block chart.  A Block chart has data points displayed as
-     * colored squares with a text label inside.  Data must be supplied in the form:
-     * 
-     * > [[x1, y1, "label 1", {css}], [x2, y2, "label 2", {css}], ...]
-     * 
-     * The label and css object are optional.  If the label is ommitted, the
-     * box will collapse unless a css height and/or width is specified.
-     * 
-     * The css object is an object specifying css properties 
-     * such as:
-     * 
-     * > {background:'#4f98a5', border:'3px solid gray', padding:'1px'}
-     * 
-     * Note that css properties specified with the data point override defaults
-     * specified with the series.
-     * 
-     */
-    $.jqplot.BlockRenderer = function(){
-        $.jqplot.LineRenderer.call(this);
-    };
-    
-    $.jqplot.BlockRenderer.prototype = new $.jqplot.LineRenderer();
-    $.jqplot.BlockRenderer.prototype.constructor = $.jqplot.BlockRenderer;
-    
-    // called with scope of a series
-    $.jqplot.BlockRenderer.prototype.init = function(options) {
-        // Group: Properties
-        //
-        // prop: css
-        // default css styles that will be applied to all data blocks.
-        // these values will be overridden by css styles supplied with the
-        // individulal data points.
-        this.css = {padding:'2px', border:'1px solid #999', textAlign:'center'};
-        // prop: escapeHtml
-        // true to escape html in the box label.
-        this.escapeHtml = false;
-        // prop: insertBreaks
-        // true to turn spaces in data block label into html breaks <br />.
-        this.insertBreaks = true;
-        // prop: varyBlockColors
-        // true to vary the color of each block in this series according to
-        // the seriesColors array.  False to set each block to the color
-        // specified on this series.  This has no effect if a css background color
-        // option is specified in the renderer css options.
-        this.varyBlockColors = false;
-        $.extend(true, this, options);
-        if (this.css.backgroundColor) {
-            this.color = this.css.backgroundColor;
-        }
-        else if (this.css.background) {
-            this.color = this.css.background;
-        }
-        else if (!this.varyBlockColors) {
-            this.css.background = this.color;
-        }
-        this.canvas = new $.jqplot.BlockCanvas();
-        this.shadowCanvas =  new $.jqplot.BlockCanvas();
-        this.canvas._plotDimensions = this._plotDimensions;
-        this.shadowCanvas._plotDimensions = this._plotDimensions;
-        this._type = 'block';
-        
-        // group: Methods 
-        //
-        // Method: moveBlock
-        // Moves an individual block.  More efficient than redrawing
-        // the whole series by calling plot.drawSeries().
-        // Properties:
-        // idx - the 0 based index of the block or point in this series.
-        // x - the x coordinate in data units (value on x axis) to move the block to.
-        // y - the y coordinate in data units (value on the y axis) to move the block to.
-        // duration - optional parameter to create an animated movement.  Can be a
-        // number (higher is slower animation) or 'fast', 'normal' or 'slow'.  If not
-        // provided, the element is moved without any animation.
-        this.moveBlock = function (idx, x, y, duration) {
-            // update plotData, stackData, data and gridData
-            // x and y are in data coordinates.
-            var el = this.canvas._elem.children(':eq('+idx+')');
-            this.data[idx][0] = x;
-            this.data[idx][1] = y;
-            this._plotData[idx][0] = x;
-            this._plotData[idx][1] = y;
-            this._stackData[idx][0] = x;
-            this._stackData[idx][1] = y;
-            this.gridData[idx][0] = this._xaxis.series_u2p(x);
-            this.gridData[idx][1] = this._yaxis.series_u2p(y);
-            var w = el.outerWidth();
-            var h = el.outerHeight();
-            var left = this.gridData[idx][0] - w/2 + 'px';
-            var top = this.gridData[idx][1] - h/2 + 'px';
-            if (duration) {
-                if (parseInt(duration, 10)) {
-                    duration = parseInt(duration, 10);
-                }
-                el.animate({left:left, top:top}, duration);
-            }
-            else {
-                el.css({left:left, top:top});
-            }
-            el = null;
-        };
-    };
-    
-    // called with scope of series
-    $.jqplot.BlockRenderer.prototype.draw = function (ctx, gd, options) {
-        if (this.plugins.pointLabels) {
-            this.plugins.pointLabels.show = false;
-        }
-        var i, el, d, gd, t, css, w, h, left, top;
-        var opts = (options != undefined) ? options : {};
-        var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors);
-        this.canvas._elem.empty();
-        for (i=0; i<this.gridData.length; i++) {
-            d = this.data[i];
-            gd = this.gridData[i];
-            t = '';
-            css = {};
-            if (typeof d[2] == 'string') {
-                t = d[2];
-            }
-            else if (typeof d[2] == 'object') {
-                css = d[2];
-            }
-            if (typeof d[3] ==  'object') {
-                css = d[3];
-            }
-            if (this.insertBreaks){ 
-                t = t.replace(/ /g, '<br />');
-            }
-            css = $.extend(true, {}, this.css, css);
-            // create a div
-            el = $('<div style="position:absolute;margin-left:auto;margin-right:auto;"></div>');
-            this.canvas._elem.append(el);
-            // set text
-            this.escapeHtml ? el.text(t) : el.html(t);
-            // style it
-            // remove styles we don't want overridden.
-            delete css.position;
-            delete css.marginRight;
-            delete css.marginLeft;
-            if (!css.background && !css.backgroundColor && !css.backgroundImage){ 
-                css.background = colorGenerator.next();
-            }
-            el.css(css);
-            w = el.outerWidth();
-            h = el.outerHeight();
-            left = gd[0] - w/2 + 'px';
-            top = gd[1] - h/2 + 'px';
-            el.css({left:left, top:top});
-            el = null;
-        }
-    };
-    
-    $.jqplot.BlockCanvas = function() {
-        $.jqplot.ElemContainer.call(this);
-        this._ctx;  
-    };
-    
-    $.jqplot.BlockCanvas.prototype = new $.jqplot.ElemContainer();
-    $.jqplot.BlockCanvas.prototype.constructor = $.jqplot.BlockCanvas;
-    
-    $.jqplot.BlockCanvas.prototype.createElement = function(offsets, clss, plotDimensions) {
-        this._offsets = offsets;
-        var klass = 'jqplot-blockCanvas';
-        if (clss != undefined) {
-            klass = clss;
-        }
-        var elem;
-        // if this canvas already has a dom element, don't make a new one.
-        if (this._elem) {
-            elem = this._elem.get(0);
-        }
-        else {
-            elem = document.createElement('div');
-        }
-        // if new plotDimensions supplied, use them.
-        if (plotDimensions != undefined) {
-            this._plotDimensions = plotDimensions;
-        }
-        
-        var w = this._plotDimensions.width - this._offsets.left - this._offsets.right + 'px';
-        var h = this._plotDimensions.height - this._offsets.top - this._offsets.bottom + 'px';
-        this._elem = $(elem);
-        this._elem.css({ position: 'absolute', width:w, height:h, left: this._offsets.left, top: this._offsets.top });
-        
-        this._elem.addClass(klass);
-        return this._elem;
-    };
-    
-    $.jqplot.BlockCanvas.prototype.setContext = function() {
-        this._ctx = {
-            canvas:{
-                width:0,
-                height:0
-            },
-            clearRect:function(){return null;}
-        };
-        return this._ctx;
-    };
-    
-})(jQuery);
-    
-    
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.blockRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.blockRenderer.min.js
deleted file mode 100644
index b0dbe37..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.blockRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.BlockRenderer=function(){a.jqplot.LineRenderer.call(this)};a.jqplot.BlockRenderer.prototype=new a.jqplot.LineRenderer();a.jqplot.BlockRenderer.prototype.constructor=a.jqplot.BlockRenderer;a.jqplot.BlockRenderer.prototype.init=function(b){this.css={padding:"2px",border:"1px solid #999",textAlign:"center"};this.escapeHtml=false;this.insertBreaks=true;this.varyBlockColors=false;a.extend(true,this,b);if(this.css.backgroundColor){this.color=this.css.backgroundColor}else{if(this.css.background){this.color=this.css.background}else{if(!this.varyBlockColors){this.css.background=this.color}}}this.canvas=new a.jqplot.BlockCanvas();this.shadowCanvas=new a.jqplot.BlockCanvas();this.canvas._plotDimensions=this._plotDimensions;this.shadowCanvas._plotDimensions=this._plotDimensions;this._type="block";this.moveBlock=function(l,j,i,e){var c=this.canvas._elem.children(":eq("+l+")");this.data[l][0]=j;this.data[l][1]=i;this._plotData[l][0]=j;this._plotData[l][1]=i;this._stackData[l][0]=j;this._stackData[l][1]=i;this.gridData[l][0]=this._xaxis.series_u2p(j);this.gridData[l][1]=this._yaxis.series_u2p(i);var k=c.outerWidth();var f=c.outerHeight();var d=this.gridData[l][0]-k/2+"px";var g=this.gridData[l][1]-f/2+"px";if(e){if(parseInt(e,10)){e=parseInt(e,10)}c.animate({left:d,top:g},e)}else{c.css({left:d,top:g})}c=null}};a.jqplot.BlockRenderer.prototype.draw=function(q,o,r){if(this.plugins.pointLabels){this.plugins.pointLabels.show=false}var f,c,l,o,p,k,n,g,e,m;var b=(r!=undefined)?r:{};var j=new a.jqplot.ColorGenerator(this.seriesColors);this.canvas._elem.empty();for(f=0;f<this.gridData.length;f++){l=this.data[f];o=this.gridData[f];p="";k={};if(typeof l[2]=="string"){p=l[2]}else{if(typeof l[2]=="object"){k=l[2]}}if(typeof l[3]=="object"){k=l[3]}if(this.insertBreaks){p=p.replace(/ /g,"<br />")}k=a.extend(true,{},this.css,k);c=a('<div style="position:absolute;margin-left:auto;margin-right:auto;"></div>');this.canvas._elem.append(c);this.escapeHtml?c.text(p):c.html(p);delete k.position;delete k.marginRight;delete k.marginLeft;if(!k.background&&!k.backgroundColor&&!k.backgroundImage){k.background=j.next()}c.css(k);n=c.outerWidth();g=c.outerHeight();e=o[0]-n/2+"px";m=o[1]-g/2+"px";c.css({left:e,top:m});c=null}};a.jqplot.BlockCanvas=function(){a.jqplot.ElemContainer.call(this);this._ctx};a.jqplot.BlockCanvas.prototype=new a.jqplot.ElemContainer();a.jqplot.BlockCanvas.prototype.constructor=a.jqplot.BlockCanvas;a.jqplot.BlockCanvas.prototype.createElement=function(i,e,c){this._offsets=i;var b="jqplot-blockCanvas";if(e!=undefined){b=e}var g;if(this._elem){g=this._elem.get(0)}else{g=document.createElement("div")}if(c!=undefined){this._plotDimensions=c}var d=this._plotDimensions.width-this._offsets.left-this._offsets.right+"px";var f=this._plotDimensions.height-this._offsets.top-this._offsets.bottom+"px";this._elem=a(g);this._elem.css({position:"absolute",width:d,height:f,left:this._offsets.left,top:this._offsets.top});this._elem.addClass(b);return this._elem};a.jqplot.BlockCanvas.prototype.setContext=function(){this._ctx={canvas:{width:0,height:0},clearRect:function(){return null}};return this._ctx}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.bubbleRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.bubbleRenderer.js
deleted file mode 100644
index e9cdfad..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.bubbleRenderer.js
+++ /dev/null
@@ -1,754 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    var arrayMax = function( array ){
-        return Math.max.apply( Math, array );
-    };
-    var arrayMin = function( array ){
-        return Math.min.apply( Math, array );
-    };
-
-    /**
-     * Class: $.jqplot.BubbleRenderer
-     * Plugin renderer to draw a bubble chart.  A Bubble chart has data points displayed as
-     * colored circles with an optional text label inside.  To use
-     * the bubble renderer, you must include the bubble renderer like:
-     * 
-     * > <script language="javascript" type="text/javascript" src="../src/plugins/jqplot.bubbleRenderer.js"></script>
-     * 
-     * Data must be supplied in 
-     * the form:
-     * 
-     * > [[x1, y1, r1, <label or {label:'text', color:color}>], ...]
-     * 
-     * where the label or options 
-     * object is optional.  
-     * 
-     * Note that all bubble colors will be the same
-     * unless the "varyBubbleColors" option is set to true.  Colors can be specified in the data array
-     * or in the seriesColors array option on the series.  If no colors are defined, the default jqPlot
-     * series of 16 colors are used.  Colors are automatically cycled around again if there are more
-     * bubbles than colors.
-     * 
-     * Bubbles are autoscaled by default to fit within the chart area while maintaining 
-     * relative sizes.  If the "autoscaleBubbles" option is set to false, the r(adius) values
-     * in the data array a treated as literal pixel values for the radii of the bubbles.
-     * 
-     * Properties are passed into the bubble renderer in the rendererOptions object of
-     * the series options like:
-     * 
-     * > seriesDefaults: {
-     * >     renderer: $.jqplot.BubbleRenderer,
-     * >     rendererOptions: {
-     * >         bubbleAlpha: 0.7,
-     * >         varyBubbleColors: false
-     * >     }
-     * > }
-     * 
-     */
-    $.jqplot.BubbleRenderer = function(){
-        $.jqplot.LineRenderer.call(this);
-    };
-    
-    $.jqplot.BubbleRenderer.prototype = new $.jqplot.LineRenderer();
-    $.jqplot.BubbleRenderer.prototype.constructor = $.jqplot.BubbleRenderer;
-    
-    // called with scope of a series
-    $.jqplot.BubbleRenderer.prototype.init = function(options, plot) {
-        // Group: Properties
-        //
-        // prop: varyBubbleColors
-        // True to vary the color of each bubble in this series according to
-        // the seriesColors array.  False to set each bubble to the color
-        // specified on this series.  This has no effect if a css background color
-        // option is specified in the renderer css options.
-        this.varyBubbleColors = true;
-        // prop: autoscaleBubbles
-        // True to scale the bubble radius based on plot size.
-        // False will use the radius value as provided as a raw pixel value for
-        // bubble radius.
-        this.autoscaleBubbles = true;
-        // prop: autoscaleMultiplier
-        // Multiplier the bubble size if autoscaleBubbles is true.
-        this.autoscaleMultiplier = 1.0;
-        // prop: autoscalePointsFactor
-        // Factor which decreases bubble size based on how many bubbles on on the chart.
-        // 0 means no adjustment for number of bubbles.  Negative values will decrease
-        // size of bubbles as more bubbles are added.  Values between 0 and -0.2
-        // should work well.
-        this.autoscalePointsFactor = -0.07;
-        // prop: escapeHtml
-        // True to escape html in bubble label text.
-        this.escapeHtml = true;
-        // prop: highlightMouseOver
-        // True to highlight bubbles when moused over.
-        // This must be false to enable highlightMouseDown to highlight when clicking on a slice.
-        this.highlightMouseOver = true;
-        // prop: highlightMouseDown
-        // True to highlight when a mouse button is pressed over a bubble.
-        // This will be disabled if highlightMouseOver is true.
-        this.highlightMouseDown = false;
-        // prop: highlightColors
-        // An array of colors to use when highlighting a slice.  Calculated automatically
-        // if not supplied.
-        this.highlightColors = [];
-        // prop: bubbleAlpha
-        // Alpha transparency to apply to all bubbles in this series.
-        this.bubbleAlpha = 1.0;
-        // prop: highlightAlpha
-        // Alpha transparency to apply when highlighting bubble.
-        // Set to value of bubbleAlpha by default.
-        this.highlightAlpha = null;
-        // prop: bubbleGradients
-        // True to color the bubbles with gradient fills instead of flat colors.
-        // NOT AVAILABLE IN IE due to lack of excanvas support for radial gradient fills.
-        // will be ignored in IE.
-        this.bubbleGradients = false;
-        // prop: showLabels
-        // True to show labels on bubbles (if any), false to not show.
-        this.showLabels = true;
-        // array of [point index, radius] which will be sorted in descending order to plot 
-        // largest points below smaller points.
-        this.radii = [];
-        this.maxRadius = 0;
-        // index of the currenty highlighted point, if any
-        this._highlightedPoint = null;
-        // array of jQuery labels.
-        this.labels = [];
-        this.bubbleCanvases = [];
-        this._type = 'bubble';
-        
-        // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
-        if (options.highlightMouseDown && options.highlightMouseOver == null) {
-            options.highlightMouseOver = false;
-        }
-        
-        $.extend(true, this, options);
-        
-        if (this.highlightAlpha == null) {
-            this.highlightAlpha = this.bubbleAlpha;
-            if (this.bubbleGradients) {
-                this.highlightAlpha = 0.35;
-            }
-        }
-        
-        this.autoscaleMultiplier = this.autoscaleMultiplier * Math.pow(this.data.length, this.autoscalePointsFactor);
-        
-        // index of the currenty highlighted point, if any
-        this._highlightedPoint = null;
-        
-        // adjust the series colors for options colors passed in with data or for alpha.
-        // note, this can leave undefined holes in the seriesColors array.
-        var comps;
-        for (var i=0; i<this.data.length; i++) {
-            var color = null;
-            var d = this.data[i];
-            this.maxRadius = Math.max(this.maxRadius, d[2]);
-            if (d[3]) {
-                if (typeof(d[3]) == 'object') {
-                    color = d[3]['color'];
-                }
-            }
-            
-            if (color == null) {
-                if (this.seriesColors[i] != null) {
-                    color = this.seriesColors[i];
-                }
-            }
-            
-            if (color && this.bubbleAlpha < 1.0) {
-                comps = $.jqplot.getColorComponents(color);
-                color = 'rgba('+comps[0]+', '+comps[1]+', '+comps[2]+', '+this.bubbleAlpha+')';
-            }
-            
-            if (color) {
-                this.seriesColors[i] = color;
-            }
-        }
-        
-        if (!this.varyBubbleColors) {
-            this.seriesColors = [this.color];
-        }
-        
-        this.colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors);
-        
-        // set highlight colors if none provided
-        if (this.highlightColors.length == 0) {
-            for (var i=0; i<this.seriesColors.length; i++){
-                var rgba = $.jqplot.getColorComponents(this.seriesColors[i]);
-                var newrgb = [rgba[0], rgba[1], rgba[2]];
-                var sum = newrgb[0] + newrgb[1] + newrgb[2];
-                for (var j=0; j<3; j++) {
-                    // when darkening, lowest color component can be is 60.
-                    newrgb[j] = (sum > 570) ?  newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]);
-                    newrgb[j] = parseInt(newrgb[j], 10);
-                }
-                this.highlightColors.push('rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+', '+this.highlightAlpha+')');
-            }
-        }
-        
-        this.highlightColorGenerator = new $.jqplot.ColorGenerator(this.highlightColors);
-        
-        var sopts = {fill:true, isarc:true, angle:this.shadowAngle, alpha:this.shadowAlpha, closePath:true};
-        
-        this.renderer.shadowRenderer.init(sopts);
-        
-        this.canvas = new $.jqplot.DivCanvas();
-        this.canvas._plotDimensions = this._plotDimensions;
-        
-        plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
-        plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
-        plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
-        plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
-        plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
-        plot.postDrawHooks.addOnce(postPlotDraw);
-        
-    };
-    
-
-    // converts the user data values to grid coordinates and stores them
-    // in the gridData array.
-    // Called with scope of a series.
-    $.jqplot.BubbleRenderer.prototype.setGridData = function(plot) {
-        // recalculate the grid data
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var data = this._plotData;
-        this.gridData = [];
-        var radii = [];
-        this.radii = [];
-        var dim = Math.min(plot._height, plot._width);
-        for (var i=0; i<this.data.length; i++) {
-            if (data[i] != null) {
-                this.gridData.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1]), data[i][2]]);
-                this.radii.push([i, data[i][2]]);
-                radii.push(data[i][2]);
-            }
-        }
-        var r, val, maxr = this.maxRadius = arrayMax(radii);
-        var l = this.gridData.length;
-        if (this.autoscaleBubbles) {
-            for (var i=0; i<l; i++) {
-                val = radii[i]/maxr;
-                r = this.autoscaleMultiplier * dim / 6;
-                this.gridData[i][2] = r * val;
-            }
-        }
-        
-        this.radii.sort(function(a, b) { return b[1] - a[1]; });
-    };
-    
-    // converts any arbitrary data values to grid coordinates and
-    // returns them.  This method exists so that plugins can use a series'
-    // linerenderer to generate grid data points without overwriting the
-    // grid data associated with that series.
-    // Called with scope of a series.
-    $.jqplot.BubbleRenderer.prototype.makeGridData = function(data, plot) {
-        // recalculate the grid data
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var gd = [];
-        var radii = [];
-        this.radii = [];
-        var dim = Math.min(plot._height, plot._width);
-        for (var i=0; i<data.length; i++) {
-            if (data[i] != null) {
-                gd.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1]), data[i][2]]);
-                radii.push(data[i][2]);
-                this.radii.push([i, data[i][2]]);
-            }
-        }
-        var r, val, maxr = this.maxRadius = arrayMax(radii);
-        var l = this.gridData.length;
-        if (this.autoscaleBubbles) {
-            for (var i=0; i<l; i++) {
-                val = radii[i]/maxr;
-                r = this.autoscaleMultiplier * dim / 6;
-                gd[i][2] = r * val;
-            }
-        }
-        this.radii.sort(function(a, b) { return b[1] - a[1]; });
-        return gd;
-    };
-    
-    // called with scope of series
-    $.jqplot.BubbleRenderer.prototype.draw = function (ctx, gd, options) {
-        if (this.plugins.pointLabels) {
-            this.plugins.pointLabels.show = false;
-        }
-        var opts = (options != undefined) ? options : {};
-        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
-        this.canvas._elem.empty();
-        for (var i=0; i<this.radii.length; i++) {
-            var idx = this.radii[i][0];
-            var t=null;
-            var color = null;
-            var el = null;
-            var tel = null;
-            var d = this.data[idx];
-            var gd = this.gridData[idx];
-            if (d[3]) {
-                if (typeof(d[3]) == 'object') {
-                    t = d[3]['label'];
-                }
-                else if (typeof(d[3]) == 'string') {
-                    t = d[3];
-                }
-            }
-            
-            // color = (this.varyBubbleColors) ? this.colorGenerator.get(idx) : this.color;
-            color = this.colorGenerator.get(idx);
-            
-            // If we're drawing a shadow, expand the canvas dimensions to accomodate.
-            var canvasRadius = gd[2];
-            var offset, depth;
-            if (this.shadow) {
-                offset = (0.7 + gd[2]/40).toFixed(1);
-                depth = 1 + Math.ceil(gd[2]/15);
-                canvasRadius += offset*depth;
-            }
-            this.bubbleCanvases[idx] = new $.jqplot.BubbleCanvas();
-            this.canvas._elem.append(this.bubbleCanvases[idx].createElement(gd[0], gd[1], canvasRadius));
-            this.bubbleCanvases[idx].setContext();
-            var ctx = this.bubbleCanvases[idx]._ctx;
-            var x = ctx.canvas.width/2;
-            var y = ctx.canvas.height/2;
-            if (this.shadow) {
-                this.renderer.shadowRenderer.draw(ctx, [x, y, gd[2], 0, 2*Math.PI], {offset: offset, depth: depth});
-            }
-            this.bubbleCanvases[idx].draw(gd[2], color, this.bubbleGradients, this.shadowAngle/180*Math.PI);
-            
-            // now draw label.
-            if (t && this.showLabels) {
-                tel = $('<div style="position:absolute;" class="jqplot-bubble-label"></div>');
-                if (this.escapeHtml) {
-                    tel.text(t);
-                }
-                else {
-                    tel.html(t);
-                }
-                this.canvas._elem.append(tel);
-                var h = $(tel).outerHeight();
-                var w = $(tel).outerWidth();
-                var top = gd[1] - 0.5*h;
-                var left = gd[0] - 0.5*w;
-                tel.css({top: top, left: left});
-                this.labels[idx] = $(tel);
-            }
-        }
-    };
-
-    
-    $.jqplot.DivCanvas = function() {
-        $.jqplot.ElemContainer.call(this);
-        this._ctx;  
-    };
-    
-    $.jqplot.DivCanvas.prototype = new $.jqplot.ElemContainer();
-    $.jqplot.DivCanvas.prototype.constructor = $.jqplot.DivCanvas;
-    
-    $.jqplot.DivCanvas.prototype.createElement = function(offsets, clss, plotDimensions) {
-        this._offsets = offsets;
-        var klass = 'jqplot-DivCanvas';
-        if (clss != undefined) {
-            klass = clss;
-        }
-        var elem;
-        // if this canvas already has a dom element, don't make a new one.
-        if (this._elem) {
-            elem = this._elem.get(0);
-        }
-        else {
-            elem = document.createElement('div');
-        }
-        // if new plotDimensions supplied, use them.
-        if (plotDimensions != undefined) {
-            this._plotDimensions = plotDimensions;
-        }
-        
-        var w = this._plotDimensions.width - this._offsets.left - this._offsets.right + 'px';
-        var h = this._plotDimensions.height - this._offsets.top - this._offsets.bottom + 'px';
-        this._elem = $(elem);
-        this._elem.css({ position: 'absolute', width:w, height:h, left: this._offsets.left, top: this._offsets.top });
-        
-        this._elem.addClass(klass);
-        return this._elem;
-    };
-    
-    $.jqplot.DivCanvas.prototype.setContext = function() {
-        this._ctx = {
-            canvas:{
-                width:0,
-                height:0
-            },
-            clearRect:function(){return null;}
-        };
-        return this._ctx;
-    };
-    
-    $.jqplot.BubbleCanvas = function() {
-        $.jqplot.ElemContainer.call(this);
-        this._ctx;
-    };
-    
-    $.jqplot.BubbleCanvas.prototype = new $.jqplot.ElemContainer();
-    $.jqplot.BubbleCanvas.prototype.constructor = $.jqplot.BubbleCanvas;
-    
-    // initialize with the x,y pont of bubble center and the bubble radius.
-    $.jqplot.BubbleCanvas.prototype.createElement = function(x, y, r) {     
-        var klass = 'jqplot-bubble-point';
-
-        var elem;
-        // if this canvas already has a dom element, don't make a new one.
-        if (this._elem) {
-            elem = this._elem.get(0);
-        }
-        else {
-            elem = document.createElement('canvas');
-        }
-        
-        elem.width = (r != null) ? 2*r : elem.width;
-        elem.height = (r != null) ? 2*r : elem.height;
-        this._elem = $(elem);
-        var l = (x != null && r != null) ? x - r : this._elem.css('left');
-        var t = (y != null && r != null) ? y - r : this._elem.css('top');
-        this._elem.css({ position: 'absolute', left: l, top: t });
-        
-        this._elem.addClass(klass);
-        if ($.jqplot.use_excanvas) {
-            window.G_vmlCanvasManager.init_(document);
-            elem = window.G_vmlCanvasManager.initElement(elem);
-        }
-        
-        return this._elem;
-    };
-    
-    $.jqplot.BubbleCanvas.prototype.draw = function(r, color, gradients, angle) {
-        var ctx = this._ctx;
-        // r = Math.floor(r*1.04);
-        // var x = Math.round(ctx.canvas.width/2);
-        // var y = Math.round(ctx.canvas.height/2);
-        var x = ctx.canvas.width/2;
-        var y = ctx.canvas.height/2;
-        ctx.save();
-        if (gradients && !$.jqplot.use_excanvas) {
-            r = r*1.04;
-            var comps = $.jqplot.getColorComponents(color);
-            var colorinner = 'rgba('+Math.round(comps[0]+0.8*(255-comps[0]))+', '+Math.round(comps[1]+0.8*(255-comps[1]))+', '+Math.round(comps[2]+0.8*(255-comps[2]))+', '+comps[3]+')';
-            var colorend = 'rgba('+comps[0]+', '+comps[1]+', '+comps[2]+', 0)';
-            // var rinner = Math.round(0.35 * r);
-            // var xinner = Math.round(x - Math.cos(angle) * 0.33 * r);
-            // var yinner = Math.round(y - Math.sin(angle) * 0.33 * r);
-            var rinner = 0.35 * r;
-            var xinner = x - Math.cos(angle) * 0.33 * r;
-            var yinner = y - Math.sin(angle) * 0.33 * r;
-            var radgrad = ctx.createRadialGradient(xinner, yinner, rinner, x, y, r);
-            radgrad.addColorStop(0, colorinner);
-            radgrad.addColorStop(0.93, color);
-            radgrad.addColorStop(0.96, colorend);
-            radgrad.addColorStop(1, colorend);
-            // radgrad.addColorStop(.98, colorend);
-            ctx.fillStyle = radgrad;
-            ctx.fillRect(0,0, ctx.canvas.width, ctx.canvas.height);
-        }
-        else {
-            ctx.fillStyle = color;
-            ctx.strokeStyle = color;
-            ctx.lineWidth = 1;
-            ctx.beginPath();
-            var ang = 2*Math.PI;
-            ctx.arc(x, y, r, 0, ang, 0);
-            ctx.closePath();
-            ctx.fill();
-        }
-        ctx.restore();
-    };
-    
-    $.jqplot.BubbleCanvas.prototype.setContext = function() {
-        this._ctx = this._elem.get(0).getContext("2d");
-        return this._ctx;
-    };
-    
-    $.jqplot.BubbleAxisRenderer = function() {
-        $.jqplot.LinearAxisRenderer.call(this);
-    };
-    
-    $.jqplot.BubbleAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
-    $.jqplot.BubbleAxisRenderer.prototype.constructor = $.jqplot.BubbleAxisRenderer;
-        
-    // called with scope of axis object.
-    $.jqplot.BubbleAxisRenderer.prototype.init = function(options){
-        $.extend(true, this, options);
-        var db = this._dataBounds;
-        var minsidx = 0,
-            minpidx = 0,
-            maxsidx = 0,
-            maxpidx = 0,
-            maxr = 0,
-            minr = 0,
-            minMaxRadius = 0,
-            maxMaxRadius = 0,
-            maxMult = 0,
-            minMult = 0;
-        // Go through all the series attached to this axis and find
-        // the min/max bounds for this axis.
-        for (var i=0; i<this._series.length; i++) {
-            var s = this._series[i];
-            var d = s._plotData;
-            
-            for (var j=0; j<d.length; j++) { 
-                if (this.name == 'xaxis' || this.name == 'x2axis') {
-                    if (d[j][0] < db.min || db.min == null) {
-                        db.min = d[j][0];
-                        minsidx=i;
-                        minpidx=j;
-                        minr = d[j][2];
-                        minMaxRadius = s.maxRadius;
-                        minMult = s.autoscaleMultiplier;
-                    }
-                    if (d[j][0] > db.max || db.max == null) {
-                        db.max = d[j][0];
-                        maxsidx=i;
-                        maxpidx=j;
-                        maxr = d[j][2];
-                        maxMaxRadius = s.maxRadius;
-                        maxMult = s.autoscaleMultiplier;
-                    }
-                }              
-                else {
-                    if (d[j][1] < db.min || db.min == null) {
-                        db.min = d[j][1];
-                        minsidx=i;
-                        minpidx=j;
-                        minr = d[j][2];
-                        minMaxRadius = s.maxRadius;
-                        minMult = s.autoscaleMultiplier;
-                    }
-                    if (d[j][1] > db.max || db.max == null) {
-                        db.max = d[j][1];
-                        maxsidx=i;
-                        maxpidx=j;
-                        maxr = d[j][2];
-                        maxMaxRadius = s.maxRadius;
-                        maxMult = s.autoscaleMultiplier;
-                    }
-                }              
-            }
-        }
-        
-        var minRatio = minr/minMaxRadius;
-        var maxRatio = maxr/maxMaxRadius;
-        
-        // need to estimate the effect of the radius on total axis span and adjust axis accordingly.
-        var span = db.max - db.min;
-        // var dim = (this.name == 'xaxis' || this.name == 'x2axis') ? this._plotDimensions.width : this._plotDimensions.height;
-        var dim = Math.min(this._plotDimensions.width, this._plotDimensions.height);
-        
-        var minfact = minRatio * minMult/3 * span;
-        var maxfact = maxRatio * maxMult/3 * span;
-        db.max += maxfact;
-        db.min -= minfact;
-    };
-    
-    function highlight (plot, sidx, pidx) {
-        plot.plugins.bubbleRenderer.highlightLabelCanvas.empty();
-        var s = plot.series[sidx];
-        var canvas = plot.plugins.bubbleRenderer.highlightCanvas;
-        var ctx = canvas._ctx;
-        ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height);
-        s._highlightedPoint = pidx;
-        plot.plugins.bubbleRenderer.highlightedSeriesIndex = sidx;
-        
-        var color = s.highlightColorGenerator.get(pidx);
-        var x = s.gridData[pidx][0],
-            y = s.gridData[pidx][1],
-            r = s.gridData[pidx][2];
-        ctx.save();
-        ctx.fillStyle = color;
-        ctx.strokeStyle = color;
-        ctx.lineWidth = 1;
-        ctx.beginPath();
-        ctx.arc(x, y, r, 0, 2*Math.PI, 0);
-        ctx.closePath();
-        ctx.fill();
-        ctx.restore();        
-        // bring label to front
-        if (s.labels[pidx]) {
-            plot.plugins.bubbleRenderer.highlightLabel = s.labels[pidx].clone();
-            plot.plugins.bubbleRenderer.highlightLabel.appendTo(plot.plugins.bubbleRenderer.highlightLabelCanvas);
-            plot.plugins.bubbleRenderer.highlightLabel.addClass('jqplot-bubble-label-highlight');
-        }
-    }
-    
-    function unhighlight (plot) {
-        var canvas = plot.plugins.bubbleRenderer.highlightCanvas;
-        var sidx = plot.plugins.bubbleRenderer.highlightedSeriesIndex;
-        plot.plugins.bubbleRenderer.highlightLabelCanvas.empty();
-        canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        for (var i=0; i<plot.series.length; i++) {
-            plot.series[i]._highlightedPoint = null;
-        }
-        plot.plugins.bubbleRenderer.highlightedSeriesIndex = null;
-        plot.target.trigger('jqplotDataUnhighlight');
-    }
-    
- 
-    function handleMove(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var si = neighbor.seriesIndex;
-            var pi = neighbor.pointIndex;
-            var ins = [si, pi, neighbor.data, plot.series[si].gridData[pi][2]];
-            var evt1 = jQuery.Event('jqplotDataMouseOver');
-            evt1.pageX = ev.pageX;
-            evt1.pageY = ev.pageY;
-            plot.target.trigger(evt1, ins);
-            if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.bubbleRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, ins[0], ins[1]);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    } 
-    
-    function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var si = neighbor.seriesIndex;
-            var pi = neighbor.pointIndex;
-            var ins = [si, pi, neighbor.data, plot.series[si].gridData[pi][2]];
-            if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.bubbleRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, ins[0], ins[1]);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    }
-    
-    function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
-        var idx = plot.plugins.bubbleRenderer.highlightedSeriesIndex;
-        if (idx != null && plot.series[idx].highlightMouseDown) {
-            unhighlight(plot);
-        }
-    }
-    
-    function handleClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var si = neighbor.seriesIndex;
-            var pi = neighbor.pointIndex;
-            var ins = [si, pi, neighbor.data, plot.series[si].gridData[pi][2]];
-            var evt = jQuery.Event('jqplotDataClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }
-    
-    function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var si = neighbor.seriesIndex;
-            var pi = neighbor.pointIndex;
-            var ins = [si, pi, neighbor.data, plot.series[si].gridData[pi][2]];
-            var idx = plot.plugins.bubbleRenderer.highlightedSeriesIndex;
-            if (idx != null && plot.series[idx].highlightMouseDown) {
-                unhighlight(plot);
-            }
-            var evt = jQuery.Event('jqplotDataRightClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }
-    
-    // called within context of plot
-    // create a canvas which we can draw on.
-    // insert it before the eventCanvas, so eventCanvas will still capture events.
-    function postPlotDraw() {
-        // Memory Leaks patch    
-        if (this.plugins.bubbleRenderer && this.plugins.bubbleRenderer.highlightCanvas) {
-            this.plugins.bubbleRenderer.highlightCanvas.resetCanvas();
-            this.plugins.bubbleRenderer.highlightCanvas = null;
-        }
-        
-        this.plugins.bubbleRenderer = {highlightedSeriesIndex:null};
-        this.plugins.bubbleRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
-        this.plugins.bubbleRenderer.highlightLabel = null;
-        this.plugins.bubbleRenderer.highlightLabelCanvas = $('<div style="position:absolute;"></div>');
-        var top = this._gridPadding.top;
-        var left = this._gridPadding.left;
-        var width = this._plotDimensions.width - this._gridPadding.left - this._gridPadding.right;
-        var height = this._plotDimensions.height - this._gridPadding.top - this._gridPadding.bottom;
-        this.plugins.bubbleRenderer.highlightLabelCanvas.css({top:top, left:left, width:width+'px', height:height+'px'});
-
-        this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-bubbleRenderer-highlight-canvas', this._plotDimensions, this));
-        this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightLabelCanvas);
-        
-        var hctx = this.plugins.bubbleRenderer.highlightCanvas.setContext();
-    }
-
-    
-    // setup default renderers for axes and legend so user doesn't have to
-    // called with scope of plot
-    function preInit(target, data, options) {
-        options = options || {};
-        options.axesDefaults = options.axesDefaults || {};
-        options.seriesDefaults = options.seriesDefaults || {};
-        // only set these if there is a Bubble series
-        var setopts = false;
-        if (options.seriesDefaults.renderer == $.jqplot.BubbleRenderer) {
-            setopts = true;
-        }
-        else if (options.series) {
-            for (var i=0; i < options.series.length; i++) {
-                if (options.series[i].renderer == $.jqplot.BubbleRenderer) {
-                    setopts = true;
-                }
-            }
-        }
-        
-        if (setopts) {
-            options.axesDefaults.renderer = $.jqplot.BubbleAxisRenderer;
-            options.sortData = false;
-        }
-    }
-    
-    $.jqplot.preInitHooks.push(preInit);
-    
-})(jQuery);
-    
-    
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.bubbleRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.bubbleRenderer.min.js
deleted file mode 100644
index ba8bfe0..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.bubbleRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(f){var d=function(m){return Math.max.apply(Math,m)};var j=function(m){return Math.min.apply(Math,m)};f.jqplot.BubbleRenderer=function(){f.jqplot.LineRenderer.call(this)};f.jqplot.BubbleRenderer.prototype=new f.jqplot.LineRenderer();f.jqplot.BubbleRenderer.prototype.constructor=f.jqplot.BubbleRenderer;f.jqplot.BubbleRenderer.prototype.init=function(w,t){this.varyBubbleColors=true;this.autoscaleBubbles=true;this.autoscaleMultiplier=1;this.autoscalePointsFactor=-0.07;this.escapeHtml=true;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.bubbleAlpha=1;this.highlightAlpha=null;this.bubbleGradients=false;this.showLabels=true;this.radii=[];this.maxRadius=0;this._highlightedPoint=null;this.labels=[];this.bubbleCanvases=[];this._type="bubble";if(w.highlightMouseDown&&w.highlightMouseOver==null){w.highlightMouseOver=false}f.extend(true,this,w);if(this.highlightAlpha==null){this.highlightAlpha=this.bubbleAlpha;if(this.bubbleGradients){this.highlightAlpha=0.35}}this.autoscaleMultiplier=this.autoscaleMultiplier*Math.pow(this.data.length,this.autoscalePointsFactor);this._highlightedPoint=null;var n;for(var r=0;r<this.data.length;r++){var p=null;var v=this.data[r];this.maxRadius=Math.max(this.maxRadius,v[2]);if(v[3]){if(typeof(v[3])=="object"){p=v[3]["color"]}}if(p==null){if(this.seriesColors[r]!=null){p=this.seriesColors[r]}}if(p&&this.bubbleAlpha<1){n=f.jqplot.getColorComponents(p);p="rgba("+n[0]+", "+n[1]+", "+n[2]+", "+this.bubbleAlpha+")"}if(p){this.seriesColors[r]=p}}if(!this.varyBubbleColors){this.seriesColors=[this.color]}this.colorGenerator=new f.jqplot.ColorGenerator(this.seriesColors);if(this.highlightColors.length==0){for(var r=0;r<this.seriesColors.length;r++){var o=f.jqplot.getColorComponents(this.seriesColors[r]);var u=[o[0],o[1],o[2]];var s=u[0]+u[1]+u[2];for(var q=0;q<3;q++){u[q]=(s>570)?u[q]*0.8:u[q]+0.3*(255-u[q]);u[q]=parseInt(u[q],10)}this.highlightColors.push("rgba("+u[0]+","+u[1]+","+u[2]+", "+this.highlightAlpha+")")}}this.highlightColorGenerator=new f.jqplot.ColorGenerator(this.highlightColors);var m={fill:true,isarc:true,angle:this.shadowAngle,alpha:this.shadowAlpha,closePath:true};this.renderer.shadowRenderer.init(m);this.canvas=new f.jqplot.DivCanvas();this.canvas._plotDimensions=this._plotDimensions;t.eventListenerHooks.addOnce("jqplotMouseMove",a);t.eventListenerHooks.addOnce("jqplotMouseDown",b);t.eventListenerHooks.addOnce("jqplotMouseUp",k);t.eventListenerHooks.addOnce("jqplotClick",g);t.eventListenerHooks.addOnce("jqplotRightClick",l);t.postDrawHooks.addOnce(h)};f.jqplot.BubbleRenderer.prototype.setGridData=function(w){var q=this._xaxis.series_u2p;var m=this._yaxis.series_u2p;var t=this._plotData;this.gridData=[];var s=[];this.radii=[];var v=Math.min(w._height,w._width);for(var u=0;u<this.data.length;u++){if(t[u]!=null){this.gridData.push([q.call(this._xaxis,t[u][0]),m.call(this._yaxis,t[u][1]),t[u][2]]);this.radii.push([u,t[u][2]]);s.push(t[u][2])}}var n,o,x=this.maxRadius=d(s);var p=this.gridData.length;if(this.autoscaleBubbles){for(var u=0;u<p;u++){o=s[u]/x;n=this.autoscaleMultiplier*v/6;this.gridData[u][2]=n*o}}this.radii.sort(function(y,r){return r[1]-y[1]})};f.jqplot.BubbleRenderer.prototype.makeGridData=function(t,w){var q=this._xaxis.series_u2p;var n=this._yaxis.series_u2p;var x=[];var s=[];this.radii=[];var v=Math.min(w._height,w._width);for(var u=0;u<t.length;u++){if(t[u]!=null){x.push([q.call(this._xaxis,t[u][0]),n.call(this._yaxis,t[u][1]),t[u][2]]);s.push(t[u][2]);this.radii.push([u,t[u][2]])}}var m,o,y=this.maxRadius=d(s);var p=this.gridData.length;if(this.autoscaleBubbles){for(var u=0;u<p;u++){o=s[u]/y;m=this.autoscaleMultiplier*v/6;x[u][2]=m*o}}this.radii.sort(function(z,r){return r[1]-z[1]});return x};f.jqplot.BubbleRenderer.prototype.draw=function(D,J,n){if(this.plugins.pointLabels){this.plugins.pointLabels.show=false}var A=(n!=undefined)?n:{};var r=(A.shadow!=undefined)?A.shadow:this.shadow;this.canvas._elem.empty();for(var G=0;G<this.radii.length;G++){var C=this.radii[G][0];var z=null;var F=null;var m=null;var p=null;var I=this.data[C];var J=this.gridData[C];if(I[3]){if(typeof(I[3])=="object"){z=I[3]["label"]}else{if(typeof(I[3])=="string"){z=I[3]}}}F=this.colorGenerator.get(C);var E=J[2];var q,K;if(this.shadow){q=(0.7+J[2]/40).toFixed(1);K=1+Math.ceil(J[2]/15);E+=q*K}this.bubbleCanvases[C]=new f.jqplot.BubbleCanvas();this.canvas._elem.append(this.bubbleCanvases[C].createElement(J[0],J[1],E));this.bubbleCanvases[C].setContext();var D=this.bubbleCanvases[C]._ctx;var u=D.canvas.width/2;var s=D.canvas.height/2;if(this.shadow){this.renderer.shadowRenderer.draw(D,[u,s,J[2],0,2*Math.PI],{offset:q,depth:K})}this.bubbleCanvases[C].draw(J[2],F,this.bubbleGradients,this.shadowAngle/180*Math.PI);if(z&&this.showLabels){p=f('<div style="position:absolute;" class="jqplot-bubble-label"></div>');if(this.escapeHtml){p.text(z)}else{p.html(z)}this.canvas._elem.append(p);var H=f(p).outerHeight();var v=f(p).outerWidth();var B=J[1]-0.5*H;var o=J[0]-0.5*v;p.css({top:B,left:o});this.labels[C]=f(p)}}};f.jqplot.DivCanvas=function(){f.jqplot.ElemContainer.call(this);this._ctx};f.jqplot.DivCanvas.prototype=new f.jqplot.ElemContainer();f.jqplot.DivCanvas.prototype.constructor=f.jqplot.DivCanvas;f.jqplot.DivCanvas.prototype.createElement=function(s,p,n){this._offsets=s;var m="jqplot-DivCanvas";if(p!=undefined){m=p}var r;if(this._elem){r=this._elem.get(0)}else{r=document.createElement("div")}if(n!=undefined){this._plotDimensions=n}var o=this._plotDimensions.width-this._offsets.left-this._offsets.right+"px";var q=this._plotDimensions.height-this._offsets.top-this._offsets.bottom+"px";this._elem=f(r);this._elem.css({position:"absolute",width:o,height:q,left:this._offsets.left,top:this._offsets.top});this._elem.addClass(m);return this._elem};f.jqplot.DivCanvas.prototype.setContext=function(){this._ctx={canvas:{width:0,height:0},clearRect:function(){return null}};return this._ctx};f.jqplot.BubbleCanvas=function(){f.jqplot.ElemContainer.call(this);this._ctx};f.jqplot.BubbleCanvas.prototype=new f.jqplot.ElemContainer();f.jqplot.BubbleCanvas.prototype.constructor=f.jqplot.BubbleCanvas;f.jqplot.BubbleCanvas.prototype.createElement=function(n,u,s){var m="jqplot-bubble-point";var q;if(this._elem){q=this._elem.get(0)}else{q=document.createElement("canvas")}q.width=(s!=null)?2*s:q.width;q.height=(s!=null)?2*s:q.height;this._elem=f(q);var o=(n!=null&&s!=null)?n-s:this._elem.css("left");var p=(u!=null&&s!=null)?u-s:this._elem.css("top");this._elem.css({position:"absolute",left:o,top:p});this._elem.addClass(m);if(f.jqplot.use_excanvas){window.G_vmlCanvasManager.init_(document);q=window.G_vmlCanvasManager.initElement(q)}return this._elem};f.jqplot.BubbleCanvas.prototype.draw=function(m,s,v,p){var D=this._ctx;var B=D.canvas.width/2;var z=D.canvas.height/2;D.save();if(v&&!f.jqplot.use_excanvas){m=m*1.04;var o=f.jqplot.getColorComponents(s);var u="rgba("+Math.round(o[0]+0.8*(255-o[0]))+", "+Math.round(o[1]+0.8*(255-o[1]))+", "+Math.round(o[2]+0.8*(255-o[2]))+", "+o[3]+")";var t="rgba("+o[0]+", "+o[1]+", "+o[2]+", 0)";var C=0.35*m;var A=B-Math.cos(p)*0.33*m;var n=z-Math.sin(p)*0.33*m;var w=D.createRadialGradient(A,n,C,B,z,m);w.addColorStop(0,u);w.addColorStop(0.93,s);w.addColorStop(0.96,t);w.addColorStop(1,t);D.fillStyle=w;D.fillRect(0,0,D.canvas.width,D.canvas.height)}else{D.fillStyle=s;D.strokeStyle=s;D.lineWidth=1;D.beginPath();var q=2*Math.PI;D.arc(B,z,m,0,q,0);D.closePath();D.fill()}D.restore()};f.jqplot.BubbleCanvas.prototype.setContext=function(){this._ctx=this._elem.get(0).getContext("2d");return this._ctx};f.jqplot.BubbleAxisRenderer=function(){f.jqplot.LinearAxisRenderer.call(this)};f.jqplot.BubbleAxisRenderer.prototype=new f.jqplot.LinearAxisRenderer();f.jqplot.BubbleAxisRenderer.prototype.constructor=f.jqplot.BubbleAxisRenderer;f.jqplot.BubbleAxisRenderer.prototype.init=function(n){f.extend(true,this,n);var I=this._dataBounds;var H=0,v=0,m=0,y=0,q=0,r=0,D=0,t=0,F=0,z=0;for(var E=0;E<this._series.length;E++){var x=this._series[E];var G=x._plotData;for(var B=0;B<G.length;B++){if(this.name=="xaxis"||this.name=="x2axis"){if(G[B][0]<I.min||I.min==null){I.min=G[B][0];H=E;v=B;r=G[B][2];D=x.maxRadius;z=x.autoscaleMultiplier}if(G[B][0]>I.max||I.max==null){I.max=G[B][0];m=E;y=B;q=G[B][2];t=x.maxRadius;F=x.autoscaleMultiplier}}else{if(G[B][1]<I.min||I.min==null){I.min=G[B][1];H=E;v=B;r=G[B][2];D=x.maxRadius;z=x.autoscaleMultiplier}if(G[B][1]>I.max||I.max==null){I.max=G[B][1];m=E;y=B;q=G[B][2];t=x.maxRadius;F=x.autoscaleMultiplier}}}}var o=r/D;var w=q/t;var C=I.max-I.min;var A=Math.min(this._plotDimensions.width,this._plotDimensions.height);var p=o*z/3*C;var u=w*F/3*C;I.max+=u;I.min-=p};function e(p,v,q){p.plugins.bubbleRenderer.highlightLabelCanvas.empty();var z=p.series[v];var n=p.plugins.bubbleRenderer.highlightCanvas;var w=n._ctx;w.clearRect(0,0,w.canvas.width,w.canvas.height);z._highlightedPoint=q;p.plugins.bubbleRenderer.highlightedSeriesIndex=v;var o=z.highlightColorGenerator.get(q);var u=z.gridData[q][0],t=z.gridData[q][1],m=z.gridData[q][2];w.save();w.fillStyle=o;w.strokeStyle=o;w.lineWidth=1;w.beginPath();w.arc(u,t,m,0,2*Math.PI,0);w.closePath();w.fill();w.restore();if(z.labels[q]){p.plugins.bubbleRenderer.highlightLabel=z.labels[q].clone();p.plugins.bubbleRenderer.highlightLabel.appendTo(p.plugins.bubbleRenderer.highlightLabelCanvas);p.plugins.bubbleRenderer.highlightLabel.addClass("jqplot-bubble-label-highlight")}}function i(p){var m=p.plugins.bubbleRenderer.highlightCanvas;var o=p.plugins.bubbleRenderer.highlightedSeriesIndex;p.plugins.bubbleRenderer.highlightLabelCanvas.empty();m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);for(var n=0;n<p.series.length;n++){p.series[n]._highlightedPoint=null}p.plugins.bubbleRenderer.highlightedSeriesIndex=null;p.target.trigger("jqplotDataUnhighlight")}function a(s,p,m,v,r){if(v){var n=v.seriesIndex;var o=v.pointIndex;var q=[n,o,v.data,r.series[n].gridData[o][2]];var t=jQuery.Event("jqplotDataMouseOver");t.pageX=s.pageX;t.pageY=s.pageY;r.target.trigger(t,q);if(r.series[q[0]].highlightMouseOver&&!(q[0]==r.plugins.bubbleRenderer.highlightedSeriesIndex&&q[1]==r.series[q[0]]._highlightedPoint)){var u=jQuery.Event("jqplotDataHighlight");u.pageX=s.pageX;u.pageY=s.pageY;r.target.trigger(u,q);e(r,q[0],q[1])}}else{if(v==null){i(r)}}}function b(s,p,m,u,r){if(u){var n=u.seriesIndex;var o=u.pointIndex;var q=[n,o,u.data,r.series[n].gridData[o][2]];if(r.series[q[0]].highlightMouseDown&&!(q[0]==r.plugins.bubbleRenderer.highlightedSeriesIndex&&q[1]==r.series[q[0]]._highlightedPoint)){var t=jQuery.Event("jqplotDataHighlight");t.pageX=s.pageX;t.pageY=s.pageY;r.target.trigger(t,q);e(r,q[0],q[1])}}else{if(u==null){i(r)}}}function k(o,n,r,q,p){var m=p.plugins.bubbleRenderer.highlightedSeriesIndex;if(m!=null&&p.series[m].highlightMouseDown){i(p)}}function g(s,p,m,u,r){if(u){var n=u.seriesIndex;var o=u.pointIndex;var q=[n,o,u.data,r.series[n].gridData[o][2]];var t=jQuery.Event("jqplotDataClick");t.pageX=s.pageX;t.pageY=s.pageY;r.target.trigger(t,q)}}function l(s,p,m,v,r){if(v){var n=v.seriesIndex;var o=v.pointIndex;var q=[n,o,v.data,r.series[n].gridData[o][2]];var t=r.plugins.bubbleRenderer.highlightedSeriesIndex;if(t!=null&&r.series[t].highlightMouseDown){i(r)}var u=jQuery.Event("jqplotDataRightClick");u.pageX=s.pageX;u.pageY=s.pageY;r.target.trigger(u,q)}}function h(){if(this.plugins.bubbleRenderer&&this.plugins.bubbleRenderer.highlightCanvas){this.plugins.bubbleRenderer.highlightCanvas.resetCanvas();this.plugins.bubbleRenderer.highlightCanvas=null}this.plugins.bubbleRenderer={highlightedSeriesIndex:null};this.plugins.bubbleRenderer.highlightCanvas=new f.jqplot.GenericCanvas();this.plugins.bubbleRenderer.highlightLabel=null;this.plugins.bubbleRenderer.highlightLabelCanvas=f('<div style="position:absolute;"></div>');var q=this._gridPadding.top;var p=this._gridPadding.left;var n=this._plotDimensions.width-this._gridPadding.left-this._gridPadding.right;var m=this._plotDimensions.height-this._gridPadding.top-this._gridPadding.bottom;this.plugins.bubbleRenderer.highlightLabelCanvas.css({top:q,left:p,width:n+"px",height:m+"px"});this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-bubbleRenderer-highlight-canvas",this._plotDimensions,this));this.eventCanvas._elem.before(this.plugins.bubbleRenderer.highlightLabelCanvas);var o=this.plugins.bubbleRenderer.highlightCanvas.setContext()}function c(q,p,n){n=n||{};n.axesDefaults=n.axesDefaults||{};n.seriesDefaults=n.seriesDefaults||{};var m=false;if(n.seriesDefaults.renderer==f.jqplot.BubbleRenderer){m=true}else{if(n.series){for(var o=0;o<n.series.length;o++){if(n.series[o].renderer==f.jqplot.BubbleRenderer){m=true}}}}if(m){n.axesDefaults.renderer=f.jqplot.BubbleAxisRenderer;n.sortData=false}}f.jqplot.preInitHooks.push(c)})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js
deleted file mode 100644
index 53520d9..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-    * Class: $.jqplot.CanvasAxisLabelRenderer
-    * Renderer to draw axis labels with a canvas element to support advanced
-    * featrues such as rotated text.  This renderer uses a separate rendering engine
-    * to draw the text on the canvas.  Two modes of rendering the text are available.
-    * If the browser has native font support for canvas fonts (currently Mozila 3.5
-    * and Safari 4), you can enable text rendering with the canvas fillText method.
-    * You do so by setting the "enableFontSupport" option to true. 
-    * 
-    * Browsers lacking native font support will have the text drawn on the canvas
-    * using the Hershey font metrics.  Even if the "enableFontSupport" option is true
-    * non-supporting browsers will still render with the Hershey font.
-    * 
-    */
-    $.jqplot.CanvasAxisLabelRenderer = function(options) {
-        // Group: Properties
-        
-        // prop: angle
-        // angle of text, measured clockwise from x axis.
-        this.angle = 0;
-        // name of the axis associated with this tick
-        this.axis;
-        // prop: show
-        // wether or not to show the tick (mark and label).
-        this.show = true;
-        // prop: showLabel
-        // wether or not to show the label.
-        this.showLabel = true;
-        // prop: label
-        // label for the axis.
-        this.label = '';
-        // prop: fontFamily
-        // CSS spec for the font-family css attribute.
-        // Applies only to browsers supporting native font rendering in the
-        // canvas tag.  Currently Mozilla 3.5 and Safari 4.
-        this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
-        // prop: fontSize
-        // CSS spec for font size.
-        this.fontSize = '11pt';
-        // prop: fontWeight
-        // CSS spec for fontWeight:  normal, bold, bolder, lighter or a number 100 - 900
-        this.fontWeight = 'normal';
-        // prop: fontStretch
-        // Multiplier to condense or expand font width.  
-        // Applies only to browsers which don't support canvas native font rendering.
-        this.fontStretch = 1.0;
-        // prop: textColor
-        // css spec for the color attribute.
-        this.textColor = '#666666';
-        // prop: enableFontSupport
-        // true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
-        // If true, label will be drawn with canvas tag native support for fonts.
-        // If false, label will be drawn with Hershey font metrics.
-        this.enableFontSupport = true;
-        // prop: pt2px
-        // Point to pixel scaling factor, used for computing height of bounding box
-        // around a label.  The labels text renderer has a default setting of 1.4, which 
-        // should be suitable for most fonts.  Leave as null to use default.  If tops of
-        // letters appear clipped, increase this.  If bounding box seems too big, decrease.
-        // This is an issue only with the native font renderering capabilities of Mozilla
-        // 3.5 and Safari 4 since they do not provide a method to determine the font height.
-        this.pt2px = null;
-        
-        this._elem;
-        this._ctx;
-        this._plotWidth;
-        this._plotHeight;
-        this._plotDimensions = {height:null, width:null};
-        
-        $.extend(true, this, options);
-        
-        if (options.angle == null && this.axis != 'xaxis' && this.axis != 'x2axis') {
-            this.angle = -90;
-        }
-        
-        var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
-        if (this.pt2px) {
-            ropts.pt2px = this.pt2px;
-        }
-        
-        if (this.enableFontSupport) {
-            if ($.jqplot.support_canvas_text()) {
-                this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
-            }
-            
-            else {
-                this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts); 
-            }
-        }
-        else {
-            this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts); 
-        }
-    };
-    
-    $.jqplot.CanvasAxisLabelRenderer.prototype.init = function(options) {
-        $.extend(true, this, options);
-        this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
-    };
-    
-    // return width along the x axis
-    // will check first to see if an element exists.
-    // if not, will return the computed text box width.
-    $.jqplot.CanvasAxisLabelRenderer.prototype.getWidth = function(ctx) {
-        if (this._elem) {
-         return this._elem.outerWidth(true);
-        }
-        else {
-            var tr = this._textRenderer;
-            var l = tr.getWidth(ctx);
-            var h = tr.getHeight(ctx);
-            var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
-            return w;
-        }
-    };
-    
-    // return height along the y axis.
-    $.jqplot.CanvasAxisLabelRenderer.prototype.getHeight = function(ctx) {
-        if (this._elem) {
-         return this._elem.outerHeight(true);
-        }
-        else {
-            var tr = this._textRenderer;
-            var l = tr.getWidth(ctx);
-            var h = tr.getHeight(ctx);
-            var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
-            return w;
-        }
-    };
-    
-    $.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad = function() {
-        var a = this.angle * Math.PI/180;
-        return a;
-    };
-    
-    $.jqplot.CanvasAxisLabelRenderer.prototype.draw = function(ctx, plot) {
-          // Memory Leaks patch
-          if (this._elem) {
-              if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
-                  window.G_vmlCanvasManager.uninitElement(this._elem.get(0));
-              }
-            
-              this._elem.emptyForce();
-              this._elem = null;
-          }
-
-        // create a canvas here, but can't draw on it untill it is appended
-        // to dom for IE compatability.
-        var elem = plot.canvasManager.getCanvas();
-
-        this._textRenderer.setText(this.label, ctx);
-        var w = this.getWidth(ctx);
-        var h = this.getHeight(ctx);
-        elem.width = w;
-        elem.height = h;
-        elem.style.width = w;
-        elem.style.height = h;
-        
-		elem = plot.canvasManager.initCanvas(elem);
-		
-        this._elem = $(elem);
-        this._elem.css({ position: 'absolute'});
-        this._elem.addClass('jqplot-'+this.axis+'-label');
-        
-        elem = null;
-        return this._elem;
-    };
-    
-    $.jqplot.CanvasAxisLabelRenderer.prototype.pack = function() {
-        this._textRenderer.draw(this._elem.get(0).getContext("2d"), this.label);
-    };
-    
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js
deleted file mode 100644
index 434b96f..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.CanvasAxisLabelRenderer=function(b){this.angle=0;this.axis;this.show=true;this.showLabel=true;this.label="";this.fontFamily='"Trebuchet MS", Arial, Helvetica, sans-serif';this.fontSize="11pt";this.fontWeight="normal";this.fontStretch=1;this.textColor="#666666";this.enableFontSupport=true;this.pt2px=null;this._elem;this._ctx;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null};a.extend(true,this,b);if(b.angle==null&&this.axis!="xaxis"&&this.axis!="x2axis"){this.angle=-90}var c={fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily};if(this.pt2px){c.pt2px=this.pt2px}if(this.enableFontSupport){if(a.jqplot.support_canvas_text()){this._textRenderer=new a.jqplot.CanvasFontRenderer(c)}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}};a.jqplot.CanvasAxisLabelRenderer.prototype.init=function(b){a.extend(true,this,b);this._textRenderer.init({fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily})};a.jqplot.CanvasAxisLabelRenderer.prototype.getWidth=function(d){if(this._elem){return this._elem.outerWidth(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.sin(f.angle)*e)+Math.abs(Math.cos(f.angle)*c);return b}};a.jqplot.CanvasAxisLabelRenderer.prototype.getHeight=function(d){if(this._elem){return this._elem.outerHeight(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.cos(f.angle)*e)+Math.abs(Math.sin(f.angle)*c);return b}};a.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad=function(){var b=this.angle*Math.PI/180;return b};a.jqplot.CanvasAxisLabelRenderer.prototype.draw=function(c,f){if(this._elem){if(a.jqplot.use_excanvas&&window.G_vmlCanvasManager.uninitElement!==undefined){window.G_vmlCanvasManager.uninitElement(this._elem.get(0))}this._elem.emptyForce();this._elem=null}var e=f.canvasManager.getCanvas();this._textRenderer.setText(this.label,c);var b=this.getWidth(c);var d=this.getHeight(c);e.width=b;e.height=d;e.style.width=b;e.style.height=d;e=f.canvasManager.initCanvas(e);this._elem=a(e);this._elem.css({position:"absolute"});this._elem.addClass("jqplot-"+this.axis+"-label");e=null;return this._elem};a.jqplot.CanvasAxisLabelRenderer.prototype.pack=function(){this._textRenderer.draw(this._elem.get(0).getContext("2d"),this.label)}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisTickRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisTickRenderer.js
deleted file mode 100644
index e0cb9a6..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisTickRenderer.js
+++ /dev/null
@@ -1,242 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-    *  Class: $.jqplot.CanvasAxisTickRenderer
-    * Renderer to draw axis ticks with a canvas element to support advanced
-    * featrues such as rotated text.  This renderer uses a separate rendering engine
-    * to draw the text on the canvas.  Two modes of rendering the text are available.
-    * If the browser has native font support for canvas fonts (currently Mozila 3.5
-    * and Safari 4), you can enable text rendering with the canvas fillText method.
-    * You do so by setting the "enableFontSupport" option to true. 
-    * 
-    * Browsers lacking native font support will have the text drawn on the canvas
-    * using the Hershey font metrics.  Even if the "enableFontSupport" option is true
-    * non-supporting browsers will still render with the Hershey font.
-    */
-    $.jqplot.CanvasAxisTickRenderer = function(options) {
-        // Group: Properties
-        
-        // prop: mark
-        // tick mark on the axis.  One of 'inside', 'outside', 'cross', '' or null.
-        this.mark = 'outside';
-        // prop: showMark
-        // wether or not to show the mark on the axis.
-        this.showMark = true;
-        // prop: showGridline
-        // wether or not to draw the gridline on the grid at this tick.
-        this.showGridline = true;
-        // prop: isMinorTick
-        // if this is a minor tick.
-        this.isMinorTick = false;
-        // prop: angle
-        // angle of text, measured clockwise from x axis.
-        this.angle = 0;
-        // prop:  markSize
-        // Length of the tick marks in pixels.  For 'cross' style, length
-        // will be stoked above and below axis, so total length will be twice this.
-        this.markSize = 4;
-        // prop: show
-        // wether or not to show the tick (mark and label).
-        this.show = true;
-        // prop: showLabel
-        // wether or not to show the label.
-        this.showLabel = true;
-        // prop: labelPosition
-        // 'auto', 'start', 'middle' or 'end'.
-        // Whether tick label should be positioned so the start, middle, or end
-        // of the tick mark.
-        this.labelPosition = 'auto';
-        this.label = '';
-        this.value = null;
-        this._styles = {};
-        // prop: formatter
-        // A class of a formatter for the tick text.
-        // The default $.jqplot.DefaultTickFormatter uses sprintf.
-        this.formatter = $.jqplot.DefaultTickFormatter;
-        // prop: formatString
-        // string passed to the formatter.
-        this.formatString = '';
-        // prop: prefix
-        // String to prepend to the tick label.
-        // Prefix is prepended to the formatted tick label.
-        this.prefix = '';
-        // prop: fontFamily
-        // css spec for the font-family css attribute.
-        this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
-        // prop: fontSize
-        // CSS spec for font size.
-        this.fontSize = '10pt';
-        // prop: fontWeight
-        // CSS spec for fontWeight
-        this.fontWeight = 'normal';
-        // prop: fontStretch
-        // Multiplier to condense or expand font width.  
-        // Applies only to browsers which don't support canvas native font rendering.
-        this.fontStretch = 1.0;
-        // prop: textColor
-        // css spec for the color attribute.
-        this.textColor = '#666666';
-        // prop: enableFontSupport
-        // true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
-        // If true, tick label will be drawn with canvas tag native support for fonts.
-        // If false, tick label will be drawn with Hershey font metrics.
-        this.enableFontSupport = true;
-        // prop: pt2px
-        // Point to pixel scaling factor, used for computing height of bounding box
-        // around a label.  The labels text renderer has a default setting of 1.4, which 
-        // should be suitable for most fonts.  Leave as null to use default.  If tops of
-        // letters appear clipped, increase this.  If bounding box seems too big, decrease.
-        // This is an issue only with the native font renderering capabilities of Mozilla
-        // 3.5 and Safari 4 since they do not provide a method to determine the font height.
-        this.pt2px = null;
-        
-        this._elem;
-        this._ctx;
-        this._plotWidth;
-        this._plotHeight;
-        this._plotDimensions = {height:null, width:null};
-        
-        $.extend(true, this, options);
-        
-        var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
-        if (this.pt2px) {
-            ropts.pt2px = this.pt2px;
-        }
-        
-        if (this.enableFontSupport) {
-            if ($.jqplot.support_canvas_text()) {
-                this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
-            }
-            
-            else {
-                this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts); 
-            }
-        }
-        else {
-            this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts); 
-        }
-    };
-    
-    $.jqplot.CanvasAxisTickRenderer.prototype.init = function(options) {
-        $.extend(true, this, options);
-        this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
-    };
-    
-    // return width along the x axis
-    // will check first to see if an element exists.
-    // if not, will return the computed text box width.
-    $.jqplot.CanvasAxisTickRenderer.prototype.getWidth = function(ctx) {
-        if (this._elem) {
-         return this._elem.outerWidth(true);
-        }
-        else {
-            var tr = this._textRenderer;
-            var l = tr.getWidth(ctx);
-            var h = tr.getHeight(ctx);
-            var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
-            return w;
-        }
-    };
-    
-    // return height along the y axis.
-    $.jqplot.CanvasAxisTickRenderer.prototype.getHeight = function(ctx) {
-        if (this._elem) {
-         return this._elem.outerHeight(true);
-        }
-        else {
-            var tr = this._textRenderer;
-            var l = tr.getWidth(ctx);
-            var h = tr.getHeight(ctx);
-            var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
-            return w;
-        }
-    };
-    
-    $.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad = function() {
-        var a = this.angle * Math.PI/180;
-        return a;
-    };
-    
-    
-    $.jqplot.CanvasAxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) {
-        this.value = value;
-        if (isMinor) {
-            this.isMinorTick = true;
-        }
-        return this;
-    };
-    
-    $.jqplot.CanvasAxisTickRenderer.prototype.draw = function(ctx, plot) {
-        if (!this.label) {
-            this.label = this.prefix + this.formatter(this.formatString, this.value);
-        }
-        
-        // Memory Leaks patch
-        if (this._elem) {
-            if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
-                window.G_vmlCanvasManager.uninitElement(this._elem.get(0));
-            }
-            
-            this._elem.emptyForce();
-            this._elem = null;
-        }
-
-        // create a canvas here, but can't draw on it untill it is appended
-        // to dom for IE compatability.
-
-        var elem = plot.canvasManager.getCanvas();
-
-        this._textRenderer.setText(this.label, ctx);
-        var w = this.getWidth(ctx);
-        var h = this.getHeight(ctx);
-        // canvases seem to need to have width and heigh attributes directly set.
-        elem.width = w;
-        elem.height = h;
-        elem.style.width = w;
-        elem.style.height = h;
-        elem.style.textAlign = 'left';
-        elem.style.position = 'absolute';
-		
-		elem = plot.canvasManager.initCanvas(elem);
-		
-        this._elem = $(elem);
-        this._elem.css(this._styles);
-        this._elem.addClass('jqplot-'+this.axis+'-tick');
-		
-        elem = null;
-        return this._elem;
-    };
-    
-    $.jqplot.CanvasAxisTickRenderer.prototype.pack = function() {
-        this._textRenderer.draw(this._elem.get(0).getContext("2d"), this.label);
-    };
-    
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js
deleted file mode 100644
index dbae162..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.CanvasAxisTickRenderer=function(b){this.mark="outside";this.showMark=true;this.showGridline=true;this.isMinorTick=false;this.angle=0;this.markSize=4;this.show=true;this.showLabel=true;this.labelPosition="auto";this.label="";this.value=null;this._styles={};this.formatter=a.jqplot.DefaultTickFormatter;this.formatString="";this.prefix="";this.fontFamily='"Trebuchet MS", Arial, Helvetica, sans-serif';this.fontSize="10pt";this.fontWeight="normal";this.fontStretch=1;this.textColor="#666666";this.enableFontSupport=true;this.pt2px=null;this._elem;this._ctx;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null};a.extend(true,this,b);var c={fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily};if(this.pt2px){c.pt2px=this.pt2px}if(this.enableFontSupport){if(a.jqplot.support_canvas_text()){this._textRenderer=new a.jqplot.CanvasFontRenderer(c)}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}};a.jqplot.CanvasAxisTickRenderer.prototype.init=function(b){a.extend(true,this,b);this._textRenderer.init({fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily})};a.jqplot.CanvasAxisTickRenderer.prototype.getWidth=function(d){if(this._elem){return this._elem.outerWidth(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.sin(f.angle)*e)+Math.abs(Math.cos(f.angle)*c);return b}};a.jqplot.CanvasAxisTickRenderer.prototype.getHeight=function(d){if(this._elem){return this._elem.outerHeight(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.cos(f.angle)*e)+Math.abs(Math.sin(f.angle)*c);return b}};a.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad=function(){var b=this.angle*Math.PI/180;return b};a.jqplot.CanvasAxisTickRenderer.prototype.setTick=function(b,d,c){this.value=b;if(c){this.isMinorTick=true}return this};a.jqplot.CanvasAxisTickRenderer.prototype.draw=function(c,f){if(!this.label){this.label=this.prefix+this.formatter(this.formatString,this.value)}if(this._elem){if(a.jqplot.use_excanvas&&window.G_vmlCanvasManager.uninitElement!==undefined){window.G_vmlCanvasManager.uninitElement(this._elem.get(0))}this._elem.emptyForce();this._elem=null}var e=f.canvasManager.getCanvas();this._textRenderer.setText(this.label,c);var b=this.getWidth(c);var d=this.getHeight(c);e.width=b;e.height=d;e.style.width=b;e.style.height=d;e.style.textAlign="left";e.style.position="absolute";e=f.canvasManager.initCanvas(e);this._elem=a(e);this._elem.css(this._styles);this._elem.addClass("jqplot-"+this.axis+"-tick");e=null;return this._elem};a.jqplot.CanvasAxisTickRenderer.prototype.pack=function(){this._textRenderer.draw(this._elem.get(0).getContext("2d"),this.label)}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasOverlay.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasOverlay.js
deleted file mode 100644
index eb67fcc..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasOverlay.js
+++ /dev/null
@@ -1,864 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    var objCounter = 0;
-    // class: $.jqplot.CanvasOverlay
-    $.jqplot.CanvasOverlay = function(opts){
-        var options = opts || {};
-        this.options = {
-            show: $.jqplot.config.enablePlugins,
-            deferDraw: false
-        };
-        // prop: objects
-        this.objects = [];
-        this.objectNames = [];
-        this.canvas = null;
-        this.markerRenderer = new $.jqplot.MarkerRenderer({style:'line'});
-        this.markerRenderer.init();
-        this.highlightObjectIndex = null;
-        if (options.objects) {
-            var objs = options.objects,
-                obj;
-            for (var i=0; i<objs.length; i++) {
-                obj = objs[i];
-                for (var n in obj) {
-                    switch (n) {
-                        case 'line':
-                            this.addLine(obj[n]);
-                            break;
-                        case 'horizontalLine':
-                            this.addHorizontalLine(obj[n]);
-                            break;
-                        case 'dashedHorizontalLine':
-                            this.addDashedHorizontalLine(obj[n]);
-                            break;
-                        case 'verticalLine':
-                            this.addVerticalLine(obj[n]);
-                            break;
-                        case 'dashedVerticalLine':
-                            this.addDashedVerticalLine(obj[n]);
-                            break;
-                        default:
-                            break;
-                    }
-                }   
-            }
-        }
-        $.extend(true, this.options, options);
-    };
-    
-    // called with scope of a plot object
-    $.jqplot.CanvasOverlay.postPlotInit = function (target, data, opts) {
-        var options = opts || {};
-        // add a canvasOverlay attribute to the plot
-        this.plugins.canvasOverlay = new $.jqplot.CanvasOverlay(options.canvasOverlay);     
-    };
-
-
-    function LineBase() {
-        this.uid = null;
-        this.type = null;
-        this.gridStart = null;
-        this.gridStop = null;
-        this.tooltipWidthFactor = 0;
-        this.options = {           
-            // prop: name
-            // Optional name for the overlay object.
-            // Can be later used to retrieve the object by name.
-            name: null,
-            // prop: show
-            // true to show (draw), false to not draw.
-            show: true,
-            // prop: lineWidth
-            // Width of the line.
-            lineWidth: 2,
-            // prop: lineCap
-            // Type of ending placed on the line ['round', 'butt', 'square']
-            lineCap: 'round',
-            // prop: color
-            // color of the line
-            color: '#666666',
-            // prop: shadow
-            // wether or not to draw a shadow on the line
-            shadow: true,
-            // prop: shadowAngle
-            // Shadow angle in degrees
-            shadowAngle: 45,
-            // prop: shadowOffset
-            // Shadow offset from line in pixels
-            shadowOffset: 1,
-            // prop: shadowDepth
-            // Number of times shadow is stroked, each stroke offset shadowOffset from the last.
-            shadowDepth: 3,
-            // prop: shadowAlpha
-            // Alpha channel transparency of shadow.  0 = transparent.
-            shadowAlpha: '0.07',
-            // prop: xaxis
-            // X axis to use for positioning/scaling the line.
-            xaxis: 'xaxis',
-            // prop: yaxis
-            // Y axis to use for positioning/scaling the line.
-            yaxis: 'yaxis',
-            // prop: showTooltip
-            // Show a tooltip with data point values.
-            showTooltip: false,
-            // prop: showTooltipPrecision
-            // Controls how close to line cursor must be to show tooltip.
-            // Higher number = closer to line, lower number = farther from line.
-            // 1.0 = cursor must be over line.
-            showTooltipPrecision: 0.6,
-            // prop: tooltipLocation
-            // Where to position tooltip, 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'
-            tooltipLocation: 'nw',
-            // prop: fadeTooltip
-            // true = fade in/out tooltip, flase = show/hide tooltip
-            fadeTooltip: true,
-            // prop: tooltipFadeSpeed
-            // 'slow', 'def', 'fast', or number of milliseconds.
-            tooltipFadeSpeed: "fast",
-            // prop: tooltipOffset
-            // Pixel offset of tooltip from the highlight.
-            tooltipOffset: 4,
-            // prop: tooltipFormatString
-            // Format string passed the x and y values of the cursor on the line.
-            // e.g., 'Dogs: %.2f, Cats: %d'.
-            tooltipFormatString: '%d, %d'
-        };
-    }
-
-    /**
-     * Class: Line
-     * A straight line.
-     */
-    function Line(options) {
-        LineBase.call(this);
-        this.type = 'line';
-        var opts = {
-            // prop: start
-            // [x, y] coordinates for the start of the line.
-            start: [],
-            // prop: stop
-            // [x, y] coordinates for the end of the line.
-            stop: []
-        };
-        $.extend(true, this.options, opts, options);
-
-        if (this.options.showTooltipPrecision < 0.01) {
-            this.options.showTooltipPrecision = 0.01;
-        }
-    }
-
-    Line.prototype = new LineBase();
-    Line.prototype.constructor = Line;
-
-
-    /**
-     * Class: HorizontalLine
-     * A straight horizontal line.
-     */
-    function HorizontalLine(options) {
-        LineBase.call(this);
-        this.type = 'horizontalLine';
-        var opts = {
-            // prop: y
-            // y value to position the line
-            y: null,
-            // prop: xmin
-            // x value for the start of the line, null to scale to axis min.
-            xmin: null,
-            // prop: xmax
-            // x value for the end of the line, null to scale to axis max.
-            xmax: null,
-            // prop xOffset
-            // offset ends of the line inside the grid.  Number 
-            xOffset: '6px', // number or string.  Number interpreted as units, string as pixels.
-            xminOffset: null,
-            xmaxOffset: null
-        };
-        $.extend(true, this.options, opts, options);
-
-        if (this.options.showTooltipPrecision < 0.01) {
-            this.options.showTooltipPrecision = 0.01;
-        }
-    }
-
-    HorizontalLine.prototype = new LineBase();
-    HorizontalLine.prototype.constructor = HorizontalLine;
-    
-
-    /**
-     * Class: DashedHorizontalLine
-     * A straight dashed horizontal line.
-     */
-    function DashedHorizontalLine(options) {
-        LineBase.call(this);
-        this.type = 'dashedHorizontalLine';
-        var opts = {
-            y: null,
-            xmin: null,
-            xmax: null,
-            xOffset: '6px', // number or string.  Number interpreted as units, string as pixels.
-            xminOffset: null,
-            xmaxOffset: null,
-            // prop: dashPattern
-            // Array of line, space settings in pixels.
-            // Default is 8 pixel of line, 8 pixel of space.
-            // Note, limit to a 2 element array b/c of bug with higher order arrays.
-            dashPattern: [8,8]
-        };
-        $.extend(true, this.options, opts, options);
-
-        if (this.options.showTooltipPrecision < 0.01) {
-            this.options.showTooltipPrecision = 0.01;
-        }
-    }
-
-    DashedHorizontalLine.prototype = new LineBase();
-    DashedHorizontalLine.prototype.constructor = DashedHorizontalLine;
-    
-
-    /**
-     * Class: VerticalLine
-     * A straight vertical line.
-     */
-    function VerticalLine(options) {
-        LineBase.call(this);
-        this.type = 'verticalLine';
-        var opts = {
-            x: null,
-            ymin: null,
-            ymax: null,
-            yOffset: '6px', // number or string.  Number interpreted as units, string as pixels.
-            yminOffset: null,
-            ymaxOffset: null
-        };
-        $.extend(true, this.options, opts, options);
-
-        if (this.options.showTooltipPrecision < 0.01) {
-            this.options.showTooltipPrecision = 0.01;
-        }
-    }
-
-    VerticalLine.prototype = new LineBase();
-    VerticalLine.prototype.constructor = VerticalLine;
-    
-
-    /**
-     * Class: DashedVerticalLine
-     * A straight dashed vertical line.
-     */
-    function DashedVerticalLine(options) {
-        LineBase.call(this);
-        this.type = 'dashedVerticalLine';
-        this.start = null;
-        this.stop = null;
-        var opts = {
-            x: null,
-            ymin: null,
-            ymax: null,
-            yOffset: '6px', // number or string.  Number interpreted as units, string as pixels.
-            yminOffset: null,
-            ymaxOffset: null,
-            // prop: dashPattern
-            // Array of line, space settings in pixels.
-            // Default is 8 pixel of line, 8 pixel of space.
-            // Note, limit to a 2 element array b/c of bug with higher order arrays.
-            dashPattern: [8,8]
-        };
-        $.extend(true, this.options, opts, options);
-
-        if (this.options.showTooltipPrecision < 0.01) {
-            this.options.showTooltipPrecision = 0.01;
-        }
-    }
-
-    DashedVerticalLine.prototype = new LineBase();
-    DashedVerticalLine.prototype.constructor = DashedVerticalLine;
-    
-    $.jqplot.CanvasOverlay.prototype.addLine = function(opts) {
-        var line = new Line(opts);
-        line.uid = objCounter++;
-        this.objects.push(line);
-        this.objectNames.push(line.options.name);
-    };
-    
-    $.jqplot.CanvasOverlay.prototype.addHorizontalLine = function(opts) {
-        var line = new HorizontalLine(opts);
-        line.uid = objCounter++;
-        this.objects.push(line);
-        this.objectNames.push(line.options.name);
-    };
-    
-    $.jqplot.CanvasOverlay.prototype.addDashedHorizontalLine = function(opts) {
-        var line = new DashedHorizontalLine(opts);
-        line.uid = objCounter++;
-        this.objects.push(line);
-        this.objectNames.push(line.options.name);
-    };
-    
-    $.jqplot.CanvasOverlay.prototype.addVerticalLine = function(opts) {
-        var line = new VerticalLine(opts);
-        line.uid = objCounter++;
-        this.objects.push(line);
-        this.objectNames.push(line.options.name);
-    };
-    
-    $.jqplot.CanvasOverlay.prototype.addDashedVerticalLine = function(opts) {
-        var line = new DashedVerticalLine(opts);
-        line.uid = objCounter++;
-        this.objects.push(line);
-        this.objectNames.push(line.options.name);
-    };
-    
-    $.jqplot.CanvasOverlay.prototype.removeObject = function(idx) {
-        // check if integer, remove by index
-        if ($.type(idx) == 'number') {
-            this.objects.splice(idx, 1);
-            this.objectNames.splice(idx, 1);
-        }
-        // if string, remove by name
-        else {
-            var id = $.inArray(idx, this.objectNames);
-            if (id != -1) {
-                this.objects.splice(id, 1);
-                this.objectNames.splice(id, 1);
-            }
-        }
-    };
-    
-    $.jqplot.CanvasOverlay.prototype.getObject = function(idx) {
-        // check if integer, remove by index
-        if ($.type(idx) == 'number') {
-            return this.objects[idx];
-        }
-        // if string, remove by name
-        else {
-            var id = $.inArray(idx, this.objectNames);
-            if (id != -1) {
-                return this.objects[id];
-            }
-        }
-    };
-    
-    // Set get as alias for getObject.
-    $.jqplot.CanvasOverlay.prototype.get = $.jqplot.CanvasOverlay.prototype.getObject;
-    
-    $.jqplot.CanvasOverlay.prototype.clear = function(plot) {
-        this.canvas._ctx.clearRect(0,0,this.canvas.getWidth(), this.canvas.getHeight());
-    };
-    
-    $.jqplot.CanvasOverlay.prototype.draw = function(plot) {
-        var obj, 
-            objs = this.objects,
-            mr = this.markerRenderer,
-            start,
-            stop;
-        if (this.options.show) {
-            this.canvas._ctx.clearRect(0,0,this.canvas.getWidth(), this.canvas.getHeight());
-            for (var k=0; k<objs.length; k++) {
-                obj = objs[k];
-                var opts = $.extend(true, {}, obj.options);
-                if (obj.options.show) {
-                    // style and shadow properties should be set before
-                    // every draw of marker renderer.
-                    mr.shadow = obj.options.shadow;
-                    obj.tooltipWidthFactor = obj.options.lineWidth / obj.options.showTooltipPrecision;
-                    switch (obj.type) {
-                        case 'line':
-                            // style and shadow properties should be set before
-                            // every draw of marker renderer.
-                            mr.style = 'line';
-                            opts.closePath = false;
-                            start = [plot.axes[obj.options.xaxis].series_u2p(obj.options.start[0]), plot.axes[obj.options.yaxis].series_u2p(obj.options.start[1])];
-                            stop = [plot.axes[obj.options.xaxis].series_u2p(obj.options.stop[0]), plot.axes[obj.options.yaxis].series_u2p(obj.options.stop[1])];
-                            obj.gridStart = start;
-                            obj.gridStop = stop;
-                            mr.draw(start, stop, this.canvas._ctx, opts);
-                            break;
-                        case 'horizontalLine':
-                            
-                            // style and shadow properties should be set before
-                            // every draw of marker renderer.
-                            if (obj.options.y != null) {
-                                mr.style = 'line';
-                                opts.closePath = false;
-                                var xaxis = plot.axes[obj.options.xaxis],
-                                    xstart,
-                                    xstop,
-                                    y = plot.axes[obj.options.yaxis].series_u2p(obj.options.y),
-                                    xminoff = obj.options.xminOffset || obj.options.xOffset,
-                                    xmaxoff = obj.options.xmaxOffset || obj.options.xOffset;
-                                if (obj.options.xmin != null) {
-                                    xstart = xaxis.series_u2p(obj.options.xmin);
-                                }
-                                else if (xminoff != null) {
-                                    if ($.type(xminoff) == "number") {
-                                        xstart = xaxis.series_u2p(xaxis.min + xminoff);
-                                    }
-                                    else if ($.type(xminoff) == "string") {
-                                        xstart = xaxis.series_u2p(xaxis.min) + parseFloat(xminoff);
-                                    }
-                                }
-                                if (obj.options.xmax != null) {
-                                    xstop = xaxis.series_u2p(obj.options.xmax);
-                                }
-                                else if (xmaxoff != null) {
-                                    if ($.type(xmaxoff) == "number") {
-                                        xstop = xaxis.series_u2p(xaxis.max - xmaxoff);
-                                    }
-                                    else if ($.type(xmaxoff) == "string") {
-                                        xstop = xaxis.series_u2p(xaxis.max) - parseFloat(xmaxoff);
-                                    }
-                                }
-                                if (xstop != null && xstart != null) {
-                                    obj.gridStart = [xstart, y];
-                                    obj.gridStop = [xstop, y];
-                                    mr.draw([xstart, y], [xstop, y], this.canvas._ctx, opts);
-                                }
-                            }
-                            break;
-
-                        case 'dashedHorizontalLine':
-                            
-                            var dashPat = obj.options.dashPattern;
-                            var dashPatLen = 0;
-                            for (var i=0; i<dashPat.length; i++) {
-                                dashPatLen += dashPat[i];
-                            }
-
-                            // style and shadow properties should be set before
-                            // every draw of marker renderer.
-                            if (obj.options.y != null) {
-                                mr.style = 'line';
-                                opts.closePath = false;
-                                var xaxis = plot.axes[obj.options.xaxis],
-                                    xstart,
-                                    xstop,
-                                    y = plot.axes[obj.options.yaxis].series_u2p(obj.options.y),
-                                    xminoff = obj.options.xminOffset || obj.options.xOffset,
-                                    xmaxoff = obj.options.xmaxOffset || obj.options.xOffset;
-                                if (obj.options.xmin != null) {
-                                    xstart = xaxis.series_u2p(obj.options.xmin);
-                                }
-                                else if (xminoff != null) {
-                                    if ($.type(xminoff) == "number") {
-                                        xstart = xaxis.series_u2p(xaxis.min + xminoff);
-                                    }
-                                    else if ($.type(xminoff) == "string") {
-                                        xstart = xaxis.series_u2p(xaxis.min) + parseFloat(xminoff);
-                                    }
-                                }
-                                if (obj.options.xmax != null) {
-                                    xstop = xaxis.series_u2p(obj.options.xmax);
-                                }
-                                else if (xmaxoff != null) {
-                                    if ($.type(xmaxoff) == "number") {
-                                        xstop = xaxis.series_u2p(xaxis.max - xmaxoff);
-                                    }
-                                    else if ($.type(xmaxoff) == "string") {
-                                        xstop = xaxis.series_u2p(xaxis.max) - parseFloat(xmaxoff);
-                                    }
-                                }
-                                if (xstop != null && xstart != null) {
-                                    obj.gridStart = [xstart, y];
-                                    obj.gridStop = [xstop, y];
-                                    var numDash = Math.ceil((xstop - xstart)/dashPatLen);
-                                    var b=xstart, e;
-                                    for (var i=0; i<numDash; i++) {
-                                        for (var j=0; j<dashPat.length; j+=2) {
-                                            e = b+dashPat[j];
-                                            mr.draw([b, y], [e, y], this.canvas._ctx, opts);
-                                            b += dashPat[j];
-                                            if (j < dashPat.length-1) {
-                                                b += dashPat[j+1];
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                            break;
-
-                        case 'verticalLine':
-                            
-                            // style and shadow properties should be set before
-                            // every draw of marker renderer.
-                            if (obj.options.x != null) {
-                                mr.style = 'line';
-                                opts.closePath = false;
-                                var yaxis = plot.axes[obj.options.yaxis],
-                                    ystart,
-                                    ystop,
-                                    x = plot.axes[obj.options.xaxis].series_u2p(obj.options.x),
-                                    yminoff = obj.options.yminOffset || obj.options.yOffset,
-                                    ymaxoff = obj.options.ymaxOffset || obj.options.yOffset;
-                                if (obj.options.ymin != null) {
-                                    ystart = yaxis.series_u2p(obj.options.ymin);
-                                }
-                                else if (yminoff != null) {
-                                    if ($.type(yminoff) == "number") {
-                                        ystart = yaxis.series_u2p(yaxis.min - yminoff);
-                                    }
-                                    else if ($.type(yminoff) == "string") {
-                                        ystart = yaxis.series_u2p(yaxis.min) - parseFloat(yminoff);
-                                    }
-                                }
-                                if (obj.options.ymax != null) {
-                                    ystop = yaxis.series_u2p(obj.options.ymax);
-                                }
-                                else if (ymaxoff != null) {
-                                    if ($.type(ymaxoff) == "number") {
-                                        ystop = yaxis.series_u2p(yaxis.max + ymaxoff);
-                                    }
-                                    else if ($.type(ymaxoff) == "string") {
-                                        ystop = yaxis.series_u2p(yaxis.max) + parseFloat(ymaxoff);
-                                    }
-                                }
-                                if (ystop != null && ystart != null) {
-                                    obj.gridStart = [x, ystart];
-                                    obj.gridStop = [x, ystop];
-                                    mr.draw([x, ystart], [x, ystop], this.canvas._ctx, opts);
-                                }
-                            }
-                            break;
-
-                        case 'dashedVerticalLine':
-                            
-                            var dashPat = obj.options.dashPattern;
-                            var dashPatLen = 0;
-                            for (var i=0; i<dashPat.length; i++) {
-                                dashPatLen += dashPat[i];
-                            }
-
-                            // style and shadow properties should be set before
-                            // every draw of marker renderer.
-                            if (obj.options.x != null) {
-                                mr.style = 'line';
-                                opts.closePath = false;
-                                var yaxis = plot.axes[obj.options.yaxis],
-                                    ystart,
-                                    ystop,
-                                    x = plot.axes[obj.options.xaxis].series_u2p(obj.options.x),
-                                    yminoff = obj.options.yminOffset || obj.options.yOffset,
-                                    ymaxoff = obj.options.ymaxOffset || obj.options.yOffset;
-                                if (obj.options.ymin != null) {
-                                    ystart = yaxis.series_u2p(obj.options.ymin);
-                                }
-                                else if (yminoff != null) {
-                                    if ($.type(yminoff) == "number") {
-                                        ystart = yaxis.series_u2p(yaxis.min - yminoff);
-                                    }
-                                    else if ($.type(yminoff) == "string") {
-                                        ystart = yaxis.series_u2p(yaxis.min) - parseFloat(yminoff);
-                                    }
-                                }
-                                if (obj.options.ymax != null) {
-                                    ystop = yaxis.series_u2p(obj.options.ymax);
-                                }
-                                else if (ymaxoff != null) {
-                                    if ($.type(ymaxoff) == "number") {
-                                        ystop = yaxis.series_u2p(yaxis.max + ymaxoff);
-                                    }
-                                    else if ($.type(ymaxoff) == "string") {
-                                        ystop = yaxis.series_u2p(yaxis.max) + parseFloat(ymaxoff);
-                                    }
-                                }
-
-
-                                if (ystop != null && ystart != null) {
-                                    obj.gridStart = [x, ystart];
-                                    obj.gridStop = [x, ystop];
-                                    var numDash = Math.ceil((ystart - ystop)/dashPatLen);
-                                    var firstDashAdjust = ((numDash * dashPatLen) - (ystart - ystop))/2.0;
-                                    var b=ystart, e, bs, es;
-                                    for (var i=0; i<numDash; i++) {
-                                        for (var j=0; j<dashPat.length; j+=2) {
-                                            e = b - dashPat[j];
-                                            if (e < ystop) {
-                                                e = ystop;
-                                            }
-                                            if (b < ystop) {
-                                                b = ystop;
-                                            }
-                                            // es = e;
-                                            // if (i == 0) {
-                                            //  es += firstDashAdjust;
-                                            // }
-                                            mr.draw([x, b], [x, e], this.canvas._ctx, opts);
-                                            b -= dashPat[j];
-                                            if (j < dashPat.length-1) {
-                                                b -= dashPat[j+1];
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                            break;
-
-                        default:
-                            break;
-                    }
-                }
-            }
-        }
-    };
-    
-    // called within context of plot
-    // create a canvas which we can draw on.
-    // insert it before the eventCanvas, so eventCanvas will still capture events.
-    $.jqplot.CanvasOverlay.postPlotDraw = function() {
-        var co = this.plugins.canvasOverlay;
-        // Memory Leaks patch    
-        if (co && co.highlightCanvas) {
-            co.highlightCanvas.resetCanvas();
-            co.highlightCanvas = null;
-        }
-        co.canvas = new $.jqplot.GenericCanvas();
-        
-        this.eventCanvas._elem.before(co.canvas.createElement(this._gridPadding, 'jqplot-overlayCanvas-canvas', this._plotDimensions, this));
-        co.canvas.setContext();
-        if (!co.deferDraw) {
-            co.draw(this);
-        }
-
-        var elem = document.createElement('div');
-        co._tooltipElem = $(elem);
-        elem = null;
-        co._tooltipElem.addClass('jqplot-canvasOverlay-tooltip');
-        co._tooltipElem.css({position:'absolute', display:'none'});
-        
-        this.eventCanvas._elem.before(co._tooltipElem);
-        this.eventCanvas._elem.bind('mouseleave', { elem: co._tooltipElem }, function (ev) { ev.data.elem.hide(); });
-
-        var co = null;
-    };
-
-
-    function showTooltip(plot, obj, gridpos, datapos) {
-        var co = plot.plugins.canvasOverlay;
-        var elem = co._tooltipElem;
-
-        var opts = obj.options, x, y;
-
-        elem.html($.jqplot.sprintf(opts.tooltipFormatString, datapos[0], datapos[1]));
-        
-        switch (opts.tooltipLocation) {
-            case 'nw':
-                x = gridpos[0] + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset;
-                y = gridpos[1] + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true);
-                break;
-            case 'n':
-                x = gridpos[0] + plot._gridPadding.left - elem.outerWidth(true)/2;
-                y = gridpos[1] + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true);
-                break;
-            case 'ne':
-                x = gridpos[0] + plot._gridPadding.left + opts.tooltipOffset;
-                y = gridpos[1] + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true);
-                break;
-            case 'e':
-                x = gridpos[0] + plot._gridPadding.left + opts.tooltipOffset;
-                y = gridpos[1] + plot._gridPadding.top - elem.outerHeight(true)/2;
-                break;
-            case 'se':
-                x = gridpos[0] + plot._gridPadding.left + opts.tooltipOffset;
-                y = gridpos[1] + plot._gridPadding.top + opts.tooltipOffset;
-                break;
-            case 's':
-                x = gridpos[0] + plot._gridPadding.left - elem.outerWidth(true)/2;
-                y = gridpos[1] + plot._gridPadding.top + opts.tooltipOffset;
-                break;
-            case 'sw':
-                x = gridpos[0] + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset;
-                y = gridpos[1] + plot._gridPadding.top + opts.tooltipOffset;
-                break;
-            case 'w':
-                x = gridpos[0] + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset;
-                y = gridpos[1] + plot._gridPadding.top - elem.outerHeight(true)/2;
-                break;
-            default: // same as 'nw'
-                x = gridpos[0] + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset;
-                y = gridpos[1] + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true);
-                break;
-        }
-
-        elem.css('left', x);
-        elem.css('top', y);
-        if (opts.fadeTooltip) {
-            // Fix for stacked up animations.  Thnanks Trevor!
-            elem.stop(true,true).fadeIn(opts.tooltipFadeSpeed);
-        }
-        else {
-            elem.show();
-        }
-        elem = null;
-    }
-
-
-    function isNearLine(point, lstart, lstop, width) {
-        // r is point to test, p and q are end points.
-        var rx = point[0];
-        var ry = point[1];
-        var px = Math.round(lstop[0]);
-        var py = Math.round(lstop[1]);
-        var qx = Math.round(lstart[0]);
-        var qy = Math.round(lstart[1]);
-
-        var l = Math.sqrt(Math.pow(px-qx, 2) + Math.pow(py-qy, 2));
-
-        // scale error term by length of line.
-        var eps = width*l;
-        var res = Math.abs((qx-px) * (ry-py) - (qy-py) * (rx-px));
-        var ret = (res < eps) ? true : false;
-        return ret;
-    }
-
-
-    function handleMove(ev, gridpos, datapos, neighbor, plot) {
-        var co = plot.plugins.canvasOverlay;
-        var objs = co.objects;
-        var l = objs.length;
-        var obj, haveHighlight=false;
-        var elem;
-        for (var i=0; i<l; i++) {
-            obj = objs[i];
-            if (obj.options.showTooltip) {
-                var n = isNearLine([gridpos.x, gridpos.y], obj.gridStart, obj.gridStop, obj.tooltipWidthFactor);
-                datapos = [plot.axes[obj.options.xaxis].series_p2u(gridpos.x), plot.axes[obj.options.yaxis].series_p2u(gridpos.y)];
-
-                // cases:
-                //    near line, no highlighting
-                //    near line, highliting on this line
-                //    near line, highlighting another line
-                //    not near any line, highlighting
-                //    not near any line, no highlighting
-
-                // near line, not currently highlighting
-                if (n && co.highlightObjectIndex == null) {
-                    switch (obj.type) {
-                        case 'line':
-                            showTooltip(plot, obj, [gridpos.x, gridpos.y], datapos);
-                            break;
-
-                        case 'horizontalLine':
-                        case 'dashedHorizontalLine':
-                            showTooltip(plot, obj, [gridpos.x, obj.gridStart[1]], [datapos[0], obj.options.y]);
-                            break;
-
-                        case 'verticalLine':
-                        case 'dashedVerticalLine':
-                            showTooltip(plot, obj, [obj.gridStart[0], gridpos.y], [obj.options.x, datapos[1]]);
-                            break;
-                        default:
-                            break;
-                    } 
-                    co.highlightObjectIndex = i;
-                    haveHighlight = true;
-                    break;
-                }
-
-                // near line, highlighting another line.
-                else if (n && co.highlightObjectIndex !== i) {
-                    // turn off tooltip.
-                    elem = co._tooltipElem;
-                    if (obj.fadeTooltip) {
-                        elem.fadeOut(obj.tooltipFadeSpeed);
-                    }
-                    else {
-                        elem.hide();
-                    }
-
-                    // turn on right tooltip.
-                    switch (obj.type) {
-                        case 'line':
-                            showTooltip(plot, obj, [gridpos.x, gridpos.y], datapos);
-                            break;
-
-                        case 'horizontalLine':
-                        case 'dashedHorizontalLine':
-                            showTooltip(plot, obj, [gridpos.x, obj.gridStart[1]], [datapos[0], obj.options.y]);
-                            break;
-
-                        case 'verticalLine':
-                        case 'dashedVerticalLine':
-                            showTooltip(plot, obj, [obj.gridStart[0], gridpos.y], [obj.options.x, datapos[1]]);
-                            break;
-                        default:
-                            break;
-                    }
-
-                    co.highlightObjectIndex = i;
-                    haveHighlight = true;
-                    break;
-                }
-
-                // near line, already highlighting this line, update
-                else if (n) {
-                    switch (obj.type) {
-                        case 'line':
-                            showTooltip(plot, obj, [gridpos.x, gridpos.y], datapos);
-                            break;
-
-                        case 'horizontalLine':
-                        case 'dashedHorizontalLine':
-                            showTooltip(plot, obj, [gridpos.x, obj.gridStart[1]], [datapos[0], obj.options.y]);
-                            break;
-
-                        case 'verticalLine':
-                        case 'dashedVerticalLine':
-                            showTooltip(plot, obj, [obj.gridStart[0], gridpos.y], [obj.options.x, datapos[1]]);
-                            break;
-                        default:
-                            break;
-                    }
-
-                    haveHighlight = true;
-                    break;
-                }
-            }
-        }
-
-        // check if we are highlighting and not near a line, turn it off.
-        if (!haveHighlight && co.highlightObjectIndex !== null) {
-            elem = co._tooltipElem;
-            obj = co.getObject(co.highlightObjectIndex);
-            if (obj.fadeTooltip) {
-                elem.fadeOut(obj.tooltipFadeSpeed);
-            }
-            else {
-                elem.hide();
-            }
-            co.highlightObjectIndex = null;
-        }
-    }
-    
-    $.jqplot.postInitHooks.push($.jqplot.CanvasOverlay.postPlotInit);
-    $.jqplot.postDrawHooks.push($.jqplot.CanvasOverlay.postPlotDraw);
-    $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMove]);
-
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasOverlay.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasOverlay.min.js
deleted file mode 100644
index 0aef8c5..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasOverlay.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(d){var f=0;d.jqplot.CanvasOverlay=function(o){var l=o||{};this.options={show:d.jqplot.config.enablePlugins,deferDraw:false};this.objects=[];this.objectNames=[];this.canvas=null;this.markerRenderer=new d.jqplot.MarkerRenderer({style:"line"});this.markerRenderer.init();this.highlightObjectIndex=null;if(l.objects){var q=l.objects,p;for(var m=0;m<q.length;m++){p=q[m];for(var r in p){switch(r){case"line":this.addLine(p[r]);break;case"horizontalLine":this.addHorizontalLine(p[r]);break;case"dashedHorizontalLine":this.addDashedHorizontalLine(p[r]);break;case"verticalLine":this.addVerticalLine(p[r]);break;case"dashedVerticalLine":this.addDashedVerticalLine(p[r]);break;default:break}}}}d.extend(true,this.options,l)};d.jqplot.CanvasOverlay.postPlotInit=function(o,n,m){var l=m||{};this.plugins.canvasOverlay=new d.jqplot.CanvasOverlay(l.canvasOverlay)};function h(){this.uid=null;this.type=null;this.gridStart=null;this.gridStop=null;this.tooltipWidthFactor=0;this.options={name:null,show:true,lineWidth:2,lineCap:"round",color:"#666666",shadow:true,shadowAngle:45,shadowOffset:1,shadowDepth:3,shadowAlpha:"0.07",xaxis:"xaxis",yaxis:"yaxis",showTooltip:false,showTooltipPrecision:0.6,tooltipLocation:"nw",fadeTooltip:true,tooltipFadeSpeed:"fast",tooltipOffset:4,tooltipFormatString:"%d, %d"}}function b(l){h.call(this);this.type="line";var m={start:[],stop:[]};d.extend(true,this.options,m,l);if(this.options.showTooltipPrecision<0.01){this.options.showTooltipPrecision=0.01}}b.prototype=new h();b.prototype.constructor=b;function e(l){h.call(this);this.type="horizontalLine";var m={y:null,xmin:null,xmax:null,xOffset:"6px",xminOffset:null,xmaxOffset:null};d.extend(true,this.options,m,l);if(this.options.showTooltipPrecision<0.01){this.options.showTooltipPrecision=0.01}}e.prototype=new h();e.prototype.constructor=e;function i(l){h.call(this);this.type="dashedHorizontalLine";var m={y:null,xmin:null,xmax:null,xOffset:"6px",xminOffset:null,xmaxOffset:null,dashPattern:[8,8]};d.extend(true,this.options,m,l);if(this.options.showTooltipPrecision<0.01){this.options.showTooltipPrecision=0.01}}i.prototype=new h();i.prototype.constructor=i;function c(l){h.call(this);this.type="verticalLine";var m={x:null,ymin:null,ymax:null,yOffset:"6px",yminOffset:null,ymaxOffset:null};d.extend(true,this.options,m,l);if(this.options.showTooltipPrecision<0.01){this.options.showTooltipPrecision=0.01}}c.prototype=new h();c.prototype.constructor=c;function k(l){h.call(this);this.type="dashedVerticalLine";this.start=null;this.stop=null;var m={x:null,ymin:null,ymax:null,yOffset:"6px",yminOffset:null,ymaxOffset:null,dashPattern:[8,8]};d.extend(true,this.options,m,l);if(this.options.showTooltipPrecision<0.01){this.options.showTooltipPrecision=0.01}}k.prototype=new h();k.prototype.constructor=k;d.jqplot.CanvasOverlay.prototype.addLine=function(m){var l=new b(m);l.uid=f++;this.objects.push(l);this.objectNames.push(l.options.name)};d.jqplot.CanvasOverlay.prototype.addHorizontalLine=function(m){var l=new e(m);l.uid=f++;this.objects.push(l);this.objectNames.push(l.options.name)};d.jqplot.CanvasOverlay.prototype.addDashedHorizontalLine=function(m){var l=new i(m);l.uid=f++;this.objects.push(l);this.objectNames.push(l.options.name)};d.jqplot.CanvasOverlay.prototype.addVerticalLine=function(m){var l=new c(m);l.uid=f++;this.objects.push(l);this.objectNames.push(l.options.name)};d.jqplot.CanvasOverlay.prototype.addDashedVerticalLine=function(m){var l=new k(m);l.uid=f++;this.objects.push(l);this.objectNames.push(l.options.name)};d.jqplot.CanvasOverlay.prototype.removeObject=function(l){if(d.type(l)=="number"){this.objects.splice(l,1);this.objectNames.splice(l,1)}else{var m=d.inArray(l,this.objectNames);if(m!=-1){this.objects.splice(m,1);this.objectNames.splice(m,1)}}};d.jqplot.CanvasOverlay.prototype.getObject=function(l){if(d.type(l)=="number"){return this.objects[l]}else{var m=d.inArray(l,this.objectNames);if(m!=-1){return this.objects[m]}}};d.jqplot.CanvasOverlay.prototype.get=d.jqplot.CanvasOverlay.prototype.getObject;d.jqplot.CanvasOverlay.prototype.clear=function(l){this.canvas._ctx.clearRect(0,0,this.canvas.getWidth(),this.canvas.getHeight())};d.jqplot.CanvasOverlay.prototype.draw=function(I){var w,t=this.objects,D=this.markerRenderer,q,E;if(this.options.show){this.canvas._ctx.clearRect(0,0,this.canvas.getWidth(),this.canvas.getHeight());for(var F=0;F<t.length;F++){w=t[F];var z=d.extend(true,{},w.options);if(w.options.show){D.shadow=w.options.shadow;w.tooltipWidthFactor=w.options.lineWidth/w.options.showTooltipPrecision;switch(w.type){case"line":D.style="line";z.closePath=false;q=[I.axes[w.options.xaxis].series_u2p(w.options.start[0]),I.axes[w.options.yaxis].series_u2p(w.options.start[1])];E=[I.axes[w.options.xaxis].series_u2p(w.options.stop[0]),I.axes[w.options.yaxis].series_u2p(w.options.stop[1])];w.gridStart=q;w.gridStop=E;D.draw(q,E,this.canvas._ctx,z);break;case"horizontalLine":if(w.options.y!=null){D.style="line";z.closePath=false;var n=I.axes[w.options.xaxis],Q,J,u=I.axes[w.options.yaxis].series_u2p(w.options.y),G=w.options.xminOffset||w.options.xOffset,r=w.options.xmaxOffset||w.options.xOffset;if(w.options.xmin!=null){Q=n.series_u2p(w.options.xmin)}else{if(G!=null){if(d.type(G)=="number"){Q=n.series_u2p(n.min+G)}else{if(d.type(G)=="string"){Q=n.series_u2p(n.min)+parseFloat(G)}}}}if(w.options.xmax!=null){J=n.series_u2p(w.options.xmax)}else{if(r!=null){if(d.type(r)=="number"){J=n.series_u2p(n.max-r)}else{if(d.type(r)=="string"){J=n.series_u2p(n.max)-parseFloat(r)}}}}if(J!=null&&Q!=null){w.gridStart=[Q,u];w.gridStop=[J,u];D.draw([Q,u],[J,u],this.canvas._ctx,z)}}break;case"dashedHorizontalLine":var m=w.options.dashPattern;var C=0;for(var K=0;K<m.length;K++){C+=m[K]}if(w.options.y!=null){D.style="line";z.closePath=false;var n=I.axes[w.options.xaxis],Q,J,u=I.axes[w.options.yaxis].series_u2p(w.options.y),G=w.options.xminOffset||w.options.xOffset,r=w.options.xmaxOffset||w.options.xOffset;if(w.options.xmin!=null){Q=n.series_u2p(w.options.xmin)}else{if(G!=null){if(d.type(G)=="number"){Q=n.series_u2p(n.min+G)}else{if(d.type(G)=="string"){Q=n.series_u2p(n.min)+parseFloat(G)}}}}if(w.options.xmax!=null){J=n.series_u2p(w.options.xmax)}else{if(r!=null){if(d.type(r)=="number"){J=n.series_u2p(n.max-r)}else{if(d.type(r)=="string"){J=n.series_u2p(n.max)-parseFloat(r)}}}}if(J!=null&&Q!=null){w.gridStart=[Q,u];w.gridStop=[J,u];var p=Math.ceil((J-Q)/C);var O=Q,M;for(var K=0;K<p;K++){for(var H=0;H<m.length;H+=2){M=O+m[H];D.draw([O,u],[M,u],this.canvas._ctx,z);O+=m[H];if(H<m.length-1){O+=m[H+1]}}}}}break;case"verticalLine":if(w.options.x!=null){D.style="line";z.closePath=false;var L=I.axes[w.options.yaxis],l,s,v=I.axes[w.options.xaxis].series_u2p(w.options.x),B=w.options.yminOffset||w.options.yOffset,o=w.options.ymaxOffset||w.options.yOffset;if(w.options.ymin!=null){l=L.series_u2p(w.options.ymin)}else{if(B!=null){if(d.type(B)=="number"){l=L.series_u2p(L.min-B)}else{if(d.type(B)=="string"){l=L.series_u2p(L.min)-parseFloat(B)}}}}if(w.options.ymax!=null){s=L.series_u2p(w.options.ymax)}else{if(o!=null){if(d.type(o)=="number"){s=L.series_u2p(L.max+o)}else{if(d.type(o)=="string"){s=L.series_u2p(L.max)+parseFloat(o)}}}}if(s!=null&&l!=null){w.gridStart=[v,l];w.gridStop=[v,s];D.draw([v,l],[v,s],this.canvas._ctx,z)}}break;case"dashedVerticalLine":var m=w.options.dashPattern;var C=0;for(var K=0;K<m.length;K++){C+=m[K]}if(w.options.x!=null){D.style="line";z.closePath=false;var L=I.axes[w.options.yaxis],l,s,v=I.axes[w.options.xaxis].series_u2p(w.options.x),B=w.options.yminOffset||w.options.yOffset,o=w.options.ymaxOffset||w.options.yOffset;if(w.options.ymin!=null){l=L.series_u2p(w.options.ymin)}else{if(B!=null){if(d.type(B)=="number"){l=L.series_u2p(L.min-B)}else{if(d.type(B)=="string"){l=L.series_u2p(L.min)-parseFloat(B)}}}}if(w.options.ymax!=null){s=L.series_u2p(w.options.ymax)}else{if(o!=null){if(d.type(o)=="number"){s=L.series_u2p(L.max+o)}else{if(d.type(o)=="string"){s=L.series_u2p(L.max)+parseFloat(o)}}}}if(s!=null&&l!=null){w.gridStart=[v,l];w.gridStop=[v,s];var p=Math.ceil((l-s)/C);var A=((p*C)-(l-s))/2;var O=l,M,N,P;for(var K=0;K<p;K++){for(var H=0;H<m.length;H+=2){M=O-m[H];if(M<s){M=s}if(O<s){O=s}D.draw([v,O],[v,M],this.canvas._ctx,z);O-=m[H];if(H<m.length-1){O-=m[H+1]}}}}}break;default:break}}}}};d.jqplot.CanvasOverlay.postPlotDraw=function(){var m=this.plugins.canvasOverlay;if(m&&m.highlightCanvas){m.highlightCanvas.resetCanvas();m.highlightCanvas=null}m.canvas=new d.jqplot.GenericCanvas();this.eventCanvas._elem.before(m.canvas.createElement(this._gridPadding,"jqplot-overlayCanvas-canvas",this._plotDimensions,this));m.canvas.setContext();if(!m.deferDraw){m.draw(this)}var l=document.createElement("div");m._tooltipElem=d(l);l=null;m._tooltipElem.addClass("jqplot-canvasOverlay-tooltip");m._tooltipElem.css({position:"absolute",display:"none"});this.eventCanvas._elem.before(m._tooltipElem);this.eventCanvas._elem.bind("mouseleave",{elem:m._tooltipElem},function(n){n.data.elem.hide()});var m=null};function j(q,o,p,n){var s=q.plugins.canvasOverlay;var m=s._tooltipElem;var l=o.options,t,r;m.html(d.jqplot.sprintf(l.tooltipFormatString,n[0],n[1]));switch(l.tooltipLocation){case"nw":t=p[0]+q._gridPadding.left-m.outerWidth(true)-l.tooltipOffset;r=p[1]+q._gridPadding.top-l.tooltipOffset-m.outerHeight(true);break;case"n":t=p[0]+q._gridPadding.left-m.outerWidth(true)/2;r=p[1]+q._gridPadding.top-l.tooltipOffset-m.outerHeight(true);break;case"ne":t=p[0]+q._gridPadding.left+l.tooltipOffset;r=p[1]+q._gridPadding.top-l.tooltipOffset-m.outerHeight(true);break;case"e":t=p[0]+q._gridPadding.left+l.tooltipOffset;r=p[1]+q._gridPadding.top-m.outerHeight(true)/2;break;case"se":t=p[0]+q._gridPadding.left+l.tooltipOffset;r=p[1]+q._gridPadding.top+l.tooltipOffset;break;case"s":t=p[0]+q._gridPadding.left-m.outerWidth(true)/2;r=p[1]+q._gridPadding.top+l.tooltipOffset;break;case"sw":t=p[0]+q._gridPadding.left-m.outerWidth(true)-l.tooltipOffset;r=p[1]+q._gridPadding.top+l.tooltipOffset;break;case"w":t=p[0]+q._gridPadding.left-m.outerWidth(true)-l.tooltipOffset;r=p[1]+q._gridPadding.top-m.outerHeight(true)/2;break;default:t=p[0]+q._gridPadding.left-m.outerWidth(true)-l.tooltipOffset;r=p[1]+q._gridPadding.top-l.tooltipOffset-m.outerHeight(true);break}m.css("left",t);m.css("top",r);if(l.fadeTooltip){m.stop(true,true).fadeIn(l.tooltipFadeSpeed)}else{m.show()}m=null}function g(y,p,r,o){var n=y[0];var m=y[1];var x=Math.round(r[0]);var w=Math.round(r[1]);var t=Math.round(p[0]);var s=Math.round(p[1]);var q=Math.sqrt(Math.pow(x-t,2)+Math.pow(w-s,2));var z=o*q;var v=Math.abs((t-x)*(m-w)-(s-w)*(n-x));var u=(v<z)?true:false;return u}function a(y,v,q,z,w){var x=w.plugins.canvasOverlay;var u=x.objects;var r=u.length;var t,m=false;var p;for(var s=0;s<r;s++){t=u[s];if(t.options.showTooltip){var o=g([v.x,v.y],t.gridStart,t.gridStop,t.tooltipWidthFactor);q=[w.axes[t.options.xaxis].series_p2u(v.x),w.axes[t.options.yaxis].series_p2u(v.y)];if(o&&x.highlightObjectIndex==null){switch(t.type){case"line":j(w,t,[v.x,v.y],q);break;case"horizontalLine":case"dashedHorizontalLine":j(w,t,[v.x,t.gridStart[1]],[q[0],t.options.y]);break;case"verticalLine":case"dashedVerticalLine":j(w,t,[t.gridStart[0],v.y],[t.options.x,q[1]]);break;default:break}x.highlightObjectIndex=s;m=true;break}else{if(o&&x.highlightObjectIndex!==s){p=x._tooltipElem;if(t.fadeTooltip){p.fadeOut(t.tooltipFadeSpeed)}else{p.hide()}switch(t.type){case"line":j(w,t,[v.x,v.y],q);break;case"horizontalLine":case"dashedHorizontalLine":j(w,t,[v.x,t.gridStart[1]],[q[0],t.options.y]);break;case"verticalLine":case"dashedVerticalLine":j(w,t,[t.gridStart[0],v.y],[t.options.x,q[1]]);break;default:break}x.highlightObjectIndex=s;m=true;break}else{if(o){switch(t.type){case"line":j(w,t,[v.x,v.y],q);break;case"horizontalLine":case"dashedHorizontalLine":j(w,t,[v.x,t.gridStart[1]],[q[0],t.options.y]);break;case"verticalLine":case"dashedVerticalLine":j(w,t,[t.gridStart[0],v.y],[t.options.x,q[1]]);break;default:break}m=true;break}}}}}if(!m&&x.highlightObjectIndex!==null){p=x._tooltipElem;t=x.getObject(x.highlightObjectIndex);if(t.fadeTooltip){p.fadeOut(t.tooltipFadeSpeed)}else{p.hide()}x.highlightObjectIndex=null}}d.jqplot.postInitHooks.push(d.jqplot.CanvasOverlay.postPlotInit);d.jqplot.postDrawHooks.push(d.jqplot.CanvasOverlay.postPlotDraw);d.jqplot.eventListenerHooks.push(["jqplotMouseMove",a])})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasTextRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasTextRenderer.js
deleted file mode 100644
index 556795a..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasTextRenderer.js
+++ /dev/null
@@ -1,448 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-
-(function($) {    
-    // This code is a modified version of the canvastext.js code, copyright below:
-    //
-    // This code is released to the public domain by Jim Studt, 2007.
-    // He may keep some sort of up to date copy at http://www.federated.com/~jim/canvastext/
-    //
-    $.jqplot.CanvasTextRenderer = function(options){
-        this.fontStyle = 'normal';  // normal, italic, oblique [not implemented]
-        this.fontVariant = 'normal';    // normal, small caps [not implemented]
-        this.fontWeight = 'normal'; // normal, bold, bolder, lighter, 100 - 900
-        this.fontSize = '10px'; 
-        this.fontFamily = 'sans-serif';
-        this.fontStretch = 1.0;
-        this.fillStyle = '#666666';
-        this.angle = 0;
-        this.textAlign = 'start';
-        this.textBaseline = 'alphabetic';
-        this.text;
-        this.width;
-        this.height;
-        this.pt2px = 1.28;
-
-        $.extend(true, this, options);
-        this.normalizedFontSize = this.normalizeFontSize(this.fontSize);
-        this.setHeight();
-    };
-    
-    $.jqplot.CanvasTextRenderer.prototype.init = function(options) {
-        $.extend(true, this, options);
-        this.normalizedFontSize = this.normalizeFontSize(this.fontSize);
-        this.setHeight();
-    };
-    
-    // convert css spec into point size
-    // returns float
-    $.jqplot.CanvasTextRenderer.prototype.normalizeFontSize = function(sz) {
-        sz = String(sz);
-        var n = parseFloat(sz);
-        if (sz.indexOf('px') > -1) {
-            return n/this.pt2px;
-        }
-        else if (sz.indexOf('pt') > -1) {
-            return n;
-        }
-        else if (sz.indexOf('em') > -1) {
-            return n*12;
-        }
-        else if (sz.indexOf('%') > -1) {
-            return n*12/100;
-        }
-        // default to pixels;
-        else {
-            return n/this.pt2px;
-        }
-    };
-    
-    
-    $.jqplot.CanvasTextRenderer.prototype.fontWeight2Float = function(w) {
-        // w = normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
-        // return values adjusted for Hershey font.
-        if (Number(w)) {
-            return w/400;
-        }
-        else {
-            switch (w) {
-                case 'normal':
-                    return 1;
-                    break;
-                case 'bold':
-                    return 1.75;
-                    break;
-                case 'bolder':
-                    return 2.25;
-                    break;
-                case 'lighter':
-                    return 0.75;
-                    break;
-                default:
-                    return 1;
-                    break;
-             }   
-        }
-    };
-    
-    $.jqplot.CanvasTextRenderer.prototype.getText = function() {
-        return this.text;
-    };
-    
-    $.jqplot.CanvasTextRenderer.prototype.setText = function(t, ctx) {
-        this.text = t;
-        this.setWidth(ctx);
-        return this;
-    };
-    
-    $.jqplot.CanvasTextRenderer.prototype.getWidth = function(ctx) {
-        return this.width;
-    };
-    
-    $.jqplot.CanvasTextRenderer.prototype.setWidth = function(ctx, w) {
-        if (!w) {
-            this.width = this.measure(ctx, this.text);
-        }
-        else {
-            this.width = w;   
-        }
-        return this;
-    };
-    
-    // return height in pixels.
-    $.jqplot.CanvasTextRenderer.prototype.getHeight = function(ctx) {
-        return this.height;
-    };
-    
-    // w - height in pt
-    // set heigh in px
-    $.jqplot.CanvasTextRenderer.prototype.setHeight = function(w) {
-        if (!w) {
-            //height = this.fontSize /0.75;
-            this.height = this.normalizedFontSize * this.pt2px;
-        }
-        else {
-            this.height = w;   
-        }
-        return this;
-    };
-
-    $.jqplot.CanvasTextRenderer.prototype.letter = function (ch)
-    {
-        return this.letters[ch];
-    };
-
-    $.jqplot.CanvasTextRenderer.prototype.ascent = function()
-    {
-        return this.normalizedFontSize;
-    };
-
-    $.jqplot.CanvasTextRenderer.prototype.descent = function()
-    {
-        return 7.0*this.normalizedFontSize/25.0;
-    };
-
-    $.jqplot.CanvasTextRenderer.prototype.measure = function(ctx, str)
-    {
-        var total = 0;
-        var len = str.length;
- 
-        for (var i = 0; i < len; i++) {
-            var c = this.letter(str.charAt(i));
-            if (c) {
-                total += c.width * this.normalizedFontSize / 25.0 * this.fontStretch;
-            }
-        }
-        return total;
-    };
-
-    $.jqplot.CanvasTextRenderer.prototype.draw = function(ctx,str)
-    {
-        var x = 0;
-        // leave room at bottom for descenders.
-        var y = this.height*0.72;
-         var total = 0;
-         var len = str.length;
-         var mag = this.normalizedFontSize / 25.0;
-
-         ctx.save();
-         var tx, ty;
-         
-         // 1st quadrant
-         if ((-Math.PI/2 <= this.angle && this.angle <= 0) || (Math.PI*3/2 <= this.angle && this.angle <= Math.PI*2)) {
-             tx = 0;
-             ty = -Math.sin(this.angle) * this.width;
-         }
-         // 4th quadrant
-         else if ((0 < this.angle && this.angle <= Math.PI/2) || (-Math.PI*2 <= this.angle && this.angle <= -Math.PI*3/2)) {
-             tx = Math.sin(this.angle) * this.height;
-             ty = 0;
-         }
-         // 2nd quadrant
-         else if ((-Math.PI < this.angle && this.angle < -Math.PI/2) || (Math.PI <= this.angle && this.angle <= Math.PI*3/2)) {
-             tx = -Math.cos(this.angle) * this.width;
-             ty = -Math.sin(this.angle) * this.width - Math.cos(this.angle) * this.height;
-         }
-         // 3rd quadrant
-         else if ((-Math.PI*3/2 < this.angle && this.angle < Math.PI) || (Math.PI/2 < this.angle && this.angle < Math.PI)) {
-             tx = Math.sin(this.angle) * this.height - Math.cos(this.angle)*this.width;
-             ty = -Math.cos(this.angle) * this.height;
-         }
-         
-         ctx.strokeStyle = this.fillStyle;
-         ctx.fillStyle = this.fillStyle;
-         ctx.translate(tx, ty);
-         ctx.rotate(this.angle);
-         ctx.lineCap = "round";
-         // multiplier was 2.0
-         var fact = (this.normalizedFontSize > 30) ? 2.0 : 2 + (30 - this.normalizedFontSize)/20;
-         ctx.lineWidth = fact * mag * this.fontWeight2Float(this.fontWeight);
-         
-         for ( var i = 0; i < len; i++) {
-            var c = this.letter( str.charAt(i));
-            if ( !c) {
-                continue;
-            }
-
-            ctx.beginPath();
-
-            var penUp = 1;
-            var needStroke = 0;
-            for ( var j = 0; j < c.points.length; j++) {
-              var a = c.points[j];
-              if ( a[0] == -1 && a[1] == -1) {
-                  penUp = 1;
-                  continue;
-              }
-              if ( penUp) {
-                  ctx.moveTo( x + a[0]*mag*this.fontStretch, y - a[1]*mag);
-                  penUp = false;
-              } else {
-                  ctx.lineTo( x + a[0]*mag*this.fontStretch, y - a[1]*mag);
-              }
-            }
-            ctx.stroke();
-            x += c.width*mag*this.fontStretch;
-         }
-         ctx.restore();
-         return total;
-    };
-
-    $.jqplot.CanvasTextRenderer.prototype.letters = {
-         ' ': { width: 16, points: [] },
-         '!': { width: 10, points: [[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]] },
-         '"': { width: 16, points: [[4,21],[4,14],[-1,-1],[12,21],[12,14]] },
-         '#': { width: 21, points: [[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]] },
-         '$': { width: 20, points: [[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]] },
-         '%': { width: 24, points: [[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]] },
-         '&': { width: 26, points: [[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]] },
-         '\'': { width: 10, points: [[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]] },
-         '(': { width: 14, points: [[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]] },
-         ')': { width: 14, points: [[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]] },
-         '*': { width: 16, points: [[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]] },
-         '+': { width: 26, points: [[13,18],[13,0],[-1,-1],[4,9],[22,9]] },
-         ',': { width: 10, points: [[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]] },
-         '-': { width: 18, points: [[6,9],[12,9]] },
-         '.': { width: 10, points: [[5,2],[4,1],[5,0],[6,1],[5,2]] },
-         '/': { width: 22, points: [[20,25],[2,-7]] },
-         '0': { width: 20, points: [[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]] },
-         '1': { width: 20, points: [[6,17],[8,18],[11,21],[11,0]] },
-         '2': { width: 20, points: [[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]] },
-         '3': { width: 20, points: [[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]] },
-         '4': { width: 20, points: [[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]] },
-         '5': { width: 20, points: [[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]] },
-         '6': { width: 20, points: [[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]] },
-         '7': { width: 20, points: [[17,21],[7,0],[-1,-1],[3,21],[17,21]] },
-         '8': { width: 20, points: [[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]] },
-         '9': { width: 20, points: [[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]] },
-         ':': { width: 10, points: [[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]] },
-         ';': { width: 10, points: [[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]] },
-         '<': { width: 24, points: [[20,18],[4,9],[20,0]] },
-         '=': { width: 26, points: [[4,12],[22,12],[-1,-1],[4,6],[22,6]] },
-         '>': { width: 24, points: [[4,18],[20,9],[4,0]] },
-         '?': { width: 18, points: [[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]] },
-         '@': { width: 27, points: [[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]] },
-         'A': { width: 18, points: [[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]] },
-         'B': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]] },
-         'C': { width: 21, points: [[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]] },
-         'D': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]] },
-         'E': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]] },
-         'F': { width: 18, points: [[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]] },
-         'G': { width: 21, points: [[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]] },
-         'H': { width: 22, points: [[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]] },
-         'I': { width: 8, points: [[4,21],[4,0]] },
-         'J': { width: 16, points: [[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]] },
-         'K': { width: 21, points: [[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]] },
-         'L': { width: 17, points: [[4,21],[4,0],[-1,-1],[4,0],[16,0]] },
-         'M': { width: 24, points: [[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]] },
-         'N': { width: 22, points: [[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]] },
-         'O': { width: 22, points: [[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]] },
-         'P': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]] },
-         'Q': { width: 22, points: [[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]] },
-         'R': { width: 21, points: [[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]] },
-         'S': { width: 20, points: [[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]] },
-         'T': { width: 16, points: [[8,21],[8,0],[-1,-1],[1,21],[15,21]] },
-         'U': { width: 22, points: [[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]] },
-         'V': { width: 18, points: [[1,21],[9,0],[-1,-1],[17,21],[9,0]] },
-         'W': { width: 24, points: [[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]] },
-         'X': { width: 20, points: [[3,21],[17,0],[-1,-1],[17,21],[3,0]] },
-         'Y': { width: 18, points: [[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]] },
-         'Z': { width: 20, points: [[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]] },
-         '[': { width: 14, points: [[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]] },
-         '\\': { width: 14, points: [[0,21],[14,-3]] },
-         ']': { width: 14, points: [[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]] },
-         '^': { width: 16, points: [[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]] },
-         '_': { width: 16, points: [[0,-2],[16,-2]] },
-         '`': { width: 10, points: [[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]] },
-         'a': { width: 19, points: [[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
-         'b': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]] },
-         'c': { width: 18, points: [[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
-         'd': { width: 19, points: [[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
-         'e': { width: 18, points: [[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
-         'f': { width: 12, points: [[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]] },
-         'g': { width: 19, points: [[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
-         'h': { width: 19, points: [[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]] },
-         'i': { width: 8, points: [[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]] },
-         'j': { width: 10, points: [[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]] },
-         'k': { width: 17, points: [[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]] },
-         'l': { width: 8, points: [[4,21],[4,0]] },
-         'm': { width: 30, points: [[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]] },
-         'n': { width: 19, points: [[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]] },
-         'o': { width: 19, points: [[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]] },
-         'p': { width: 19, points: [[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]] },
-         'q': { width: 19, points: [[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]] },
-         'r': { width: 13, points: [[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]] },
-         's': { width: 17, points: [[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]] },
-         't': { width: 12, points: [[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]] },
-         'u': { width: 19, points: [[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]] },
-         'v': { width: 16, points: [[2,14],[8,0],[-1,-1],[14,14],[8,0]] },
-         'w': { width: 22, points: [[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]] },
-         'x': { width: 17, points: [[3,14],[14,0],[-1,-1],[14,14],[3,0]] },
-         'y': { width: 16, points: [[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]] },
-         'z': { width: 17, points: [[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]] },
-         '{': { width: 14, points: [[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]] },
-         '|': { width: 8, points: [[4,25],[4,-7]] },
-         '}': { width: 14, points: [[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]] },
-         '~': { width: 24, points: [[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]] }
-     };
-     
-    $.jqplot.CanvasFontRenderer = function(options) {
-        options = options || {};
-        if (!options.pt2px) {
-            options.pt2px = 1.5;
-        }
-        $.jqplot.CanvasTextRenderer.call(this, options);
-    };
-    
-    $.jqplot.CanvasFontRenderer.prototype = new $.jqplot.CanvasTextRenderer({});
-    $.jqplot.CanvasFontRenderer.prototype.constructor = $.jqplot.CanvasFontRenderer;
-
-    $.jqplot.CanvasFontRenderer.prototype.measure = function(ctx, str)
-    {
-        // var fstyle = this.fontStyle+' '+this.fontVariant+' '+this.fontWeight+' '+this.fontSize+' '+this.fontFamily;
-        var fstyle = this.fontSize+' '+this.fontFamily;
-        ctx.save();
-        ctx.font = fstyle;
-        var w = ctx.measureText(str).width;
-        ctx.restore();
-        return w;
-    };
-
-    $.jqplot.CanvasFontRenderer.prototype.draw = function(ctx, str)
-    {
-        var x = 0;
-        // leave room at bottom for descenders.
-        var y = this.height*0.72;
-        //var y = 12;
-
-         ctx.save();
-         var tx, ty;
-         
-         // 1st quadrant
-         if ((-Math.PI/2 <= this.angle && this.angle <= 0) || (Math.PI*3/2 <= this.angle && this.angle <= Math.PI*2)) {
-             tx = 0;
-             ty = -Math.sin(this.angle) * this.width;
-         }
-         // 4th quadrant
-         else if ((0 < this.angle && this.angle <= Math.PI/2) || (-Math.PI*2 <= this.angle && this.angle <= -Math.PI*3/2)) {
-             tx = Math.sin(this.angle) * this.height;
-             ty = 0;
-         }
-         // 2nd quadrant
-         else if ((-Math.PI < this.angle && this.angle < -Math.PI/2) || (Math.PI <= this.angle && this.angle <= Math.PI*3/2)) {
-             tx = -Math.cos(this.angle) * this.width;
-             ty = -Math.sin(this.angle) * this.width - Math.cos(this.angle) * this.height;
-         }
-         // 3rd quadrant
-         else if ((-Math.PI*3/2 < this.angle && this.angle < Math.PI) || (Math.PI/2 < this.angle && this.angle < Math.PI)) {
-             tx = Math.sin(this.angle) * this.height - Math.cos(this.angle)*this.width;
-             ty = -Math.cos(this.angle) * this.height;
-         }
-         ctx.strokeStyle = this.fillStyle;
-         ctx.fillStyle = this.fillStyle;
-        // var fstyle = this.fontStyle+' '+this.fontVariant+' '+this.fontWeight+' '+this.fontSize+' '+this.fontFamily;
-        var fstyle = this.fontSize+' '+this.fontFamily;
-         ctx.font = fstyle;
-         ctx.translate(tx, ty);
-         ctx.rotate(this.angle);
-         ctx.fillText(str, x, y);
-         // ctx.strokeText(str, x, y);
-
-         ctx.restore();
-    };
-    
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasTextRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasTextRenderer.min.js
deleted file mode 100644
index 8a9e44e..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.canvasTextRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.CanvasTextRenderer=function(b){this.fontStyle="normal";this.fontVariant="normal";this.fontWeight="normal";this.fontSize="10px";this.fontFamily="sans-serif";this.fontStretch=1;this.fillStyle="#666666";this.angle=0;this.textAlign="start";this.textBaseline="alphabetic";this.text;this.width;this.height;this.pt2px=1.28;a.extend(true,this,b);this.normalizedFontSize=this.normalizeFontSize(this.fontSize);this.setHeight()};a.jqplot.CanvasTextRenderer.prototype.init=function(b){a.extend(true,this,b);this.normalizedFontSize=this.normalizeFontSize(this.fontSize);this.setHeight()};a.jqplot.CanvasTextRenderer.prototype.normalizeFontSize=function(b){b=String(b);var c=parseFloat(b);if(b.indexOf("px")>-1){return c/this.pt2px}else{if(b.indexOf("pt")>-1){return c}else{if(b.indexOf("em")>-1){return c*12}else{if(b.indexOf("%")>-1){return c*12/100}else{return c/this.pt2px}}}}};a.jqplot.CanvasTextRenderer.prototype.fontWeight2Float=function(b){if(Number(b)){return b/400}else{switch(b){case"normal":return 1;break;case"bold":return 1.75;break;case"bolder":return 2.25;break;case"lighter":return 0.75;break;default:return 1;break}}};a.jqplot.CanvasTextRenderer.prototype.getText=function(){return this.text};a.jqplot.CanvasTextRenderer.prototype.setText=function(c,b){this.text=c;this.setWidth(b);return this};a.jqplot.CanvasTextRenderer.prototype.getWidth=function(b){return this.width};a.jqplot.CanvasTextRenderer.prototype.setWidth=function(c,b){if(!b){this.width=this.measure(c,this.text)}else{this.width=b}return this};a.jqplot.CanvasTextRenderer.prototype.getHeight=function(b){return this.height};a.jqplot.CanvasTextRenderer.prototype.setHeight=function(b){if(!b){this.height=this.normalizedFontSize*this.pt2px}else{this.height=b}return this};a.jqplot.CanvasTextRenderer.prototype.letter=function(b){return this.letters[b]};a.jqplot.CanvasTextRenderer.prototype.ascent=function(){return this.normalizedFontSize};a.jqplot.CanvasTextRenderer.prototype.descent=function(){return 7*this.normalizedFontSize/25};a.jqplot.CanvasTextRenderer.prototype.measure=function(d,g){var f=0;var b=g.length;for(var e=0;e<b;e++){var h=this.letter(g.charAt(e));if(h){f+=h.width*this.normalizedFontSize/25*this.fontStretch}}return f};a.jqplot.CanvasTextRenderer.prototype.draw=function(s,n){var r=0;var o=this.height*0.72;var p=0;var l=n.length;var k=this.normalizedFontSize/25;s.save();var h,f;if((-Math.PI/2<=this.angle&&this.angle<=0)||(Math.PI*3/2<=this.angle&&this.angle<=Math.PI*2)){h=0;f=-Math.sin(this.angle)*this.width}else{if((0<this.angle&&this.angle<=Math.PI/2)||(-Math.PI*2<=this.angle&&this.angle<=-Math.PI*3/2)){h=Math.sin(this.angle)*this.height;f=0}else{if((-Math.PI<this.angle&&this.angle<-Math.PI/2)||(Math.PI<=this.angle&&this.angle<=Math.PI*3/2)){h=-Math.cos(this.angle)*this.width;f=-Math.sin(this.angle)*this.width-Math.cos(this.angle)*this.height}else{if((-Math.PI*3/2<this.angle&&this.angle<Math.PI)||(Math.PI/2<this.angle&&this.angle<Math.PI)){h=Math.sin(this.angle)*this.height-Math.cos(this.angle)*this.width;f=-Math.cos(this.angle)*this.height}}}}s.strokeStyle=this.fillStyle;s.fillStyle=this.fillStyle;s.translate(h,f);s.rotate(this.angle);s.lineCap="round";var t=(this.normalizedFontSize>30)?2:2+(30-this.normalizedFontSize)/20;s.lineWidth=t*k*this.fontWeight2Float(this.fontWeight);for(var g=0;g<l;g++){var m=this.letter(n.charAt(g));if(!m){continue}s.beginPath();var e=1;var b=0;for(var d=0;d<m.points.length;d++){var q=m.points[d];if(q[0]==-1&&q[1]==-1){e=1;continue}if(e){s.moveTo(r+q[0]*k*this.fontStretch,o-q[1]*k);e=false}else{s.lineTo(r+q[0]*k*this.fontStretch,o-q[1]*k)}}s.stroke();r+=m.width*k*this.fontStretch}s.restore();return p};a.jqplot.CanvasTextRenderer.prototype.letters={" ":{width:16,points:[]},"!":{width:10,points:[[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},'"':{width:16,points:[[4,21],[4,14],[-1,-1],[12,21],[12,14]]},"#":{width:21,points:[[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]]},"$":{width:20,points:[[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},"%":{width:24,points:[[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]]},"&":{width:26,points:[[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]]},"'":{width:10,points:[[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]]},"(":{width:14,points:[[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]]},")":{width:14,points:[[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]]},"*":{width:16,points:[[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]]},"+":{width:26,points:[[13,18],[13,0],[-1,-1],[4,9],[22,9]]},",":{width:10,points:[[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"-":{width:18,points:[[6,9],[12,9]]},".":{width:10,points:[[5,2],[4,1],[5,0],[6,1],[5,2]]},"/":{width:22,points:[[20,25],[2,-7]]},"0":{width:20,points:[[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]]},"1":{width:20,points:[[6,17],[8,18],[11,21],[11,0]]},"2":{width:20,points:[[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]]},"3":{width:20,points:[[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},"4":{width:20,points:[[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]]},"5":{width:20,points:[[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},"6":{width:20,points:[[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]]},"7":{width:20,points:[[17,21],[7,0],[-1,-1],[3,21],[17,21]]},"8":{width:20,points:[[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]]},"9":{width:20,points:[[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]]},":":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},";":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"<":{width:24,points:[[20,18],[4,9],[20,0]]},"=":{width:26,points:[[4,12],[22,12],[-1,-1],[4,6],[22,6]]},">":{width:24,points:[[4,18],[20,9],[4,0]]},"?":{width:18,points:[[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]]},"@":{width:27,points:[[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]]},A:{width:18,points:[[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]]},B:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]]},C:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]]},D:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]]},E:{width:19,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]]},F:{width:18,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]]},G:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]]},H:{width:22,points:[[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]]},I:{width:8,points:[[4,21],[4,0]]},J:{width:16,points:[[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]]},K:{width:21,points:[[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]]},L:{width:17,points:[[4,21],[4,0],[-1,-1],[4,0],[16,0]]},M:{width:24,points:[[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]]},N:{width:22,points:[[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]]},O:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]]},P:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]]},Q:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]]},R:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]]},S:{width:20,points:[[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},T:{width:16,points:[[8,21],[8,0],[-1,-1],[1,21],[15,21]]},U:{width:22,points:[[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]]},V:{width:18,points:[[1,21],[9,0],[-1,-1],[17,21],[9,0]]},W:{width:24,points:[[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]]},X:{width:20,points:[[3,21],[17,0],[-1,-1],[17,21],[3,0]]},Y:{width:18,points:[[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]]},Z:{width:20,points:[[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]]},"[":{width:14,points:[[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]]},"\\":{width:14,points:[[0,21],[14,-3]]},"]":{width:14,points:[[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]]},"^":{width:16,points:[[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]]},_:{width:16,points:[[0,-2],[16,-2]]},"`":{width:10,points:[[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]]},a:{width:19,points:[[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},b:{width:19,points:[[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},c:{width:18,points:[[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},d:{width:19,points:[[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},e:{width:18,points:[[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},f:{width:12,points:[[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]]},g:{width:19,points:[[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},h:{width:19,points:[[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},i:{width:8,points:[[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]]},j:{width:10,points:[[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]]},k:{width:17,points:[[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]]},l:{width:8,points:[[4,21],[4,0]]},m:{width:30,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]]},n:{width:19,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},o:{width:19,points:[[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]]},p:{width:19,points:[[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},q:{width:19,points:[[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},r:{width:13,points:[[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]]},s:{width:17,points:[[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]]},t:{width:12,points:[[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]]},u:{width:19,points:[[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]]},v:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0]]},w:{width:22,points:[[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]]},x:{width:17,points:[[3,14],[14,0],[-1,-1],[14,14],[3,0]]},y:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]]},z:{width:17,points:[[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]]},"{":{width:14,points:[[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]]},"|":{width:8,points:[[4,25],[4,-7]]},"}":{width:14,points:[[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]]},"~":{width:24,points:[[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]]}};a.jqplot.CanvasFontRenderer=function(b){b=b||{};if(!b.pt2px){b.pt2px=1.5}a.jqplot.CanvasTextRenderer.call(this,b)};a.jqplot.CanvasFontRenderer.prototype=new a.jqplot.CanvasTextRenderer({});a.jqplot.CanvasFontRenderer.prototype.constructor=a.jqplot.CanvasFontRenderer;a.jqplot.CanvasFontRenderer.prototype.measure=function(c,e){var d=this.fontSize+" "+this.fontFamily;c.save();c.font=d;var b=c.measureText(e).width;c.restore();return b};a.jqplot.CanvasFontRenderer.prototype.draw=function(e,g){var c=0;var h=this.height*0.72;e.save();var d,b;if((-Math.PI/2<=this.angle&&this.angle<=0)||(Math.PI*3/2<=this.angle&&this.angle<=Math.PI*2)){d=0;b=-Math.sin(this.angle)*this.width}else{if((0<this.angle&&this.angle<=Math.PI/2)||(-Math.PI*2<=this.angle&&this.angle<=-Math.PI*3/2)){d=Math.sin(this.angle)*this.height;b=0}else{if((-Math.PI<this.angle&&this.angle<-Math.PI/2)||(Math.PI<=this.angle&&this.angle<=Math.PI*3/2)){d=-Math.cos(this.angle)*this.width;b=-Math.sin(this.angle)*this.width-Math.cos(this.angle)*this.height}else{if((-Math.PI*3/2<this.angle&&this.angle<Math.PI)||(Math.PI/2<this.angle&&this.angle<Math.PI)){d=Math.sin(this.angle)*this.height-Math.cos(this.angle)*this.width;b=-Math.cos(this.angle)*this.height}}}}e.strokeStyle=this.fillStyle;e.fillStyle=this.fillStyle;var f=this.fontSize+" "+this.fontFamily;e.font=f;e.translate(d,b);e.rotate(this.angle);e.fillText(g,c,h);e.restore()}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.categoryAxisRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.categoryAxisRenderer.js
deleted file mode 100644
index 82e4121..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.categoryAxisRenderer.js
+++ /dev/null
@@ -1,636 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {   
-    /**
-    *  class: $.jqplot.CategoryAxisRenderer
-    *  A plugin for jqPlot to render a category style axis, with equal pixel spacing between y data values of a series.
-    *  
-    *  To use this renderer, include the plugin in your source
-    *  > <script type="text/javascript" language="javascript" src="plugins/jqplot.categoryAxisRenderer.js"></script>
-    *  
-    *  and supply the appropriate options to your plot
-    *  
-    *  > {axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer}}}
-    **/
-    $.jqplot.CategoryAxisRenderer = function(options) {
-        $.jqplot.LinearAxisRenderer.call(this);
-        // prop: sortMergedLabels
-        // True to sort tick labels when labels are created by merging
-        // x axis values from multiple series.  That is, say you have
-        // two series like:
-        // > line1 = [[2006, 4],            [2008, 9], [2009, 16]];
-        // > line2 = [[2006, 3], [2007, 7], [2008, 6]];
-        // If no label array is specified, tick labels will be collected
-        // from the x values of the series.  With sortMergedLabels
-        // set to true, tick labels will be:
-        // > [2006, 2007, 2008, 2009]
-        // With sortMergedLabels set to false, tick labels will be:
-        // > [2006, 2008, 2009, 2007]
-        //
-        // Note, this property is specified on the renderOptions for the 
-        // axes when creating a plot:
-        // > axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer, rendererOptions:{sortMergedLabels:true}}}
-        this.sortMergedLabels = false;
-    };
-    
-    $.jqplot.CategoryAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
-    $.jqplot.CategoryAxisRenderer.prototype.constructor = $.jqplot.CategoryAxisRenderer;
-    
-    $.jqplot.CategoryAxisRenderer.prototype.init = function(options){
-        this.groups = 1;
-        this.groupLabels = [];
-        this._groupLabels = [];
-        this._grouped = false;
-        this._barsPerGroup = null;
-        // prop: tickRenderer
-        // A class of a rendering engine for creating the ticks labels displayed on the plot, 
-        // See <$.jqplot.AxisTickRenderer>.
-        // this.tickRenderer = $.jqplot.AxisTickRenderer;
-        // this.labelRenderer = $.jqplot.AxisLabelRenderer;
-        $.extend(true, this, {tickOptions:{formatString:'%d'}}, options);
-        var db = this._dataBounds;
-        // Go through all the series attached to this axis and find
-        // the min/max bounds for this axis.
-        for (var i=0; i<this._series.length; i++) {
-            var s = this._series[i];
-            if (s.groups) {
-                this.groups = s.groups;
-            }
-            var d = s.data;
-            
-            for (var j=0; j<d.length; j++) { 
-                if (this.name == 'xaxis' || this.name == 'x2axis') {
-                    if (d[j][0] < db.min || db.min == null) {
-                        db.min = d[j][0];
-                    }
-                    if (d[j][0] > db.max || db.max == null) {
-                        db.max = d[j][0];
-                    }
-                }              
-                else {
-                    if (d[j][1] < db.min || db.min == null) {
-                        db.min = d[j][1];
-                    }
-                    if (d[j][1] > db.max || db.max == null) {
-                        db.max = d[j][1];
-                    }
-                }              
-            }
-        }
-        
-        if (this.groupLabels.length) {
-            this.groups = this.groupLabels.length;
-        }
-    };
- 
-
-    $.jqplot.CategoryAxisRenderer.prototype.createTicks = function() {
-        // we're are operating on an axis here
-        var ticks = this._ticks;
-        var userTicks = this.ticks;
-        var name = this.name;
-        // databounds were set on axis initialization.
-        var db = this._dataBounds;
-        var dim, interval;
-        var min, max;
-        var pos1, pos2;
-        var tt, i;
-
-        // if we already have ticks, use them.
-        if (userTicks.length) {
-            // adjust with blanks if we have groups
-            if (this.groups > 1 && !this._grouped) {
-                var l = userTicks.length;
-                var skip = parseInt(l/this.groups, 10);
-                var count = 0;
-                for (var i=skip; i<l; i+=skip) {
-                    userTicks.splice(i+count, 0, ' ');
-                    count++;
-                }
-                this._grouped = true;
-            }
-            this.min = 0.5;
-            this.max = userTicks.length + 0.5;
-            var range = this.max - this.min;
-            this.numberTicks = 2*userTicks.length + 1;
-            for (i=0; i<userTicks.length; i++){
-                tt = this.min + 2 * i * range / (this.numberTicks-1);
-                // need a marker before and after the tick
-                var t = new this.tickRenderer(this.tickOptions);
-                t.showLabel = false;
-                // t.showMark = true;
-                t.setTick(tt, this.name);
-                this._ticks.push(t);
-                var t = new this.tickRenderer(this.tickOptions);
-                t.label = userTicks[i];
-                // t.showLabel = true;
-                t.showMark = false;
-                t.showGridline = false;
-                t.setTick(tt+0.5, this.name);
-                this._ticks.push(t);
-            }
-            // now add the last tick at the end
-            var t = new this.tickRenderer(this.tickOptions);
-            t.showLabel = false;
-            // t.showMark = true;
-            t.setTick(tt+1, this.name);
-            this._ticks.push(t);
-        }
-
-        // we don't have any ticks yet, let's make some!
-        else {
-            if (name == 'xaxis' || name == 'x2axis') {
-                dim = this._plotDimensions.width;
-            }
-            else {
-                dim = this._plotDimensions.height;
-            }
-            
-            // if min, max and number of ticks specified, user can't specify interval.
-            if (this.min != null && this.max != null && this.numberTicks != null) {
-                this.tickInterval = null;
-            }
-            
-            // if max, min, and interval specified and interval won't fit, ignore interval.
-            if (this.min != null && this.max != null && this.tickInterval != null) {
-                if (parseInt((this.max-this.min)/this.tickInterval, 10) != (this.max-this.min)/this.tickInterval) {
-                    this.tickInterval = null;
-                }
-            }
-        
-            // find out how many categories are in the lines and collect labels
-            var labels = [];
-            var numcats = 0;
-            var min = 0.5;
-            var max, val;
-            var isMerged = false;
-            for (var i=0; i<this._series.length; i++) {
-                var s = this._series[i];
-                for (var j=0; j<s.data.length; j++) {
-                    if (this.name == 'xaxis' || this.name == 'x2axis') {
-                        val = s.data[j][0];
-                    }
-                    else {
-                        val = s.data[j][1];
-                    }
-                    if ($.inArray(val, labels) == -1) {
-                        isMerged = true;
-                        numcats += 1;      
-                        labels.push(val);
-                    }
-                }
-            }
-            
-            if (isMerged && this.sortMergedLabels) {
-                labels.sort(function(a,b) { return a - b; });
-            }
-            
-            // keep a reference to these tick labels to use for redrawing plot (see bug #57)
-            this.ticks = labels;
-            
-            // now bin the data values to the right lables.
-            for (var i=0; i<this._series.length; i++) {
-                var s = this._series[i];
-                for (var j=0; j<s.data.length; j++) {
-                    if (this.name == 'xaxis' || this.name == 'x2axis') {
-                        val = s.data[j][0];
-                    }
-                    else {
-                        val = s.data[j][1];
-                    }
-                    // for category axis, force the values into category bins.
-                    // we should have the value in the label array now.
-                    var idx = $.inArray(val, labels)+1;
-                    if (this.name == 'xaxis' || this.name == 'x2axis') {
-                        s.data[j][0] = idx;
-                    }
-                    else {
-                        s.data[j][1] = idx;
-                    }
-                }
-            }
-            
-            // adjust with blanks if we have groups
-            if (this.groups > 1 && !this._grouped) {
-                var l = labels.length;
-                var skip = parseInt(l/this.groups, 10);
-                var count = 0;
-                for (var i=skip; i<l; i+=skip+1) {
-                    labels[i] = ' ';
-                }
-                this._grouped = true;
-            }
-        
-            max = numcats + 0.5;
-            if (this.numberTicks == null) {
-                this.numberTicks = 2*numcats + 1;
-            }
-
-            var range = max - min;
-            this.min = min;
-            this.max = max;
-            var track = 0;
-            
-            // todo: adjust this so more ticks displayed.
-            var maxVisibleTicks = parseInt(3+dim/20, 10);
-            var skip = parseInt(numcats/maxVisibleTicks, 10);
-
-            if (this.tickInterval == null) {
-
-                this.tickInterval = range / (this.numberTicks-1);
-
-            }
-            // if tickInterval is specified, we will ignore any computed maximum.
-            for (var i=0; i<this.numberTicks; i++){
-                tt = this.min + i * this.tickInterval;
-                var t = new this.tickRenderer(this.tickOptions);
-                // if even tick, it isn't a category, it's a divider
-                if (i/2 == parseInt(i/2, 10)) {
-                    t.showLabel = false;
-                    t.showMark = true;
-                }
-                else {
-                    if (skip>0 && track<skip) {
-                        t.showLabel = false;
-                        track += 1;
-                    }
-                    else {
-                        t.showLabel = true;
-                        track = 0;
-                    } 
-                    t.label = t.formatter(t.formatString, labels[(i-1)/2]);
-                    t.showMark = false;
-                    t.showGridline = false;
-                }
-                t.setTick(tt, this.name);
-                this._ticks.push(t);
-            }
-        }
-        
-    };
-    
-    // called with scope of axis
-    $.jqplot.CategoryAxisRenderer.prototype.draw = function(ctx, plot) {
-        if (this.show) {
-            // populate the axis label and value properties.
-            // createTicks is a method on the renderer, but
-            // call it within the scope of the axis.
-            this.renderer.createTicks.call(this);
-            // fill a div with axes labels in the right direction.
-            // Need to pregenerate each axis to get it's bounds and
-            // position it and the labels correctly on the plot.
-            var dim=0;
-            var temp;
-            // Added for theming.
-            if (this._elem) {
-                // this._elem.empty();
-                // Memory Leaks patch
-                this._elem.emptyForce();
-            }
-
-            this._elem = this._elem || $('<div class="jqplot-axis jqplot-'+this.name+'" style="position:absolute;"></div>');
-            
-            if (this.name == 'xaxis' || this.name == 'x2axis') {
-                this._elem.width(this._plotDimensions.width);
-            }
-            else {
-                this._elem.height(this._plotDimensions.height);
-            }
-            
-            // create a _label object.
-            this.labelOptions.axis = this.name;
-            this._label = new this.labelRenderer(this.labelOptions);
-            if (this._label.show) {
-                var elem = this._label.draw(ctx, plot);
-                elem.appendTo(this._elem);
-            }
-    
-            var t = this._ticks;
-            for (var i=0; i<t.length; i++) {
-                var tick = t[i];
-                if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
-                    var elem = tick.draw(ctx, plot);
-                    elem.appendTo(this._elem);
-                }
-            }
-        
-            this._groupLabels = [];
-            // now make group labels
-            for (var i=0; i<this.groupLabels.length; i++)
-            {
-                var elem = $('<div style="position:absolute;" class="jqplot-'+this.name+'-groupLabel"></div>');
-                elem.html(this.groupLabels[i]);
-                this._groupLabels.push(elem);
-                elem.appendTo(this._elem);
-            }
-        }
-        return this._elem;
-    };
-    
-    // called with scope of axis
-    $.jqplot.CategoryAxisRenderer.prototype.set = function() { 
-        var dim = 0;
-        var temp;
-        var w = 0;
-        var h = 0;
-        var lshow = (this._label == null) ? false : this._label.show;
-        if (this.show) {
-            var t = this._ticks;
-            for (var i=0; i<t.length; i++) {
-                var tick = t[i];
-                if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
-                    if (this.name == 'xaxis' || this.name == 'x2axis') {
-                        temp = tick._elem.outerHeight(true);
-                    }
-                    else {
-                        temp = tick._elem.outerWidth(true);
-                    }
-                    if (temp > dim) {
-                        dim = temp;
-                    }
-                }
-            }
-            
-            var dim2 = 0;
-            for (var i=0; i<this._groupLabels.length; i++) {
-                var l = this._groupLabels[i];
-                if (this.name == 'xaxis' || this.name == 'x2axis') {
-                    temp = l.outerHeight(true);
-                }
-                else {
-                    temp = l.outerWidth(true);
-                }
-                if (temp > dim2) {
-                    dim2 = temp;
-                }
-            }
-            
-            if (lshow) {
-                w = this._label._elem.outerWidth(true);
-                h = this._label._elem.outerHeight(true); 
-            }
-            if (this.name == 'xaxis') {
-                dim += dim2 + h;
-                this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'});
-            }
-            else if (this.name == 'x2axis') {
-                dim += dim2 + h;
-                this._elem.css({'height':dim+'px', left:'0px', top:'0px'});
-            }
-            else if (this.name == 'yaxis') {
-                dim += dim2 + w;
-                this._elem.css({'width':dim+'px', left:'0px', top:'0px'});
-                if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
-                    this._label._elem.css('width', w+'px');
-                }
-            }
-            else {
-                dim += dim2 + w;
-                this._elem.css({'width':dim+'px', right:'0px', top:'0px'});
-                if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
-                    this._label._elem.css('width', w+'px');
-                }
-            }
-        }  
-    };
-    
-    // called with scope of axis
-    $.jqplot.CategoryAxisRenderer.prototype.pack = function(pos, offsets) {
-        var ticks = this._ticks;
-        var max = this.max;
-        var min = this.min;
-        var offmax = offsets.max;
-        var offmin = offsets.min;
-        var lshow = (this._label == null) ? false : this._label.show;
-        var i;
-		
-        for (var p in pos) {
-            this._elem.css(p, pos[p]);
-        }
-        
-        this._offsets = offsets;
-        // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left.
-        var pixellength = offmax - offmin;
-        var unitlength = max - min;
-        
-        // point to unit and unit to point conversions references to Plot DOM element top left corner.
-        this.p2u = function(p){
-            return (p - offmin) * unitlength / pixellength + min;
-        };
-        
-        this.u2p = function(u){
-            return (u - min) * pixellength / unitlength + offmin;
-        };
-                
-        if (this.name == 'xaxis' || this.name == 'x2axis'){
-            this.series_u2p = function(u){
-                return (u - min) * pixellength / unitlength;
-            };
-            this.series_p2u = function(p){
-                return p * unitlength / pixellength + min;
-            };
-        }
-        
-        else {
-            this.series_u2p = function(u){
-                return (u - max) * pixellength / unitlength;
-            };
-            this.series_p2u = function(p){
-                return p * unitlength / pixellength + max;
-            };
-        }
-        
-        if (this.show) {
-            if (this.name == 'xaxis' || this.name == 'x2axis') {
-                for (i=0; i<ticks.length; i++) {
-                    var t = ticks[i];
-                    if (t.show && t.showLabel) {
-                        var shim;
-                        
-                        if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
-                            // will need to adjust auto positioning based on which axis this is.
-                            var temp = (this.name == 'xaxis') ? 1 : -1;
-                            switch (t.labelPosition) {
-                                case 'auto':
-                                    // position at end
-                                    if (temp * t.angle < 0) {
-                                        shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    }
-                                    // position at start
-                                    else {
-                                        shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'end':
-                                    shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                                case 'start':
-                                    shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    break;
-                                case 'middle':
-                                    shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                                default:
-                                    shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                            }
-                        }
-                        else {
-                            shim = -t.getWidth()/2;
-                        }
-                        var val = this.u2p(t.value) + shim + 'px';
-                        t._elem.css('left', val);
-                        t.pack();
-                    }
-                }
-                
-                var labeledge=['bottom', 0];
-                if (lshow) {
-                    var w = this._label._elem.outerWidth(true);
-                    this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px');
-                    if (this.name == 'xaxis') {
-                        this._label._elem.css('bottom', '0px');
-                        labeledge = ['bottom', this._label._elem.outerHeight(true)];
-                    }
-                    else {
-                        this._label._elem.css('top', '0px');
-                        labeledge = ['top', this._label._elem.outerHeight(true)];
-                    }
-                    this._label.pack();
-                }
-                
-                // draw the group labels
-                var step = parseInt(this._ticks.length/this.groups, 10);
-                for (i=0; i<this._groupLabels.length; i++) {
-                    var mid = 0;
-                    var count = 0;
-                    for (var j=i*step; j<=(i+1)*step; j++) {
-                        if (this._ticks[j]._elem && this._ticks[j].label != " ") {
-                            var t = this._ticks[j]._elem;
-                            var p = t.position();
-                            mid += p.left + t.outerWidth(true)/2;
-                            count++;
-                        }
-                    }
-                    mid = mid/count;
-                    this._groupLabels[i].css({'left':(mid - this._groupLabels[i].outerWidth(true)/2)});
-                    this._groupLabels[i].css(labeledge[0], labeledge[1]);
-                }
-            }
-            else {
-                for (i=0; i<ticks.length; i++) {
-                    var t = ticks[i];
-                    if (t.show && t.showLabel) {                        
-                        var shim;
-                        if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
-                            // will need to adjust auto positioning based on which axis this is.
-                            var temp = (this.name == 'yaxis') ? 1 : -1;
-                            switch (t.labelPosition) {
-                                case 'auto':
-                                    // position at end
-                                case 'end':
-                                    if (temp * t.angle < 0) {
-                                        shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
-                                    }
-                                    else {
-                                        shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'start':
-                                    if (t.angle > 0) {
-                                        shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
-                                    }
-                                    else {
-                                        shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'middle':
-                                    // if (t.angle > 0) {
-                                    //     shim = -t.getHeight()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    // }
-                                    // else {
-                                    //     shim = -t.getHeight()/2 - t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    // }
-                                    shim = -t.getHeight()/2;
-                                    break;
-                                default:
-                                    shim = -t.getHeight()/2;
-                                    break;
-                            }
-                        }
-                        else {
-                            shim = -t.getHeight()/2;
-                        }
-                        
-                        var val = this.u2p(t.value) + shim + 'px';
-                        t._elem.css('top', val);
-                        t.pack();
-                    }
-                }
-                
-                var labeledge=['left', 0];
-                if (lshow) {
-                    var h = this._label._elem.outerHeight(true);
-                    this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px');
-                    if (this.name == 'yaxis') {
-                        this._label._elem.css('left', '0px');
-                        labeledge = ['left', this._label._elem.outerWidth(true)];
-                    }
-                    else {
-                        this._label._elem.css('right', '0px');
-                        labeledge = ['right', this._label._elem.outerWidth(true)];
-                    }   
-                    this._label.pack();
-                }
-                
-                // draw the group labels, position top here, do left after label position.
-                var step = parseInt(this._ticks.length/this.groups, 10);
-                for (i=0; i<this._groupLabels.length; i++) {
-                    var mid = 0;
-                    var count = 0;
-                    for (var j=i*step; j<=(i+1)*step; j++) {
-                        if (this._ticks[j]._elem && this._ticks[j].label != " ") {
-                            var t = this._ticks[j]._elem;
-                            var p = t.position();
-                            mid += p.top + t.outerHeight()/2;
-                            count++;
-                        }
-                    }
-                    mid = mid/count;
-                    this._groupLabels[i].css({'top':mid - this._groupLabels[i].outerHeight()/2});
-                    this._groupLabels[i].css(labeledge[0], labeledge[1]);
-                    
-                }
-            }
-        }
-    };    
-    
-    
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.categoryAxisRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.categoryAxisRenderer.min.js
deleted file mode 100644
index db0d7a7..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.categoryAxisRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.CategoryAxisRenderer=function(b){a.jqplot.LinearAxisRenderer.call(this);this.sortMergedLabels=false};a.jqplot.CategoryAxisRenderer.prototype=new a.jqplot.LinearAxisRenderer();a.jqplot.CategoryAxisRenderer.prototype.constructor=a.jqplot.CategoryAxisRenderer;a.jqplot.CategoryAxisRenderer.prototype.init=function(e){this.groups=1;this.groupLabels=[];this._groupLabels=[];this._grouped=false;this._barsPerGroup=null;a.extend(true,this,{tickOptions:{formatString:"%d"}},e);var b=this._dataBounds;for(var f=0;f<this._series.length;f++){var g=this._series[f];if(g.groups){this.groups=g.groups}var h=g.data;for(var c=0;c<h.length;c++){if(this.name=="xaxis"||this.name=="x2axis"){if(h[c][0]<b.min||b.min==null){b.min=h[c][0]}if(h[c][0]>b.max||b.max==null){b.max=h[c][0]}}else{if(h[c][1]<b.min||b.min==null){b.min=h[c][1]}if(h[c][1]>b.max||b.max==null){b.max=h[c][1]}}}}if(this.groupLabels.length){this.groups=this.groupLabels.length}};a.jqplot.CategoryAxisRenderer.prototype.createTicks=function(){var D=this._ticks;var z=this.ticks;var F=this.name;var C=this._dataBounds;var v,A;var q,w;var d,c;var b,x;if(z.length){if(this.groups>1&&!this._grouped){var r=z.length;var p=parseInt(r/this.groups,10);var e=0;for(var x=p;x<r;x+=p){z.splice(x+e,0," ");e++}this._grouped=true}this.min=0.5;this.max=z.length+0.5;var m=this.max-this.min;this.numberTicks=2*z.length+1;for(x=0;x<z.length;x++){b=this.min+2*x*m/(this.numberTicks-1);var h=new this.tickRenderer(this.tickOptions);h.showLabel=false;h.setTick(b,this.name);this._ticks.push(h);var h=new this.tickRenderer(this.tickOptions);h.label=z[x];h.showMark=false;h.showGridline=false;h.setTick(b+0.5,this.name);this._ticks.push(h)}var h=new this.tickRenderer(this.tickOptions);h.showLabel=false;h.setTick(b+1,this.name);this._ticks.push(h)}else{if(F=="xaxis"||F=="x2axis"){v=this._plotDimensions.width}else{v=this._plotDimensions.height}if(this.min!=null&&this.max!=null&&this.numberTicks!=null){this.tickInterval=null}if(this.min!=null&&this.max!=null&&this.tickInterval!=null){if(parseInt((this.max-this.min)/this.tickInterval,10)!=(this.max-this.min)/this.tickInterval){this.tickInterval=null}}var y=[];var B=0;var q=0.5;var w,E;var f=false;for(var x=0;x<this._series.length;x++){var k=this._series[x];for(var u=0;u<k.data.length;u++){if(this.name=="xaxis"||this.name=="x2axis"){E=k.data[u][0]}else{E=k.data[u][1]}if(a.inArray(E,y)==-1){f=true;B+=1;y.push(E)}}}if(f&&this.sortMergedLabels){y.sort(function(j,i){return j-i})}this.ticks=y;for(var x=0;x<this._series.length;x++){var k=this._series[x];for(var u=0;u<k.data.length;u++){if(this.name=="xaxis"||this.name=="x2axis"){E=k.data[u][0]}else{E=k.data[u][1]}var n=a.inArray(E,y)+1;if(this.name=="xaxis"||this.name=="x2axis"){k.data[u][0]=n}else{k.data[u][1]=n}}}if(this.groups>1&&!this._grouped){var r=y.length;var p=parseInt(r/this.groups,10);var e=0;for(var x=p;x<r;x+=p+1){y[x]=" "}this._grouped=true}w=B+0.5;if(this.numberTicks==null){this.numberTicks=2*B+1}var m=w-q;this.min=q;this.max=w;var o=0;var g=parseInt(3+v/20,10);var p=parseInt(B/g,10);if(this.tickInterval==null){this.tickInterval=m/(this.numberTicks-1)}for(var x=0;x<this.numberTicks;x++){b=this.min+x*this.tickInterval;var h=new this.tickRenderer(this.tickOptions);if(x/2==parseInt(x/2,10)){h.showLabel=false;h.showMark=true}else{if(p>0&&o<p){h.showLabel=false;o+=1}else{h.showLabel=true;o=0}h.label=h.formatter(h.formatString,y[(x-1)/2]);h.showMark=false;h.showGridline=false}h.setTick(b,this.name);this._ticks.push(h)}}};a.jqplot.CategoryAxisRenderer.prototype.draw=function(b,j){if(this.show){this.renderer.createTicks.call(this);var h=0;var c;if(this._elem){this._elem.emptyForce()}this._elem=this._elem||a('<div class="jqplot-axis jqplot-'+this.name+'" style="position:absolute;"></div>');if(this.name=="xaxis"||this.name=="x2axis"){this._elem.width(this._plotDimensions.width)}else{this._elem.height(this._plotDimensions.height)}this.labelOptions.axis=this.name;this._label=new this.labelRenderer(this.labelOptions);if(this._label.show){var g=this._label.draw(b,j);g.appendTo(this._elem)}var f=this._ticks;for(var e=0;e<f.length;e++){var d=f[e];if(d.showLabel&&(!d.isMinorTick||this.showMinorTicks)){var g=d.draw(b,j);g.appendTo(this._elem)}}this._groupLabels=[];for(var e=0;e<this.groupLabels.length;e++){var g=a('<div style="position:absolute;" class="jqplot-'+this.name+'-groupLabel"></div>');g.html(this.groupLabels[e]);this._groupLabels.push(g);g.appendTo(this._elem)}}return this._elem};a.jqplot.CategoryAxisRenderer.prototype.set=function(){var e=0;var m;var k=0;var f=0;var d=(this._label==null)?false:this._label.show;if(this.show){var n=this._ticks;for(var c=0;c<n.length;c++){var g=n[c];if(g.showLabel&&(!g.isMinorTick||this.showMinorTicks)){if(this.name=="xaxis"||this.name=="x2axis"){m=g._elem.outerHeight(true)}else{m=g._elem.outerWidth(true)}if(m>e){e=m}}}var j=0;for(var c=0;c<this._groupLabels.length;c++){var b=this._groupLabels[c];if(this.name=="xaxis"||this.name=="x2axis"){m=b.outerHeight(true)}else{m=b.outerWidth(true)}if(m>j){j=m}}if(d){k=this._label._elem.outerWidth(true);f=this._label._elem.outerHeight(true)}if(this.name=="xaxis"){e+=j+f;this._elem.css({height:e+"px",left:"0px",bottom:"0px"})}else{if(this.name=="x2axis"){e+=j+f;this._elem.css({height:e+"px",left:"0px",top:"0px"})}else{if(this.name=="yaxis"){e+=j+k;this._elem.css({width:e+"px",left:"0px",top:"0px"});if(d&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",k+"px")}}else{e+=j+k;this._elem.css({width:e+"px",right:"0px",top:"0px"});if(d&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",k+"px")}}}}}};a.jqplot.CategoryAxisRenderer.prototype.pack=function(e,c){var C=this._ticks;var v=this.max;var s=this.min;var n=c.max;var l=c.min;var q=(this._label==null)?false:this._label.show;var x;for(var r in e){this._elem.css(r,e[r])}this._offsets=c;var g=n-l;var k=v-s;this.p2u=function(h){return(h-l)*k/g+s};this.u2p=function(h){return(h-s)*g/k+l};if(this.name=="xaxis"||this.name=="x2axis"){this.series_u2p=function(h){return(h-s)*g/k};this.series_p2u=function(h){return h*k/g+s}}else{this.series_u2p=function(h){return(h-v)*g/k};this.series_p2u=function(h){return h*k/g+v}}if(this.show){if(this.name=="xaxis"||this.name=="x2axis"){for(x=0;x<C.length;x++){var o=C[x];if(o.show&&o.showLabel){var b;if(o.constructor==a.jqplot.CanvasAxisTickRenderer&&o.angle){var A=(this.name=="xaxis")?1:-1;switch(o.labelPosition){case"auto":if(A*o.angle<0){b=-o.getWidth()+o._textRenderer.height*Math.sin(-o._textRenderer.angle)/2}else{b=-o._textRenderer.height*Math.sin(o._textRenderer.angle)/2}break;case"end":b=-o.getWidth()+o._textRenderer.height*Math.sin(-o._textRenderer.angle)/2;break;case"start":b=-o._textRenderer.height*Math.sin(o._textRenderer.angle)/2;break;case"middle":b=-o.getWidth()/2+o._textRenderer.height*Math.sin(-o._textRenderer.angle)/2;break;default:b=-o.getWidth()/2+o._textRenderer.height*Math.sin(-o._textRenderer.angle)/2;break}}else{b=-o.getWidth()/2}var D=this.u2p(o.value)+b+"px";o._elem.css("left",D);o.pack()}}var z=["bottom",0];if(q){var m=this._label._elem.outerWidth(true);this._label._elem.css("left",l+g/2-m/2+"px");if(this.name=="xaxis"){this._label._elem.css("bottom","0px");z=["bottom",this._label._elem.outerHeight(true)]}else{this._label._elem.css("top","0px");z=["top",this._label._elem.outerHeight(true)]}this._label.pack()}var d=parseInt(this._ticks.length/this.groups,10);for(x=0;x<this._groupLabels.length;x++){var B=0;var f=0;for(var u=x*d;u<=(x+1)*d;u++){if(this._ticks[u]._elem&&this._ticks[u].label!=" "){var o=this._ticks[u]._elem;var r=o.position();B+=r.left+o.outerWidth(true)/2;f++}}B=B/f;this._groupLabels[x].css({left:(B-this._groupLabels[x].outerWidth(true)/2)});this._groupLabels[x].css(z[0],z[1])}}else{for(x=0;x<C.length;x++){var o=C[x];if(o.show&&o.showLabel){var b;if(o.constructor==a.jqplot.CanvasAxisTickRenderer&&o.angle){var A=(this.name=="yaxis")?1:-1;switch(o.labelPosition){case"auto":case"end":if(A*o.angle<0){b=-o._textRenderer.height*Math.cos(-o._textRenderer.angle)/2}else{b=-o.getHeight()+o._textRenderer.height*Math.cos(o._textRenderer.angle)/2}break;case"start":if(o.angle>0){b=-o._textRenderer.height*Math.cos(-o._textRenderer.angle)/2}else{b=-o.getHeight()+o._textRenderer.height*Math.cos(o._textRenderer.angle)/2}break;case"middle":b=-o.getHeight()/2;break;default:b=-o.getHeight()/2;break}}else{b=-o.getHeight()/2}var D=this.u2p(o.value)+b+"px";o._elem.css("top",D);o.pack()}}var z=["left",0];if(q){var y=this._label._elem.outerHeight(true);this._label._elem.css("top",n-g/2-y/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px");z=["left",this._label._elem.outerWidth(true)]}else{this._label._elem.css("right","0px");z=["right",this._label._elem.outerWidth(true)]}this._label.pack()}var d=parseInt(this._ticks.length/this.groups,10);for(x=0;x<this._groupLabels.length;x++){var B=0;var f=0;for(var u=x*d;u<=(x+1)*d;u++){if(this._ticks[u]._elem&&this._ticks[u].label!=" "){var o=this._ticks[u]._elem;var r=o.position();B+=r.top+o.outerHeight()/2;f++}}B=B/f;this._groupLabels[x].css({top:B-this._groupLabels[x].outerHeight()/2});this._groupLabels[x].css(z[0],z[1])}}}}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ciParser.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ciParser.js
deleted file mode 100644
index 8b42501..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ciParser.js
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-     * Class: $.jqplot.ciParser
-     * Data Renderer function which converts a custom JSON data object into jqPlot data format.
-     * Set this as a callable on the jqplot dataRenderer plot option:
-     * 
-     * > plot = $.jqplot('mychart', [data], { dataRenderer: $.jqplot.ciParser, ... });
-     * 
-     * Where data is an object in JSON format or a JSON encoded string conforming to the
-     * City Index API spec.
-     * 
-     * Note that calling the renderer function is handled internally by jqPlot.  The
-     * user does not have to call the function.  The parameters described below will
-     * automatically be passed to the ciParser function.
-     * 
-     * Parameters:
-     * data - JSON encoded string or object.
-     * plot - reference to jqPlot Plot object.
-     * 
-     * Returns:
-     * data array in jqPlot format.
-     * 
-     */
-    $.jqplot.ciParser = function (data, plot) {
-        var ret = [],
-            line,
-			temp,
-            i, j, k, kk;
-    
-         if (typeof(data) == "string") {
-             data =  $.jqplot.JSON.parse(data, handleStrings);
-         }
- 
-         else if (typeof(data) == "object") {
-             for (k in data) {
-                 for (i=0; i<data[k].length; i++) {
-                     for (kk in data[k][i]) {
-                         data[k][i][kk] = handleStrings(kk, data[k][i][kk]);
-                     }
-                 }
-             }
-         }
- 
-         else {
-             return null;
-         }
- 
-         // function handleStrings
-         // Checks any JSON encoded strings to see if they are
-         // encoded dates.  If so, pull out the timestamp.
-         // Expects dates to be represented by js timestamps.
- 
-         function handleStrings(key, value) {
-            var a;
-            if (value != null) {
-                if (value.toString().indexOf('Date') >= 0) {
-                    //here we will try to extract the ticks from the Date string in the "value" fields of JSON returned data
-                    a = /^\/Date\((-?[0-9]+)\)\/$/.exec(value);
-                    if (a) {
-                        return parseInt(a[1], 10);
-                    }
-                }
-                return value;
-            }
-         }
- 
-        for (var prop in data) {
-            line = [];
-            temp = data[prop];
-            switch (prop) {
-                case "PriceTicks":
-                    for (i=0; i<temp.length; i++) {
-                        line.push([temp[i]['TickDate'], temp[i]['Price']]);
-                    }
-                    break;
-                case "PriceBars":
-                    for (i=0; i<temp.length; i++) {
-                        line.push([temp[i]['BarDate'], temp[i]['Open'], temp[i]['High'], temp[i]['Low'], temp[i]['Close']]);
-                    }
-                    break;
-            }
-            ret.push(line);
-        }
-        return ret;
-    };
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ciParser.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ciParser.min.js
deleted file mode 100644
index a638c5d..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ciParser.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.ciParser=function(g,l){var m=[],o,n,h,f,e,c;if(typeof(g)=="string"){g=a.jqplot.JSON.parse(g,d)}else{if(typeof(g)=="object"){for(e in g){for(h=0;h<g[e].length;h++){for(c in g[e][h]){g[e][h][c]=d(c,g[e][h][c])}}}}else{return null}}function d(j,k){var i;if(k!=null){if(k.toString().indexOf("Date")>=0){i=/^\/Date\((-?[0-9]+)\)\/$/.exec(k);if(i){return parseInt(i[1],10)}}return k}}for(var b in g){o=[];n=g[b];switch(b){case"PriceTicks":for(h=0;h<n.length;h++){o.push([n[h]["TickDate"],n[h]["Price"]])}break;case"PriceBars":for(h=0;h<n.length;h++){o.push([n[h]["BarDate"],n[h]["Open"],n[h]["High"],n[h]["Low"],n[h]["Close"]])}break}m.push(o)}return m}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.cursor.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.cursor.js
deleted file mode 100644
index 350d7ca..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.cursor.js
+++ /dev/null
@@ -1,1083 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    
-    /**
-     * Class: $.jqplot.Cursor
-     * Plugin class representing the cursor as displayed on the plot.
-     */
-    $.jqplot.Cursor = function(options) {
-        // Group: Properties
-        //
-        // prop: style
-        // CSS spec for cursor style
-        this.style = 'crosshair';
-        this.previousCursor = 'auto';
-        // prop: show
-        // wether to show the cursor or not.
-        this.show = $.jqplot.config.enablePlugins;
-        // prop: showTooltip
-        // show a cursor position tooltip.  Location of the tooltip
-        // will be controlled by followMouse and tooltipLocation.
-        this.showTooltip = true;
-        // prop: followMouse
-        // Tooltip follows the mouse, it is not at a fixed location.
-        // Tooltip will show on the grid at the location given by
-        // tooltipLocation, offset from the grid edge by tooltipOffset.
-        this.followMouse = false;
-        // prop: tooltipLocation
-        // Where to position tooltip.  If followMouse is true, this is
-        // relative to the cursor, otherwise, it is relative to the grid.
-        // One of 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'
-        this.tooltipLocation = 'se';
-        // prop: tooltipOffset
-        // Pixel offset of tooltip from the grid boudaries or cursor center.
-        this.tooltipOffset = 6;
-        // prop: showTooltipGridPosition
-        // show the grid pixel coordinates of the mouse.
-        this.showTooltipGridPosition = false;
-        // prop: showTooltipUnitPosition
-        // show the unit (data) coordinates of the mouse.
-        this.showTooltipUnitPosition = true;
-        // prop: showTooltipDataPosition
-        // Used with showVerticalLine to show intersecting data points in the tooltip.
-        this.showTooltipDataPosition = false;
-        // prop: tooltipFormatString
-        // sprintf format string for the tooltip.
-        // Uses Ash Searle's javascript sprintf implementation
-        // found here: http://hexmen.com/blog/2007/03/printf-sprintf/
-        // See http://perldoc.perl.org/functions/sprintf.html for reference
-        // Note, if showTooltipDataPosition is true, the default tooltipFormatString
-        // will be set to the cursorLegendFormatString, not the default given here.
-        this.tooltipFormatString = '%.4P, %.4P';
-        // prop: useAxesFormatters
-        // Use the x and y axes formatters to format the text in the tooltip.
-        this.useAxesFormatters = true;
-        // prop: tooltipAxisGroups
-        // Show position for the specified axes.
-        // This is an array like [['xaxis', 'yaxis'], ['xaxis', 'y2axis']]
-        // Default is to compute automatically for all visible axes.
-        this.tooltipAxisGroups = [];
-        // prop: zoom
-        // Enable plot zooming.
-        this.zoom = false;
-        // zoomProxy and zoomTarget properties are not directly set by user.  
-        // They Will be set through call to zoomProxy method.
-        this.zoomProxy = false;
-        this.zoomTarget = false;
-        // prop: looseZoom
-        // Will expand zoom range to provide more rounded tick values.
-        // Works only with linear axes and date axes.
-        this.looseZoom = false;
-        // prop: clickReset
-        // Will reset plot zoom if single click on plot without drag.
-        this.clickReset = false;
-        // prop: dblClickReset
-        // Will reset plot zoom if double click on plot without drag.
-        this.dblClickReset = true;
-        // prop: showVerticalLine
-        // draw a vertical line across the plot which follows the cursor.
-        // When the line is near a data point, a special legend and/or tooltip can
-        // be updated with the data values.
-        this.showVerticalLine = false;
-        // prop: showHorizontalLine
-        // draw a horizontal line across the plot which follows the cursor.
-        this.showHorizontalLine = false;
-        // prop: constrainZoomTo
-        // 'none', 'x' or 'y'
-        this.constrainZoomTo = 'none';
-        // // prop: autoscaleConstraint
-        // // when a constrained axis is specified, true will
-        // // auatoscale the adjacent axis.
-        // this.autoscaleConstraint = true;
-        this.shapeRenderer = new $.jqplot.ShapeRenderer();
-        this._zoom = {start:[], end:[], started: false, zooming:false, isZoomed:false, axes:{start:{}, end:{}}, gridpos:{}, datapos:{}};
-        this._tooltipElem;
-        this.zoomCanvas;
-        this.cursorCanvas;
-        // prop: intersectionThreshold
-        // pixel distance from data point or marker to consider cursor lines intersecting with point.
-        // If data point markers are not shown, this should be >= 1 or will often miss point intersections.
-        this.intersectionThreshold = 2;
-        // prop: showCursorLegend
-        // Replace the plot legend with an enhanced legend displaying intersection information.
-        this.showCursorLegend = false;
-        // prop: cursorLegendFormatString
-        // Format string used in the cursor legend.  If showTooltipDataPosition is true,
-        // this will also be the default format string used by tooltipFormatString.
-        this.cursorLegendFormatString = $.jqplot.Cursor.cursorLegendFormatString;
-        // whether the cursor is over the grid or not.
-        this._oldHandlers = {onselectstart: null, ondrag: null, onmousedown: null};
-        // prop: constrainOutsideZoom
-        // True to limit actual zoom area to edges of grid, even when zooming
-        // outside of plot area.  That is, can't zoom out by mousing outside plot.
-        this.constrainOutsideZoom = true;
-        // prop: showTooltipOutsideZoom
-        // True will keep updating the tooltip when zooming of the grid.
-        this.showTooltipOutsideZoom = false;
-        // true if mouse is over grid, false if not.
-        this.onGrid = false;
-        $.extend(true, this, options);
-    };
-    
-    $.jqplot.Cursor.cursorLegendFormatString = '%s x:%s, y:%s';
-    
-    // called with scope of plot
-    $.jqplot.Cursor.init = function (target, data, opts){
-        // add a cursor attribute to the plot
-        var options = opts || {};
-        this.plugins.cursor = new $.jqplot.Cursor(options.cursor);
-        var c = this.plugins.cursor;
-
-        if (c.show) {
-            $.jqplot.eventListenerHooks.push(['jqplotMouseEnter', handleMouseEnter]);
-            $.jqplot.eventListenerHooks.push(['jqplotMouseLeave', handleMouseLeave]);
-            $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMouseMove]);
-            
-            if (c.showCursorLegend) {              
-                opts.legend = opts.legend || {};
-                opts.legend.renderer =  $.jqplot.CursorLegendRenderer;
-                opts.legend.formatString = this.plugins.cursor.cursorLegendFormatString;
-                opts.legend.show = true;
-            }
-            
-            if (c.zoom) {
-                $.jqplot.eventListenerHooks.push(['jqplotMouseDown', handleMouseDown]);
-                
-                if (c.clickReset) {
-                    $.jqplot.eventListenerHooks.push(['jqplotClick', handleClick]);
-                }
-                
-                if (c.dblClickReset) {
-                    $.jqplot.eventListenerHooks.push(['jqplotDblClick', handleDblClick]);
-                }             
-            }
-    
-            this.resetZoom = function() {
-                var axes = this.axes;
-                if (!c.zoomProxy) {
-                    for (var ax in axes) {
-                        axes[ax].reset();
-                        axes[ax]._ticks = [];
-                        // fake out tick creation algorithm to make sure original auto
-                        // computed format string is used if _overrideFormatString is true
-                        if (c._zoom.axes[ax] !== undefined) {
-                            axes[ax]._autoFormatString = c._zoom.axes[ax].tickFormatString;
-                        }
-                    }
-                    this.redraw();
-                }
-                else {
-                    var ctx = this.plugins.cursor.zoomCanvas._ctx;
-                    ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height);
-                    ctx = null;
-                }
-                this.plugins.cursor._zoom.isZoomed = false;
-                this.target.trigger('jqplotResetZoom', [this, this.plugins.cursor]);
-            };
-            
-
-            if (c.showTooltipDataPosition) {
-                c.showTooltipUnitPosition = false;
-                c.showTooltipGridPosition = false;
-                if (options.cursor.tooltipFormatString == undefined) {
-                    c.tooltipFormatString = $.jqplot.Cursor.cursorLegendFormatString;
-                }
-            }
-        }
-    };
-    
-    // called with context of plot
-    $.jqplot.Cursor.postDraw = function() {
-        var c = this.plugins.cursor;
-        
-        // Memory Leaks patch
-        if (c.zoomCanvas) {
-            c.zoomCanvas.resetCanvas();
-            c.zoomCanvas = null;
-        }
-        
-        if (c.cursorCanvas) {
-            c.cursorCanvas.resetCanvas();
-            c.cursorCanvas = null;
-        }
-        
-        if (c._tooltipElem) {
-            c._tooltipElem.emptyForce();
-            c._tooltipElem = null;
-        }
-
-        
-        if (c.zoom) {
-            c.zoomCanvas = new $.jqplot.GenericCanvas();
-            this.eventCanvas._elem.before(c.zoomCanvas.createElement(this._gridPadding, 'jqplot-zoom-canvas', this._plotDimensions, this));
-            c.zoomCanvas.setContext();
-        }
-
-        var elem = document.createElement('div');
-        c._tooltipElem = $(elem);
-        elem = null;
-        c._tooltipElem.addClass('jqplot-cursor-tooltip');
-        c._tooltipElem.css({position:'absolute', display:'none'});
-        
-        
-        if (c.zoomCanvas) {
-            c.zoomCanvas._elem.before(c._tooltipElem);
-        }
-
-        else {
-            this.eventCanvas._elem.before(c._tooltipElem);
-        }
-
-        if (c.showVerticalLine || c.showHorizontalLine) {
-            c.cursorCanvas = new $.jqplot.GenericCanvas();
-            this.eventCanvas._elem.before(c.cursorCanvas.createElement(this._gridPadding, 'jqplot-cursor-canvas', this._plotDimensions, this));
-            c.cursorCanvas.setContext();
-        }
-
-        // if we are showing the positions in unit coordinates, and no axes groups
-        // were specified, create a default set.
-        if (c.showTooltipUnitPosition){
-            if (c.tooltipAxisGroups.length === 0) {
-                var series = this.series;
-                var s;
-                var temp = [];
-                for (var i=0; i<series.length; i++) {
-                    s = series[i];
-                    var ax = s.xaxis+','+s.yaxis;
-                    if ($.inArray(ax, temp) == -1) {
-                        temp.push(ax);
-                    }
-                }
-                for (var i=0; i<temp.length; i++) {
-                    c.tooltipAxisGroups.push(temp[i].split(','));
-                }
-            }
-        }
-    };
-    
-    // Group: methods
-    //
-    // method: $.jqplot.Cursor.zoomProxy
-    // links targetPlot to controllerPlot so that plot zooming of
-    // targetPlot will be controlled by zooming on the controllerPlot.
-    // controllerPlot will not actually zoom, but acts as an
-    // overview plot.  Note, the zoom options must be set to true for
-    // zoomProxy to work.
-    $.jqplot.Cursor.zoomProxy = function(targetPlot, controllerPlot) {
-        var tc = targetPlot.plugins.cursor;
-        var cc = controllerPlot.plugins.cursor;
-        tc.zoomTarget = true;
-        tc.zoom = true;
-        tc.style = 'auto';
-        tc.dblClickReset = false;
-        cc.zoom = true;
-        cc.zoomProxy = true;
-              
-        controllerPlot.target.bind('jqplotZoom', plotZoom);
-        controllerPlot.target.bind('jqplotResetZoom', plotReset);
-
-        function plotZoom(ev, gridpos, datapos, plot, cursor) {
-            tc.doZoom(gridpos, datapos, targetPlot, cursor);
-        } 
-
-        function plotReset(ev, plot, cursor) {
-            targetPlot.resetZoom();
-        }
-    };
-    
-    $.jqplot.Cursor.prototype.resetZoom = function(plot, cursor) {
-        var axes = plot.axes;
-        var cax = cursor._zoom.axes;
-        if (!plot.plugins.cursor.zoomProxy && cursor._zoom.isZoomed) {
-            for (var ax in axes) {
-                // axes[ax]._ticks = [];
-                // axes[ax].min = cax[ax].min;
-                // axes[ax].max = cax[ax].max;
-                // axes[ax].numberTicks = cax[ax].numberTicks; 
-                // axes[ax].tickInterval = cax[ax].tickInterval;
-                // // for date axes
-                // axes[ax].daTickInterval = cax[ax].daTickInterval;
-                axes[ax].reset();
-                axes[ax]._ticks = [];
-                // fake out tick creation algorithm to make sure original auto
-                // computed format string is used if _overrideFormatString is true
-                axes[ax]._autoFormatString = cax[ax].tickFormatString;
-            }
-            plot.redraw();
-            cursor._zoom.isZoomed = false;
-        }
-        else {
-            var ctx = cursor.zoomCanvas._ctx;
-            ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height);
-            ctx = null;
-        }
-        plot.target.trigger('jqplotResetZoom', [plot, cursor]);
-    };
-    
-    $.jqplot.Cursor.resetZoom = function(plot) {
-        plot.resetZoom();
-    };
-    
-    $.jqplot.Cursor.prototype.doZoom = function (gridpos, datapos, plot, cursor) {
-        var c = cursor;
-        var axes = plot.axes;
-        var zaxes = c._zoom.axes;
-        var start = zaxes.start;
-        var end = zaxes.end;
-        var min, max, dp, span;
-        var ctx = plot.plugins.cursor.zoomCanvas._ctx;
-        // don't zoom if zoom area is too small (in pixels)
-        if ((c.constrainZoomTo == 'none' && Math.abs(gridpos.x - c._zoom.start[0]) > 6 && Math.abs(gridpos.y - c._zoom.start[1]) > 6) || (c.constrainZoomTo == 'x' && Math.abs(gridpos.x - c._zoom.start[0]) > 6) ||  (c.constrainZoomTo == 'y' && Math.abs(gridpos.y - c._zoom.start[1]) > 6)) {
-            if (!plot.plugins.cursor.zoomProxy) {
-                for (var ax in datapos) {
-                    // make a copy of the original axes to revert back.
-                    if (c._zoom.axes[ax] == undefined) {
-                        c._zoom.axes[ax] = {};
-                        c._zoom.axes[ax].numberTicks = axes[ax].numberTicks;
-                        c._zoom.axes[ax].tickInterval = axes[ax].tickInterval;
-                        // for date axes...
-                        c._zoom.axes[ax].daTickInterval = axes[ax].daTickInterval;
-                        c._zoom.axes[ax].min = axes[ax].min;
-                        c._zoom.axes[ax].max = axes[ax].max;
-                        c._zoom.axes[ax].tickFormatString = (axes[ax].tickOptions != null) ? axes[ax].tickOptions.formatString :  '';
-                    }
-
-
-                    if ((c.constrainZoomTo == 'none') || (c.constrainZoomTo == 'x' && ax.charAt(0) == 'x') || (c.constrainZoomTo == 'y' && ax.charAt(0) == 'y')) {   
-                        dp = datapos[ax];
-                        if (dp != null) {  
-                            var newmin, newmax;         
-                            if (dp > start[ax]) { 
-                                newmin = start[ax];
-                                newmax = dp;
-                            }
-                            else {
-                                span = start[ax] - dp;
-                                newmin = dp;
-                                newmax = start[ax];
-                            }
-
-                            var curax = axes[ax];
-
-                            var _numberTicks = null;
-
-                            // if aligning this axis, use number of ticks from previous axis.
-                            // Do I need to reset somehow if alignTicks is changed and then graph is replotted??
-                            if (curax.alignTicks) {
-                                if (curax.name === 'x2axis' && plot.axes.xaxis.show) {
-                                    _numberTicks = plot.axes.xaxis.numberTicks;
-                                }
-                                else if (curax.name.charAt(0) === 'y' && curax.name !== 'yaxis' && curax.name !== 'yMidAxis' && plot.axes.yaxis.show) {
-                                    _numberTicks = plot.axes.yaxis.numberTicks;
-                                }
-                            }
-                            
-                            if (this.looseZoom && (axes[ax].renderer.constructor === $.jqplot.LinearAxisRenderer || axes[ax].renderer.constructor === $.jqplot.DateAxisRenderer)) {
-                                var ret = $.jqplot.LinearTickGenerator(newmin, newmax, curax._scalefact, _numberTicks);
-
-                                // if new minimum is less than "true" minimum of axis display, adjust it
-                                if (axes[ax].tickInset && ret[0] < axes[ax].min + axes[ax].tickInset * axes[ax].tickInterval) {
-                                    ret[0] += ret[4];
-                                    ret[2] -= 1;
-                                }
-
-                                // if new maximum is greater than "true" max of axis display, adjust it
-                                if (axes[ax].tickInset && ret[1] > axes[ax].max - axes[ax].tickInset * axes[ax].tickInterval) {
-                                    ret[1] -= ret[4];
-                                    ret[2] -= 1;
-                                }
-                                axes[ax].min = ret[0];
-                                axes[ax].max = ret[1];
-                                axes[ax]._autoFormatString = ret[3];
-                                axes[ax].numberTicks = ret[2];
-                                axes[ax].tickInterval = ret[4];
-                                // for date axes...
-                                axes[ax].daTickInterval = [ret[4]/1000, 'seconds'];
-                            }
-                            else {
-                                axes[ax].min = newmin;
-                                axes[ax].max = newmax;
-                                axes[ax].tickInterval = null;
-                                // for date axes...
-                                axes[ax].daTickInterval = null;
-                            }
-
-                            axes[ax]._ticks = [];
-                        }
-                    }
-                            
-                    // if ((c.constrainZoomTo == 'x' && ax.charAt(0) == 'y' && c.autoscaleConstraint) || (c.constrainZoomTo == 'y' && ax.charAt(0) == 'x' && c.autoscaleConstraint)) {
-                    //     dp = datapos[ax];
-                    //     if (dp != null) {
-                    //         axes[ax].max == null;
-                    //         axes[ax].min = null;
-                    //     }
-                    // }
-                }
-                ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height);
-                plot.redraw();
-                c._zoom.isZoomed = true;
-                ctx = null;
-            }
-            plot.target.trigger('jqplotZoom', [gridpos, datapos, plot, cursor]);
-        }
-    };
-    
-    $.jqplot.preInitHooks.push($.jqplot.Cursor.init);
-    $.jqplot.postDrawHooks.push($.jqplot.Cursor.postDraw);
-    
-    function updateTooltip(gridpos, datapos, plot) {
-        var c = plot.plugins.cursor;
-        var s = '';
-        var addbr = false;
-        if (c.showTooltipGridPosition) {
-            s = gridpos.x+', '+gridpos.y;
-            addbr = true;
-        }
-        if (c.showTooltipUnitPosition) {
-            var g;
-            for (var i=0; i<c.tooltipAxisGroups.length; i++) {
-                g = c.tooltipAxisGroups[i];
-                if (addbr) {
-                    s += '<br />';
-                }
-                if (c.useAxesFormatters) {
-                    var xf = plot.axes[g[0]]._ticks[0].formatter;
-                    var yf = plot.axes[g[1]]._ticks[0].formatter;
-                    var xfstr = plot.axes[g[0]]._ticks[0].formatString;
-                    var yfstr = plot.axes[g[1]]._ticks[0].formatString;
-                    s += xf(xfstr, datapos[g[0]]) + ', '+ yf(yfstr, datapos[g[1]]);
-                }
-                else {
-                    s += $.jqplot.sprintf(c.tooltipFormatString, datapos[g[0]], datapos[g[1]]);
-                }
-                addbr = true;
-            }
-        }
-        
-        if (c.showTooltipDataPosition) {
-            var series = plot.series; 
-            var ret = getIntersectingPoints(plot, gridpos.x, gridpos.y);
-            var addbr = false;
-        
-            for (var i = 0; i< series.length; i++) {
-                if (series[i].show) {
-                    var idx = series[i].index;
-                    var label = series[i].label.toString();
-                    var cellid = $.inArray(idx, ret.indices);
-                    var sx = undefined;
-                    var sy = undefined;
-                    if (cellid != -1) {
-                        var data = ret.data[cellid].data;
-                        if (c.useAxesFormatters) {
-                            var xf = series[i]._xaxis._ticks[0].formatter;
-                            var yf = series[i]._yaxis._ticks[0].formatter;
-                            var xfstr = series[i]._xaxis._ticks[0].formatString;
-                            var yfstr = series[i]._yaxis._ticks[0].formatString;
-                            sx = xf(xfstr, data[0]);
-                            sy = yf(yfstr, data[1]);
-                        }
-                        else {
-                            sx = data[0];
-                            sy = data[1];
-                        }
-                        if (addbr) {
-                            s += '<br />';
-                        }
-                        s += $.jqplot.sprintf(c.tooltipFormatString, label, sx, sy);
-                        addbr = true;
-                    }
-                }
-            }
-            
-        }
-        c._tooltipElem.html(s);
-    }
-    
-    function moveLine(gridpos, plot) {
-        var c = plot.plugins.cursor;
-        var ctx = c.cursorCanvas._ctx;
-        ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height);
-        if (c.showVerticalLine) {
-            c.shapeRenderer.draw(ctx, [[gridpos.x, 0], [gridpos.x, ctx.canvas.height]]);
-        }
-        if (c.showHorizontalLine) {
-            c.shapeRenderer.draw(ctx, [[0, gridpos.y], [ctx.canvas.width, gridpos.y]]);
-        }
-        var ret = getIntersectingPoints(plot, gridpos.x, gridpos.y);
-        if (c.showCursorLegend) {
-            var cells = $(plot.targetId + ' td.jqplot-cursor-legend-label');
-            for (var i=0; i<cells.length; i++) {
-                var idx = $(cells[i]).data('seriesIndex');
-                var series = plot.series[idx];
-                var label = series.label.toString();
-                var cellid = $.inArray(idx, ret.indices);
-                var sx = undefined;
-                var sy = undefined;
-                if (cellid != -1) {
-                    var data = ret.data[cellid].data;
-                    if (c.useAxesFormatters) {
-                        var xf = series._xaxis._ticks[0].formatter;
-                        var yf = series._yaxis._ticks[0].formatter;
-                        var xfstr = series._xaxis._ticks[0].formatString;
-                        var yfstr = series._yaxis._ticks[0].formatString;
-                        sx = xf(xfstr, data[0]);
-                        sy = yf(yfstr, data[1]);
-                    }
-                    else {
-                        sx = data[0];
-                        sy = data[1];
-                    }
-                }
-                if (plot.legend.escapeHtml) {
-                    $(cells[i]).text($.jqplot.sprintf(c.cursorLegendFormatString, label, sx, sy));
-                }
-                else {
-                    $(cells[i]).html($.jqplot.sprintf(c.cursorLegendFormatString, label, sx, sy));
-                }
-            }        
-        }
-        ctx = null;
-    }
-        
-    function getIntersectingPoints(plot, x, y) {
-        var ret = {indices:[], data:[]};
-        var s, i, d0, d, j, r, p;
-        var threshold;
-        var c = plot.plugins.cursor;
-        for (var i=0; i<plot.series.length; i++) {
-            s = plot.series[i];
-            r = s.renderer;
-            if (s.show) {
-                threshold = c.intersectionThreshold;
-                if (s.showMarker) {
-                    threshold += s.markerRenderer.size/2;
-                }
-                for (var j=0; j<s.gridData.length; j++) {
-                    p = s.gridData[j];
-                    // check vertical line
-                    if (c.showVerticalLine) {
-                        if (Math.abs(x-p[0]) <= threshold) {
-                            ret.indices.push(i);
-                            ret.data.push({seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]});
-                        }
-                    }
-                } 
-            }
-        }
-        return ret;
-    }
-    
-    function moveTooltip(gridpos, plot) {
-        var c = plot.plugins.cursor;  
-        var elem = c._tooltipElem;
-        switch (c.tooltipLocation) {
-            case 'nw':
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - c.tooltipOffset;
-                var y = gridpos.y + plot._gridPadding.top - c.tooltipOffset - elem.outerHeight(true);
-                break;
-            case 'n':
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2;
-                var y = gridpos.y + plot._gridPadding.top - c.tooltipOffset - elem.outerHeight(true);
-                break;
-            case 'ne':
-                var x = gridpos.x + plot._gridPadding.left + c.tooltipOffset;
-                var y = gridpos.y + plot._gridPadding.top - c.tooltipOffset - elem.outerHeight(true);
-                break;
-            case 'e':
-                var x = gridpos.x + plot._gridPadding.left + c.tooltipOffset;
-                var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2;
-                break;
-            case 'se':
-                var x = gridpos.x + plot._gridPadding.left + c.tooltipOffset;
-                var y = gridpos.y + plot._gridPadding.top + c.tooltipOffset;
-                break;
-            case 's':
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2;
-                var y = gridpos.y + plot._gridPadding.top + c.tooltipOffset;
-                break;
-            case 'sw':
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - c.tooltipOffset;
-                var y = gridpos.y + plot._gridPadding.top + c.tooltipOffset;
-                break;
-            case 'w':
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - c.tooltipOffset;
-                var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2;
-                break;
-            default:
-                var x = gridpos.x + plot._gridPadding.left + c.tooltipOffset;
-                var y = gridpos.y + plot._gridPadding.top + c.tooltipOffset;
-                break;
-        }
-            
-        elem.css('left', x);
-        elem.css('top', y);
-	    elem = null;
-    }
-    
-    function positionTooltip(plot) { 
-        // fake a grid for positioning
-        var grid = plot._gridPadding; 
-        var c = plot.plugins.cursor;
-        var elem = c._tooltipElem;  
-        switch (c.tooltipLocation) {
-            case 'nw':
-                var a = grid.left + c.tooltipOffset;
-                var b = grid.top + c.tooltipOffset;
-                elem.css('left', a);
-                elem.css('top', b);
-                break;
-            case 'n':
-                var a = (grid.left + (plot._plotDimensions.width - grid.right))/2 - elem.outerWidth(true)/2;
-                var b = grid.top + c.tooltipOffset;
-                elem.css('left', a);
-                elem.css('top', b);
-                break;
-            case 'ne':
-                var a = grid.right + c.tooltipOffset;
-                var b = grid.top + c.tooltipOffset;
-                elem.css({right:a, top:b});
-                break;
-            case 'e':
-                var a = grid.right + c.tooltipOffset;
-                var b = (grid.top + (plot._plotDimensions.height - grid.bottom))/2 - elem.outerHeight(true)/2;
-                elem.css({right:a, top:b});
-                break;
-            case 'se':
-                var a = grid.right + c.tooltipOffset;
-                var b = grid.bottom + c.tooltipOffset;
-                elem.css({right:a, bottom:b});
-                break;
-            case 's':
-                var a = (grid.left + (plot._plotDimensions.width - grid.right))/2 - elem.outerWidth(true)/2;
-                var b = grid.bottom + c.tooltipOffset;
-                elem.css({left:a, bottom:b});
-                break;
-            case 'sw':
-                var a = grid.left + c.tooltipOffset;
-                var b = grid.bottom + c.tooltipOffset;
-                elem.css({left:a, bottom:b});
-                break;
-            case 'w':
-                var a = grid.left + c.tooltipOffset;
-                var b = (grid.top + (plot._plotDimensions.height - grid.bottom))/2 - elem.outerHeight(true)/2;
-                elem.css({left:a, top:b});
-                break;
-            default:  // same as 'se'
-                var a = grid.right - c.tooltipOffset;
-                var b = grid.bottom + c.tooltipOffset;
-                elem.css({right:a, bottom:b});
-                break;
-        }
-        elem = null;
-    }
-    
-    function handleClick (ev, gridpos, datapos, neighbor, plot) {
-        ev.preventDefault();
-        ev.stopImmediatePropagation();
-        var c = plot.plugins.cursor;
-        if (c.clickReset) {
-            c.resetZoom(plot, c);
-        }
-        var sel = window.getSelection;
-        if (document.selection && document.selection.empty)
-        {
-            document.selection.empty();
-        }
-        else if (sel && !sel().isCollapsed) {
-            sel().collapse();
-        }
-        return false;
-    }
-    
-    function handleDblClick (ev, gridpos, datapos, neighbor, plot) {
-        ev.preventDefault();
-        ev.stopImmediatePropagation();
-        var c = plot.plugins.cursor;
-        if (c.dblClickReset) {
-            c.resetZoom(plot, c);
-        }
-        var sel = window.getSelection;
-        if (document.selection && document.selection.empty)
-        {
-            document.selection.empty();
-        }
-        else if (sel && !sel().isCollapsed) {
-            sel().collapse();
-        }
-        return false;
-    }
-    
-    function handleMouseLeave(ev, gridpos, datapos, neighbor, plot) {
-        var c = plot.plugins.cursor;
-        c.onGrid = false;
-        if (c.show) {
-            $(ev.target).css('cursor', c.previousCursor);
-            if (c.showTooltip && !(c._zoom.zooming && c.showTooltipOutsideZoom && !c.constrainOutsideZoom)) {
-                c._tooltipElem.hide();
-            }
-            if (c.zoom) {
-                c._zoom.gridpos = gridpos;
-                c._zoom.datapos = datapos;
-            }
-            if (c.showVerticalLine || c.showHorizontalLine) {
-                var ctx = c.cursorCanvas._ctx;
-                ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height);
-                ctx = null;
-            }
-            if (c.showCursorLegend) {
-                var cells = $(plot.targetId + ' td.jqplot-cursor-legend-label');
-                for (var i=0; i<cells.length; i++) {
-                    var idx = $(cells[i]).data('seriesIndex');
-                    var series = plot.series[idx];
-                    var label = series.label.toString();
-                    if (plot.legend.escapeHtml) {
-                        $(cells[i]).text($.jqplot.sprintf(c.cursorLegendFormatString, label, undefined, undefined));
-                    }
-                    else {
-                        $(cells[i]).html($.jqplot.sprintf(c.cursorLegendFormatString, label, undefined, undefined));
-                    }
-                
-                }        
-            }
-        }
-    }
-    
-    function handleMouseEnter(ev, gridpos, datapos, neighbor, plot) {
-        var c = plot.plugins.cursor;
-        c.onGrid = true;
-        if (c.show) {
-            c.previousCursor = ev.target.style.cursor;
-            ev.target.style.cursor = c.style;
-            if (c.showTooltip) {
-                updateTooltip(gridpos, datapos, plot);
-                if (c.followMouse) {
-                    moveTooltip(gridpos, plot);
-                }
-                else {
-                    positionTooltip(plot);
-                }
-                c._tooltipElem.show();
-            }
-            if (c.showVerticalLine || c.showHorizontalLine) {
-                moveLine(gridpos, plot);
-            }
-        }
-
-    }    
-    
-    function handleMouseMove(ev, gridpos, datapos, neighbor, plot) {
-        var c = plot.plugins.cursor;
-        if (c.show) {
-            if (c.showTooltip) {
-                updateTooltip(gridpos, datapos, plot);
-                if (c.followMouse) {
-                    moveTooltip(gridpos, plot);
-                }
-            }
-            if (c.showVerticalLine || c.showHorizontalLine) {
-                moveLine(gridpos, plot);
-            }
-        }
-    }
-            
-    function getEventPosition(ev) {
-        var plot = ev.data.plot;
-        var go = plot.eventCanvas._elem.offset();
-        var gridPos = {x:ev.pageX - go.left, y:ev.pageY - go.top};
-        //////
-        // TO DO: handle yMidAxis
-        //////
-        var dataPos = {xaxis:null, yaxis:null, x2axis:null, y2axis:null, y3axis:null, y4axis:null, y5axis:null, y6axis:null, y7axis:null, y8axis:null, y9axis:null, yMidAxis:null};
-        var an = ['xaxis', 'yaxis', 'x2axis', 'y2axis', 'y3axis', 'y4axis', 'y5axis', 'y6axis', 'y7axis', 'y8axis', 'y9axis', 'yMidAxis'];
-        var ax = plot.axes;
-        var n, axis;
-        for (n=11; n>0; n--) {
-            axis = an[n-1];
-            if (ax[axis].show) {
-                dataPos[axis] = ax[axis].series_p2u(gridPos[axis.charAt(0)]);
-            }
-        }
-
-        return {offsets:go, gridPos:gridPos, dataPos:dataPos};
-    }    
-    
-    function handleZoomMove(ev) {
-        var plot = ev.data.plot;
-        var c = plot.plugins.cursor;
-        // don't do anything if not on grid.
-        if (c.show && c.zoom && c._zoom.started && !c.zoomTarget) {
-            var ctx = c.zoomCanvas._ctx;
-            var positions = getEventPosition(ev);
-            var gridpos = positions.gridPos;
-            var datapos = positions.dataPos;
-            c._zoom.gridpos = gridpos;
-            c._zoom.datapos = datapos;
-            c._zoom.zooming = true;
-            var xpos = gridpos.x;
-            var ypos = gridpos.y;
-            var height = ctx.canvas.height;
-            var width = ctx.canvas.width;
-            if (c.showTooltip && !c.onGrid && c.showTooltipOutsideZoom) {
-                updateTooltip(gridpos, datapos, plot);
-                if (c.followMouse) {
-                    moveTooltip(gridpos, plot);
-                }
-            }
-            if (c.constrainZoomTo == 'x') {
-                c._zoom.end = [xpos, height];
-            }
-            else if (c.constrainZoomTo == 'y') {
-                c._zoom.end = [width, ypos];
-            }
-            else {
-                c._zoom.end = [xpos, ypos];
-            }
-            var sel = window.getSelection;
-            if (document.selection && document.selection.empty)
-            {
-                document.selection.empty();
-            }
-            else if (sel && !sel().isCollapsed) {
-                sel().collapse();
-            }
-            drawZoomBox.call(c);
-            ctx = null;
-        }
-    }
-    
-    function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
-        var c = plot.plugins.cursor;
-        $(document).one('mouseup.jqplot_cursor', {plot:plot}, handleMouseUp);
-        var axes = plot.axes;
-        if (document.onselectstart != undefined) {
-            c._oldHandlers.onselectstart = document.onselectstart;
-            document.onselectstart = function () { return false; };
-        }
-        if (document.ondrag != undefined) {
-            c._oldHandlers.ondrag = document.ondrag;
-            document.ondrag = function () { return false; };
-        }
-        if (document.onmousedown != undefined) {
-            c._oldHandlers.onmousedown = document.onmousedown;
-            document.onmousedown = function () { return false; };
-        }
-        if (c.zoom) {
-            if (!c.zoomProxy) {
-                var ctx = c.zoomCanvas._ctx;
-                ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height);
-                ctx = null;
-            }
-            if (c.constrainZoomTo == 'x') {
-                c._zoom.start = [gridpos.x, 0];
-            }
-            else if (c.constrainZoomTo == 'y') {
-                c._zoom.start = [0, gridpos.y];
-            }
-            else {
-                c._zoom.start = [gridpos.x, gridpos.y];
-            }
-            c._zoom.started = true;
-            for (var ax in datapos) {
-                // get zoom starting position.
-                c._zoom.axes.start[ax] = datapos[ax];
-            }  
-            $(document).bind('mousemove.jqplotCursor', {plot:plot}, handleZoomMove);              
-        }
-    }
-    
-    function handleMouseUp(ev) {
-        var plot = ev.data.plot;
-        var c = plot.plugins.cursor;
-        if (c.zoom && c._zoom.zooming && !c.zoomTarget) {
-            var xpos = c._zoom.gridpos.x;
-            var ypos = c._zoom.gridpos.y;
-            var datapos = c._zoom.datapos;
-            var height = c.zoomCanvas._ctx.canvas.height;
-            var width = c.zoomCanvas._ctx.canvas.width;
-            var axes = plot.axes;
-            
-            if (c.constrainOutsideZoom && !c.onGrid) {
-                if (xpos < 0) { xpos = 0; }
-                else if (xpos > width) { xpos = width; }
-                if (ypos < 0) { ypos = 0; }
-                else if (ypos > height) { ypos = height; }
-                
-                for (var axis in datapos) {
-                    if (datapos[axis]) {
-                        if (axis.charAt(0) == 'x') {
-                            datapos[axis] = axes[axis].series_p2u(xpos);
-                        }
-                        else {
-                            datapos[axis] = axes[axis].series_p2u(ypos);
-                        }
-                    }
-                }
-            }
-            
-            if (c.constrainZoomTo == 'x') {
-                ypos = height;
-            }
-            else if (c.constrainZoomTo == 'y') {
-                xpos = width;
-            }
-            c._zoom.end = [xpos, ypos];
-            c._zoom.gridpos = {x:xpos, y:ypos};
-            
-            c.doZoom(c._zoom.gridpos, datapos, plot, c);
-        }
-        c._zoom.started = false;
-        c._zoom.zooming = false;
-        
-        $(document).unbind('mousemove.jqplotCursor', handleZoomMove);
-        
-        if (document.onselectstart != undefined && c._oldHandlers.onselectstart != null){
-            document.onselectstart = c._oldHandlers.onselectstart;
-            c._oldHandlers.onselectstart = null;
-        }
-        if (document.ondrag != undefined && c._oldHandlers.ondrag != null){
-            document.ondrag = c._oldHandlers.ondrag;
-            c._oldHandlers.ondrag = null;
-        }
-        if (document.onmousedown != undefined && c._oldHandlers.onmousedown != null){
-            document.onmousedown = c._oldHandlers.onmousedown;
-            c._oldHandlers.onmousedown = null;
-        }
-
-    }
-    
-    function drawZoomBox() {
-        var start = this._zoom.start;
-        var end = this._zoom.end;
-        var ctx = this.zoomCanvas._ctx;
-        var l, t, h, w;
-        if (end[0] > start[0]) {
-            l = start[0];
-            w = end[0] - start[0];
-        }
-        else {
-            l = end[0];
-            w = start[0] - end[0];
-        }
-        if (end[1] > start[1]) {
-            t = start[1];
-            h = end[1] - start[1];
-        }
-        else {
-            t = end[1];
-            h = start[1] - end[1];
-        }
-        ctx.fillStyle = 'rgba(0,0,0,0.2)';
-        ctx.strokeStyle = '#999999';
-        ctx.lineWidth = 1.0;
-        ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height);
-        ctx.fillRect(0,0,ctx.canvas.width, ctx.canvas.height);
-        ctx.clearRect(l, t, w, h);
-        // IE won't show transparent fill rect, so stroke a rect also.
-        ctx.strokeRect(l,t,w,h);
-        ctx = null;
-    }
-    
-    $.jqplot.CursorLegendRenderer = function(options) {
-        $.jqplot.TableLegendRenderer.call(this, options);
-        this.formatString = '%s';
-    };
-    
-    $.jqplot.CursorLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
-    $.jqplot.CursorLegendRenderer.prototype.constructor = $.jqplot.CursorLegendRenderer;
-    
-    // called in context of a Legend
-    $.jqplot.CursorLegendRenderer.prototype.draw = function() {
-        if (this._elem) {
-            this._elem.emptyForce();
-            this._elem = null;
-        }
-        if (this.show) {
-            var series = this._series, s;
-            // make a table.  one line label per row.
-            var elem = document.createElement('div');
-            this._elem = $(elem);
-            elem = null;
-            this._elem.addClass('jqplot-legend jqplot-cursor-legend');
-            this._elem.css('position', 'absolute');
-        
-            var pad = false;
-            for (var i = 0; i< series.length; i++) {
-                s = series[i];
-                if (s.show && s.showLabel) {
-                    var lt = $.jqplot.sprintf(this.formatString, s.label.toString());
-                    if (lt) {
-                        var color = s.color;
-                        if (s._stack && !s.fill) {
-                            color = '';
-                        }
-                        addrow.call(this, lt, color, pad, i);
-                        pad = true;
-                    }
-                    // let plugins add more rows to legend.  Used by trend line plugin.
-                    for (var j=0; j<$.jqplot.addLegendRowHooks.length; j++) {
-                        var item = $.jqplot.addLegendRowHooks[j].call(this, s);
-                        if (item) {
-                            addrow.call(this, item.label, item.color, pad);
-                            pad = true;
-                        } 
-                    }
-                }
-            }
-            series = s = null;
-            delete series;
-            delete s;
-        }
-        
-        function addrow(label, color, pad, idx) {
-            var rs = (pad) ? this.rowSpacing : '0';
-            var tr = $('<tr class="jqplot-legend jqplot-cursor-legend"></tr>').appendTo(this._elem);
-            tr.data('seriesIndex', idx);
-            $('<td class="jqplot-legend jqplot-cursor-legend-swatch" style="padding-top:'+rs+';">'+
-                '<div style="border:1px solid #cccccc;padding:0.2em;">'+
-                '<div class="jqplot-cursor-legend-swatch" style="background-color:'+color+';"></div>'+
-                '</div></td>').appendTo(tr);
-            var td = $('<td class="jqplot-legend jqplot-cursor-legend-label" style="vertical-align:middle;padding-top:'+rs+';"></td>');
-            td.appendTo(tr);
-            td.data('seriesIndex', idx);
-            if (this.escapeHtml) {
-                td.text(label);
-            }
-            else {
-                td.html(label);
-            }
-            tr = null;
-            td = null;
-        }
-        return this._elem;
-    };
-    
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.cursor.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.cursor.min.js
deleted file mode 100644
index 1b5736d..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.cursor.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(j){j.jqplot.Cursor=function(q){this.style="crosshair";this.previousCursor="auto";this.show=j.jqplot.config.enablePlugins;this.showTooltip=true;this.followMouse=false;this.tooltipLocation="se";this.tooltipOffset=6;this.showTooltipGridPosition=false;this.showTooltipUnitPosition=true;this.showTooltipDataPosition=false;this.tooltipFormatString="%.4P, %.4P";this.useAxesFormatters=true;this.tooltipAxisGroups=[];this.zoom=false;this.zoomProxy=false;this.zoomTarget=false;this.looseZoom=false;this.clickReset=false;this.dblClickReset=true;this.showVerticalLine=false;this.showHorizontalLine=false;this.constrainZoomTo="none";this.shapeRenderer=new j.jqplot.ShapeRenderer();this._zoom={start:[],end:[],started:false,zooming:false,isZoomed:false,axes:{start:{},end:{}},gridpos:{},datapos:{}};this._tooltipElem;this.zoomCanvas;this.cursorCanvas;this.intersectionThreshold=2;this.showCursorLegend=false;this.cursorLegendFormatString=j.jqplot.Cursor.cursorLegendFormatString;this._oldHandlers={onselectstart:null,ondrag:null,onmousedown:null};this.constrainOutsideZoom=true;this.showTooltipOutsideZoom=false;this.onGrid=false;j.extend(true,this,q)};j.jqplot.Cursor.cursorLegendFormatString="%s x:%s, y:%s";j.jqplot.Cursor.init=function(t,s,r){var q=r||{};this.plugins.cursor=new j.jqplot.Cursor(q.cursor);var u=this.plugins.cursor;if(u.show){j.jqplot.eventListenerHooks.push(["jqplotMouseEnter",b]);j.jqplot.eventListenerHooks.push(["jqplotMouseLeave",f]);j.jqplot.eventListenerHooks.push(["jqplotMouseMove",i]);if(u.showCursorLegend){r.legend=r.legend||{};r.legend.renderer=j.jqplot.CursorLegendRenderer;r.legend.formatString=this.plugins.cursor.cursorLegendFormatString;r.legend.show=true}if(u.zoom){j.jqplot.eventListenerHooks.push(["jqplotMouseDown",a]);if(u.clickReset){j.jqplot.eventListenerHooks.push(["jqplotClick",k])}if(u.dblClickReset){j.jqplot.eventListenerHooks.push(["jqplotDblClick",c])}}this.resetZoom=function(){var x=this.axes;if(!u.zoomProxy){for(var w in x){x[w].reset();x[w]._ticks=[];if(u._zoom.axes[w]!==undefined){x[w]._autoFormatString=u._zoom.axes[w].tickFormatString}}this.redraw()}else{var v=this.plugins.cursor.zoomCanvas._ctx;v.clearRect(0,0,v.canvas.width,v.canvas.height);v=null}this.plugins.cursor._zoom.isZoomed=false;this.target.trigger("jqplotResetZoom",[this,this.plugins.cursor])};if(u.showTooltipDataPosition){u.showTooltipUnitPosition=false;u.showTooltipGridPosition=false;if(q.cursor.tooltipFormatString==undefined){u.tooltipFormatString=j.jqplot.Cursor.cursorLegendFormatString}}}};j.jqplot.Cursor.postDraw=function(){var x=this.plugins.cursor;if(x.zoomCanvas){x.zoomCanvas.resetCanvas();x.zoomCanvas=null}if(x.cursorCanvas){x.cursorCanvas.resetCanvas();x.cursorCanvas=null}if(x._tooltipElem){x._tooltipElem.emptyForce();x._tooltipElem=null}if(x.zoom){x.zoomCanvas=new j.jqplot.GenericCanvas();this.eventCanvas._elem.before(x.zoomCanvas.createElement(this._gridPadding,"jqplot-zoom-canvas",this._plotDimensions,this));x.zoomCanvas.setContext()}var v=document.createElement("div");x._tooltipElem=j(v);v=null;x._tooltipElem.addClass("jqplot-cursor-tooltip");x._tooltipElem.css({position:"absolute",display:"none"});if(x.zoomCanvas){x.zoomCanvas._elem.before(x._tooltipElem)}else{this.eventCanvas._elem.before(x._tooltipElem)}if(x.showVerticalLine||x.showHorizontalLine){x.cursorCanvas=new j.jqplot.GenericCanvas();this.eventCanvas._elem.before(x.cursorCanvas.createElement(this._gridPadding,"jqplot-cursor-canvas",this._plotDimensions,this));x.cursorCanvas.setContext()}if(x.showTooltipUnitPosition){if(x.tooltipAxisGroups.length===0){var t=this.series;var u;var q=[];for(var r=0;r<t.length;r++){u=t[r];var w=u.xaxis+","+u.yaxis;if(j.inArray(w,q)==-1){q.push(w)}}for(var r=0;r<q.length;r++){x.tooltipAxisGroups.push(q[r].split(","))}}}};j.jqplot.Cursor.zoomProxy=function(v,r){var q=v.plugins.cursor;var u=r.plugins.cursor;q.zoomTarget=true;q.zoom=true;q.style="auto";q.dblClickReset=false;u.zoom=true;u.zoomProxy=true;r.target.bind("jqplotZoom",t);r.target.bind("jqplotResetZoom",s);function t(x,w,z,y,A){q.doZoom(w,z,v,A)}function s(w,x,y){v.resetZoom()}};j.jqplot.Cursor.prototype.resetZoom=function(u,v){var t=u.axes;var s=v._zoom.axes;if(!u.plugins.cursor.zoomProxy&&v._zoom.isZoomed){for(var r in t){t[r].reset();t[r]._ticks=[];t[r]._autoFormatString=s[r].tickFormatString}u.redraw();v._zoom.isZoomed=false}else{var q=v.zoomCanvas._ctx;q.clearRect(0,0,q.canvas.width,q.canvas.height);q=null}u.target.trigger("jqplotResetZoom",[u,v])};j.jqplot.Cursor.resetZoom=function(q){q.resetZoom()};j.jqplot.Cursor.prototype.doZoom=function(G,t,C,u){var I=u;var F=C.axes;var r=I._zoom.axes;var w=r.start;var s=r.end;var B,E,z,D;var A=C.plugins.cursor.zoomCanvas._ctx;if((I.constrainZoomTo=="none"&&Math.abs(G.x-I._zoom.start[0])>6&&Math.abs(G.y-I._zoom.start[1])>6)||(I.constrainZoomTo=="x"&&Math.abs(G.x-I._zoom.start[0])>6)||(I.constrainZoomTo=="y"&&Math.abs(G.y-I._zoom.start[1])>6)){if(!C.plugins.cursor.zoomProxy){for(var y in t){if(I._zoom.axes[y]==undefined){I._zoom.axes[y]={};I._zoom.axes[y].numberTicks=F[y].numberTicks;I._zoom.axes[y].tickInterval=F[y].tickInterval;I._zoom.axes[y].daTickInterval=F[y].daTickInterval;I._zoom.axes[y].min=F[y].min;I._zoom.axes[y].max=F[y].max;I._zoom.axes[y].tickFormatString=(F[y].tickOptions!=null)?F[y].tickOptions.formatString:""}if((I.constrainZoomTo=="none")||(I.constrainZoomTo=="x"&&y.charAt(0)=="x")||(I.constrainZoomTo=="y"&&y.charAt(0)=="y")){z=t[y];if(z!=null){var v,x;if(z>w[y]){v=w[y];x=z}else{D=w[y]-z;v=z;x=w[y]}var q=F[y];var H=null;if(q.alignTicks){if(q.name==="x2axis"&&C.axes.xaxis.show){H=C.axes.xaxis.numberTicks}else{if(q.name.charAt(0)==="y"&&q.name!=="yaxis"&&q.name!=="yMidAxis"&&C.axes.yaxis.show){H=C.axes.yaxis.numberTicks}}}if(this.looseZoom&&(F[y].renderer.constructor===j.jqplot.LinearAxisRenderer||F[y].renderer.constructor===j.jqplot.DateAxisRenderer)){var J=j.jqplot.LinearTickGenerator(v,x,q._scalefact,H);if(F[y].tickInset&&J[0]<F[y].min+F[y].tickInset*F[y].tickInterval){J[0]+=J[4];J[2]-=1}if(F[y].tickInset&&J[1]>F[y].max-F[y].tickInset*F[y].tickInterval){J[1]-=J[4];J[2]-=1}F[y].min=J[0];F[y].max=J[1];F[y]._autoFormatString=J[3];F[y].numberTicks=J[2];F[y].tickInterval=J[4];F[y].daTickInterval=[J[4]/1000,"seconds"]}else{F[y].min=v;F[y].max=x;F[y].tickInterval=null;F[y].daTickInterval=null}F[y]._ticks=[]}}}A.clearRect(0,0,A.canvas.width,A.canvas.height);C.redraw();I._zoom.isZoomed=true;A=null}C.target.trigger("jqplotZoom",[G,t,C,u])}};j.jqplot.preInitHooks.push(j.jqplot.Cursor.init);j.jqplot.postDrawHooks.push(j.jqplot.Cursor.postDraw);function e(E,r,B){var G=B.plugins.cursor;var w="";var K=false;if(G.showTooltipGridPosition){w=E.x+", "+E.y;K=true}if(G.showTooltipUnitPosition){var D;for(var C=0;C<G.tooltipAxisGroups.length;C++){D=G.tooltipAxisGroups[C];if(K){w+="<br />"}if(G.useAxesFormatters){var A=B.axes[D[0]]._ticks[0].formatter;var q=B.axes[D[1]]._ticks[0].formatter;var H=B.axes[D[0]]._ticks[0].formatString;var v=B.axes[D[1]]._ticks[0].formatString;w+=A(H,r[D[0]])+", "+q(v,r[D[1]])}else{w+=j.jqplot.sprintf(G.tooltipFormatString,r[D[0]],r[D[1]])}K=true}}if(G.showTooltipDataPosition){var u=B.series;var J=d(B,E.x,E.y);var K=false;for(var C=0;C<u.length;C++){if(u[C].show){var y=u[C].index;var t=u[C].label.toString();var F=j.inArray(y,J.indices);var z=undefined;var x=undefined;if(F!=-1){var I=J.data[F].data;if(G.useAxesFormatters){var A=u[C]._xaxis._ticks[0].formatter;var q=u[C]._yaxis._ticks[0].formatter;var H=u[C]._xaxis._ticks[0].formatString;var v=u[C]._yaxis._ticks[0].formatString;z=A(H,I[0]);x=q(v,I[1])}else{z=I[0];x=I[1]}if(K){w+="<br />"}w+=j.jqplot.sprintf(G.tooltipFormatString,t,z,x);K=true}}}}G._tooltipElem.html(w)}function g(C,A){var E=A.plugins.cursor;var z=E.cursorCanvas._ctx;z.clearRect(0,0,z.canvas.width,z.canvas.height);if(E.showVerticalLine){E.shapeRenderer.draw(z,[[C.x,0],[C.x,z.canvas.height]])}if(E.showHorizontalLine){E.shapeRenderer.draw(z,[[0,C.y],[z.canvas.width,C.y]])}var G=d(A,C.x,C.y);if(E.showCursorLegend){var r=j(A.targetId+" td.jqplot-cursor-legend-label");for(var B=0;B<r.length;B++){var v=j(r[B]).data("seriesIndex");var t=A.series[v];var s=t.label.toString();var D=j.inArray(v,G.indices);var x=undefined;var w=undefined;if(D!=-1){var H=G.data[D].data;if(E.useAxesFormatters){var y=t._xaxis._ticks[0].formatter;var q=t._yaxis._ticks[0].formatter;var F=t._xaxis._ticks[0].formatString;var u=t._yaxis._ticks[0].formatString;x=y(F,H[0]);w=q(u,H[1])}else{x=H[0];w=H[1]}}if(A.legend.escapeHtml){j(r[B]).text(j.jqplot.sprintf(E.cursorLegendFormatString,s,x,w))}else{j(r[B]).html(j.jqplot.sprintf(E.cursorLegendFormatString,s,x,w))}}}z=null}function d(A,F,E){var B={indices:[],data:[]};var G,w,u,C,v,q,t;var z;var D=A.plugins.cursor;for(var w=0;w<A.series.length;w++){G=A.series[w];q=G.renderer;if(G.show){z=D.intersectionThreshold;if(G.showMarker){z+=G.markerRenderer.size/2}for(var v=0;v<G.gridData.length;v++){t=G.gridData[v];if(D.showVerticalLine){if(Math.abs(F-t[0])<=z){B.indices.push(w);B.data.push({seriesIndex:w,pointIndex:v,gridData:t,data:G.data[v]})}}}}}return B}function n(r,t){var v=t.plugins.cursor;var s=v._tooltipElem;switch(v.tooltipLocation){case"nw":var q=r.x+t._gridPadding.left-s.outerWidth(true)-v.tooltipOffset;var u=r.y+t._gridPadding.top-v.tooltipOffset-s.outerHeight(true);break;case"n":var q=r.x+t._gridPadding.left-s.outerWidth(true)/2;var u=r.y+t._gridPadding.top-v.tooltipOffset-s.outerHeight(true);break;case"ne":var q=r.x+t._gridPadding.left+v.tooltipOffset;var u=r.y+t._gridPadding.top-v.tooltipOffset-s.outerHeight(true);break;case"e":var q=r.x+t._gridPadding.left+v.tooltipOffset;var u=r.y+t._gridPadding.top-s.outerHeight(true)/2;break;case"se":var q=r.x+t._gridPadding.left+v.tooltipOffset;var u=r.y+t._gridPadding.top+v.tooltipOffset;break;case"s":var q=r.x+t._gridPadding.left-s.outerWidth(true)/2;var u=r.y+t._gridPadding.top+v.tooltipOffset;break;case"sw":var q=r.x+t._gridPadding.left-s.outerWidth(true)-v.tooltipOffset;var u=r.y+t._gridPadding.top+v.tooltipOffset;break;case"w":var q=r.x+t._gridPadding.left-s.outerWidth(true)-v.tooltipOffset;var u=r.y+t._gridPadding.top-s.outerHeight(true)/2;break;default:var q=r.x+t._gridPadding.left+v.tooltipOffset;var u=r.y+t._gridPadding.top+v.tooltipOffset;break}s.css("left",q);s.css("top",u);s=null}function m(u){var s=u._gridPadding;var v=u.plugins.cursor;var t=v._tooltipElem;switch(v.tooltipLocation){case"nw":var r=s.left+v.tooltipOffset;var q=s.top+v.tooltipOffset;t.css("left",r);t.css("top",q);break;case"n":var r=(s.left+(u._plotDimensions.width-s.right))/2-t.outerWidth(true)/2;var q=s.top+v.tooltipOffset;t.css("left",r);t.css("top",q);break;case"ne":var r=s.right+v.tooltipOffset;var q=s.top+v.tooltipOffset;t.css({right:r,top:q});break;case"e":var r=s.right+v.tooltipOffset;var q=(s.top+(u._plotDimensions.height-s.bottom))/2-t.outerHeight(true)/2;t.css({right:r,top:q});break;case"se":var r=s.right+v.tooltipOffset;var q=s.bottom+v.tooltipOffset;t.css({right:r,bottom:q});break;case"s":var r=(s.left+(u._plotDimensions.width-s.right))/2-t.outerWidth(true)/2;var q=s.bottom+v.tooltipOffset;t.css({left:r,bottom:q});break;case"sw":var r=s.left+v.tooltipOffset;var q=s.bottom+v.tooltipOffset;t.css({left:r,bottom:q});break;case"w":var r=s.left+v.tooltipOffset;var q=(s.top+(u._plotDimensions.height-s.bottom))/2-t.outerHeight(true)/2;t.css({left:r,top:q});break;default:var r=s.right-v.tooltipOffset;var q=s.bottom+v.tooltipOffset;t.css({right:r,bottom:q});break}t=null}function k(r,q,v,u,t){r.preventDefault();r.stopImmediatePropagation();var w=t.plugins.cursor;if(w.clickReset){w.resetZoom(t,w)}var s=window.getSelection;if(document.selection&&document.selection.empty){document.selection.empty()}else{if(s&&!s().isCollapsed){s().collapse()}}return false}function c(r,q,v,u,t){r.preventDefault();r.stopImmediatePropagation();var w=t.plugins.cursor;if(w.dblClickReset){w.resetZoom(t,w)}var s=window.getSelection;if(document.selection&&document.selection.empty){document.selection.empty()}else{if(s&&!s().isCollapsed){s().collapse()}}return false}function f(w,t,q,z,u){var v=u.plugins.cursor;v.onGrid=false;if(v.show){j(w.target).css("cursor",v.previousCursor);if(v.showTooltip&&!(v._zoom.zooming&&v.showTooltipOutsideZoom&&!v.constrainOutsideZoom)){v._tooltipElem.hide()}if(v.zoom){v._zoom.gridpos=t;v._zoom.datapos=q}if(v.showVerticalLine||v.showHorizontalLine){var B=v.cursorCanvas._ctx;B.clearRect(0,0,B.canvas.width,B.canvas.height);B=null}if(v.showCursorLegend){var A=j(u.targetId+" td.jqplot-cursor-legend-label");for(var s=0;s<A.length;s++){var y=j(A[s]).data("seriesIndex");var r=u.series[y];var x=r.label.toString();if(u.legend.escapeHtml){j(A[s]).text(j.jqplot.sprintf(v.cursorLegendFormatString,x,undefined,undefined))}else{j(A[s]).html(j.jqplot.sprintf(v.cursorLegendFormatString,x,undefined,undefined))}}}}}function b(r,q,u,t,s){var v=s.plugins.cursor;v.onGrid=true;if(v.show){v.previousCursor=r.target.style.cursor;r.target.style.cursor=v.style;if(v.showTooltip){e(q,u,s);if(v.followMouse){n(q,s)}else{m(s)}v._tooltipElem.show()}if(v.showVerticalLine||v.showHorizontalLine){g(q,s)}}}function i(r,q,u,t,s){var v=s.plugins.cursor;if(v.show){if(v.showTooltip){e(q,u,s);if(v.followMouse){n(q,s)}}if(v.showVerticalLine||v.showHorizontalLine){g(q,s)}}}function o(y){var x=y.data.plot;var t=x.eventCanvas._elem.offset();var w={x:y.pageX-t.left,y:y.pageY-t.top};var u={xaxis:null,yaxis:null,x2axis:null,y2axis:null,y3axis:null,y4axis:null,y5axis:null,y6axis:null,y7axis:null,y8axis:null,y9axis:null,yMidAxis:null};var v=["xaxis","yaxis","x2axis","y2axis","y3axis","y4axis","y5axis","y6axis","y7axis","y8axis","y9axis","yMidAxis"];var q=x.axes;var r,s;for(r=11;r>0;r--){s=v[r-1];if(q[s].show){u[s]=q[s].series_p2u(w[s.charAt(0)])}}return{offsets:t,gridPos:w,dataPos:u}}function h(z){var x=z.data.plot;var y=x.plugins.cursor;if(y.show&&y.zoom&&y._zoom.started&&!y.zoomTarget){var B=y.zoomCanvas._ctx;var v=o(z);var w=v.gridPos;var t=v.dataPos;y._zoom.gridpos=w;y._zoom.datapos=t;y._zoom.zooming=true;var u=w.x;var s=w.y;var A=B.canvas.height;var q=B.canvas.width;if(y.showTooltip&&!y.onGrid&&y.showTooltipOutsideZoom){e(w,t,x);if(y.followMouse){n(w,x)}}if(y.constrainZoomTo=="x"){y._zoom.end=[u,A]}else{if(y.constrainZoomTo=="y"){y._zoom.end=[q,s]}else{y._zoom.end=[u,s]}}var r=window.getSelection;if(document.selection&&document.selection.empty){document.selection.empty()}else{if(r&&!r().isCollapsed){r().collapse()}}l.call(y);B=null}}function a(w,s,r,x,t){var v=t.plugins.cursor;j(document).one("mouseup.jqplot_cursor",{plot:t},p);var u=t.axes;if(document.onselectstart!=undefined){v._oldHandlers.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!=undefined){v._oldHandlers.ondrag=document.ondrag;document.ondrag=function(){return false}}if(document.onmousedown!=undefined){v._oldHandlers.onmousedown=document.onmousedown;document.onmousedown=function(){return false}}if(v.zoom){if(!v.zoomProxy){var y=v.zoomCanvas._ctx;y.clearRect(0,0,y.canvas.width,y.canvas.height);y=null}if(v.constrainZoomTo=="x"){v._zoom.start=[s.x,0]}else{if(v.constrainZoomTo=="y"){v._zoom.start=[0,s.y]}else{v._zoom.start=[s.x,s.y]}}v._zoom.started=true;for(var q in r){v._zoom.axes.start[q]=r[q]}j(document).bind("mousemove.jqplotCursor",{plot:t},h)}}function p(y){var v=y.data.plot;var x=v.plugins.cursor;if(x.zoom&&x._zoom.zooming&&!x.zoomTarget){var u=x._zoom.gridpos.x;var r=x._zoom.gridpos.y;var t=x._zoom.datapos;var z=x.zoomCanvas._ctx.canvas.height;var q=x.zoomCanvas._ctx.canvas.width;var w=v.axes;if(x.constrainOutsideZoom&&!x.onGrid){if(u<0){u=0}else{if(u>q){u=q}}if(r<0){r=0}else{if(r>z){r=z}}for(var s in t){if(t[s]){if(s.charAt(0)=="x"){t[s]=w[s].series_p2u(u)}else{t[s]=w[s].series_p2u(r)}}}}if(x.constrainZoomTo=="x"){r=z}else{if(x.constrainZoomTo=="y"){u=q}}x._zoom.end=[u,r];x._zoom.gridpos={x:u,y:r};x.doZoom(x._zoom.gridpos,t,v,x)}x._zoom.started=false;x._zoom.zooming=false;j(document).unbind("mousemove.jqplotCursor",h);if(document.onselectstart!=undefined&&x._oldHandlers.onselectstart!=null){document.onselectstart=x._oldHandlers.onselectstart;x._oldHandlers.onselectstart=null}if(document.ondrag!=undefined&&x._oldHandlers.ondrag!=null){document.ondrag=x._oldHandlers.ondrag;x._oldHandlers.ondrag=null}if(document.onmousedown!=undefined&&x._oldHandlers.onmousedown!=null){document.onmousedown=x._oldHandlers.onmousedown;x._oldHandlers.onmousedown=null}}function l(){var y=this._zoom.start;var u=this._zoom.end;var s=this.zoomCanvas._ctx;var r,v,x,q;if(u[0]>y[0]){r=y[0];q=u[0]-y[0]}else{r=u[0];q=y[0]-u[0]}if(u[1]>y[1]){v=y[1];x=u[1]-y[1]}else{v=u[1];x=y[1]-u[1]}s.fillStyle="rgba(0,0,0,0.2)";s.strokeStyle="#999999";s.lineWidth=1;s.clearRect(0,0,s.canvas.width,s.canvas.height);s.fillRect(0,0,s.canvas.width,s.canvas.height);s.clearRect(r,v,q,x);s.strokeRect(r,v,q,x);s=null}j.jqplot.CursorLegendRenderer=function(q){j.jqplot.TableLegendRenderer.call(this,q);this.formatString="%s"};j.jqplot.CursorLegendRenderer.prototype=new j.jqplot.TableLegendRenderer();j.jqplot.CursorLegendRenderer.prototype.constructor=j.jqplot.CursorLegendRenderer;j.jqplot.CursorLegendRenderer.prototype.draw=function(){if(this._elem){this._elem.emptyForce();this._elem=null}if(this.show){var w=this._series,A;var r=document.createElement("div");this._elem=j(r);r=null;this._elem.addClass("jqplot-legend jqplot-cursor-legend");this._elem.css("position","absolute");var q=false;for(var x=0;x<w.length;x++){A=w[x];if(A.show&&A.showLabel){var v=j.jqplot.sprintf(this.formatString,A.label.toString());if(v){var t=A.color;if(A._stack&&!A.fill){t=""}z.call(this,v,t,q,x);q=true}for(var u=0;u<j.jqplot.addLegendRowHooks.length;u++){var y=j.jqplot.addLegendRowHooks[u].call(this,A);if(y){z.call(this,y.label,y.color,q);q=true}}}}w=A=null;delete w;delete A}function z(D,C,F,s){var B=(F)?this.rowSpacing:"0";var E=j('<tr class="jqplot-legend jqplot-cursor-legend"></tr>').appendTo(this._elem);E.data("seriesIndex",s);j('<td class="jqplot-legend jqplot-cursor-legend-swatch" style="padding-top:'+B+';"><div style="border:1px solid #cccccc;padding:0.2em;"><div class="jqplot-cursor-legend-swatch" style="background-color:'+C+';"></div></div></td>').appendTo(E);var G=j('<td class="jqplot-legend jqplot-cursor-legend-label" style="vertical-align:middle;padding-top:'+B+';"></td>');G.appendTo(E);G.data("seriesIndex",s);if(this.escapeHtml){G.text(D)}else{G.html(D)}E=null;G=null}return this._elem}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dateAxisRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dateAxisRenderer.js
deleted file mode 100644
index dfc2daa..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dateAxisRenderer.js
+++ /dev/null
@@ -1,501 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {  
-    /**
-     * Class: $.jqplot.DateAxisRenderer
-     * A plugin for a jqPlot to render an axis as a series of date values.
-     * This renderer has no options beyond those supplied by the <Axis> class.
-     * It supplies it's own tick formatter, so the tickOptions.formatter option
-     * should not be overridden.
-     * 
-     * Thanks to Ken Synder for his enhanced Date instance methods which are
-     * included with this code <http://kendsnyder.com/sandbox/date/>.
-     * 
-     * To use this renderer, include the plugin in your source
-     * > <script type="text/javascript" language="javascript" src="plugins/jqplot.dateAxisRenderer.js"></script>
-     * 
-     * and supply the appropriate options to your plot
-     * 
-     * > {axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}}}
-     * 
-     * Dates can be passed into the axis in almost any recognizable value and 
-     * will be parsed.  They will be rendered on the axis in the format
-     * specified by tickOptions.formatString.  e.g. tickOptions.formatString = '%Y-%m-%d'.
-     * 
-     * Accecptable format codes 
-     * are:
-     * 
-     * > Code    Result                  Description
-     * >             == Years ==
-     * > %Y      2008                Four-digit year
-     * > %y      08                  Two-digit year
-     * >             == Months ==
-     * > %m      09                  Two-digit month
-     * > %#m     9                   One or two-digit month
-     * > %B      September           Full month name
-     * > %b      Sep                 Abbreviated month name
-     * >             == Days ==
-     * > %d      05                  Two-digit day of month
-     * > %#d     5                   One or two-digit day of month
-     * > %e      5                   One or two-digit day of month
-     * > %A      Sunday              Full name of the day of the week
-     * > %a      Sun                 Abbreviated name of the day of the week
-     * > %w      0                   Number of the day of the week (0 = Sunday, 6 = Saturday)
-     * > %o      th                  The ordinal suffix string following the day of the month
-     * >             == Hours ==
-     * > %H      23                  Hours in 24-hour format (two digits)
-     * > %#H     3                   Hours in 24-hour integer format (one or two digits)
-     * > %I      11                  Hours in 12-hour format (two digits)
-     * > %#I     3                   Hours in 12-hour integer format (one or two digits)
-     * > %p      PM                  AM or PM
-     * >             == Minutes ==
-     * > %M      09                  Minutes (two digits)
-     * > %#M     9                   Minutes (one or two digits)
-     * >             == Seconds ==
-     * > %S      02                  Seconds (two digits)
-     * > %#S     2                   Seconds (one or two digits)
-     * > %s      1206567625723       Unix timestamp (Seconds past 1970-01-01 00:00:00)
-     * >             == Milliseconds ==
-     * > %N      008                 Milliseconds (three digits)
-     * > %#N     8                   Milliseconds (one to three digits)
-     * >             == Timezone ==
-     * > %O      360                 difference in minutes between local time and GMT
-     * > %Z      Mountain Standard Time  Name of timezone as reported by browser
-     * > %G      -06:00              Hours and minutes between GMT
-     * >             == Shortcuts ==
-     * > %F      2008-03-26          %Y-%m-%d
-     * > %T      05:06:30            %H:%M:%S
-     * > %X      05:06:30            %H:%M:%S
-     * > %x      03/26/08            %m/%d/%y
-     * > %D      03/26/08            %m/%d/%y
-     * > %#c     Wed Mar 26 15:31:00 2008  %a %b %e %H:%M:%S %Y
-     * > %v      3-Sep-2008          %e-%b-%Y
-     * > %R      15:31               %H:%M
-     * > %r      3:31:00 PM          %I:%M:%S %p
-     * >             == Characters ==
-     * > %n      \n                  Newline
-     * > %t      \t                  Tab
-     * > %%      %                   Percent Symbol 
-     */
-    $.jqplot.DateAxisRenderer = function() {
-        $.jqplot.LinearAxisRenderer.call(this);
-		this.date = new $.jsDate();
-    };
-    
-    $.jqplot.DateAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
-    $.jqplot.DateAxisRenderer.prototype.constructor = $.jqplot.DateAxisRenderer;
-    
-    $.jqplot.DateTickFormatter = function(format, val) {
-        if (!format) {
-            format = '%Y/%m/%d';
-        }
-        return $.jsDate.strftime(val, format);
-    };
-    
-    $.jqplot.DateAxisRenderer.prototype.init = function(options){
-        // prop: tickRenderer
-        // A class of a rendering engine for creating the ticks labels displayed on the plot, 
-        // See <$.jqplot.AxisTickRenderer>.
-        // this.tickRenderer = $.jqplot.AxisTickRenderer;
-        // this.labelRenderer = $.jqplot.AxisLabelRenderer;
-        this.tickOptions.formatter = $.jqplot.DateTickFormatter;
-        // prop: tickInset
-        // Controls the amount to inset the first and last ticks from 
-        // the edges of the grid, in multiples of the tick interval.
-        // 0 is no inset, 0.5 is one half a tick interval, 1 is a full
-        // tick interval, etc.
-        this.tickInset = 0;
-        // prop: drawBaseline
-        // True to draw the axis baseline.
-        this.drawBaseline = true;
-        // prop: baselineWidth
-        // width of the baseline in pixels.
-        this.baselineWidth = null;
-        // prop: baselineColor
-        // CSS color spec for the baseline.
-        this.baselineColor = null;
-        this.daTickInterval = null;
-        this._daTickInterval = null;
-		
-        $.extend(true, this, options);
-		
-        var db = this._dataBounds,
-			stats, 
-			sum,
-			s,
-			d,
-			pd,
-			sd,
-			intv;
-		
-        // Go through all the series attached to this axis and find
-        // the min/max bounds for this axis.
-        for (var i=0; i<this._series.length; i++) {
-			stats = {intervals:[], frequencies:{}, sortedIntervals:[], min:null, max:null, mean:null};
-			sum = 0;
-            s = this._series[i];
-            d = s.data;
-            pd = s._plotData;
-            sd = s._stackData;
-			intv = 0;
-            
-            for (var j=0; j<d.length; j++) { 
-                if (this.name == 'xaxis' || this.name == 'x2axis') {
-                    d[j][0] = new $.jsDate(d[j][0]).getTime();
-                    pd[j][0] = new $.jsDate(d[j][0]).getTime();
-                    sd[j][0] = new $.jsDate(d[j][0]).getTime();
-                    if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) {
-                        db.min = d[j][0];
-                    }
-                    if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) {
-                        db.max = d[j][0];
-                    }
-					if (j>0) {
-						intv = Math.abs(d[j][0] - d[j-1][0]);
-						stats.intervals.push(intv);
-						if (stats.frequencies.hasOwnProperty(intv)) {
-							stats.frequencies[intv] += 1;
-						}
-						else {
-							stats.frequencies[intv] = 1;
-						}
-					}
-					sum += intv;
-					
-                }              
-                else {
-                    d[j][1] = new $.jsDate(d[j][1]).getTime();
-                    pd[j][1] = new $.jsDate(d[j][1]).getTime();
-                    sd[j][1] = new $.jsDate(d[j][1]).getTime();
-                    if ((d[j][1] != null && d[j][1] < db.min) || db.min == null) {
-                        db.min = d[j][1];
-                    }
-                    if ((d[j][1] != null && d[j][1] > db.max) || db.max == null) {
-                        db.max = d[j][1];
-                    }
-					if (j>0) {
-						intv = Math.abs(d[j][1] - d[j-1][1]);
-						stats.intervals.push(intv);
-						if (stats.frequencies.hasOwnProperty(intv)) {
-							stats.frequencies[intv] += 1;
-						}
-						else {
-							stats.frequencies[intv] = 1;
-						}
-					}
-                }
-				sum += intv;              
-            }
-
-            if (s.renderer.bands) {
-                if (s.renderer.bands.hiData.length) {
-                    var bd = s.renderer.bands.hiData;
-                    for (var j=0, l=bd.length; j < l; j++) {
-                        if (this.name === 'xaxis' || this.name === 'x2axis') {
-                            bd[j][0] = new $.jsDate(bd[j][0]).getTime();
-                            if ((bd[j][0] != null && bd[j][0] > db.max) || db.max == null) {
-                                db.max = bd[j][0];
-                            }                        
-                        }              
-                        else {
-                            bd[j][1] = new $.jsDate(bd[j][1]).getTime();
-                            if ((bd[j][1] != null && bd[j][1] > db.max) || db.max == null) {
-                                db.max = bd[j][1];
-                            }
-                        }
-                    }
-                }
-                if (s.renderer.bands.lowData.length) {
-                    var bd = s.renderer.bands.lowData;
-                    for (var j=0, l=bd.length; j < l; j++) {
-                        if (this.name === 'xaxis' || this.name === 'x2axis') {
-                            bd[j][0] = new $.jsDate(bd[j][0]).getTime();
-                            if ((bd[j][0] != null && bd[j][0] < db.min) || db.min == null) {
-                                db.min = bd[j][0];
-                            }                       
-                        }              
-                        else {
-                            bd[j][1] = new $.jsDate(bd[j][1]).getTime();
-                            if ((bd[j][1] != null && bd[j][1] < db.min) || db.min == null) {
-                                db.min = bd[j][1];
-                            }
-                        }
-                    }
-                }
-            }
-			
-			var tempf = 0,
-				tempn=0;
-			for (var n in stats.frequencies) {
-				stats.sortedIntervals.push({interval:n, frequency:stats.frequencies[n]});
-			}
-			stats.sortedIntervals.sort(function(a, b){
-				return b.frequency - a.frequency;
-			});
-			
-			stats.min = $.jqplot.arrayMin(stats.intervals);
-			stats.max = $.jqplot.arrayMax(stats.intervals);
-			stats.mean = sum/d.length;
-			this._intervalStats.push(stats);
-			stats = sum = s = d = pd = sd = null;
-        }
-		db = null;
-		
-    };
-    
-    // called with scope of an axis
-    $.jqplot.DateAxisRenderer.prototype.reset = function() {
-        this.min = this._options.min;
-        this.max = this._options.max;
-        this.tickInterval = this._options.tickInterval;
-        this.numberTicks = this._options.numberTicks;
-        this._autoFormatString = '';
-        if (this._overrideFormatString && this.tickOptions && this.tickOptions.formatString) {
-            this.tickOptions.formatString = '';
-        }
-        this.daTickInterval = this._daTickInterval;
-        // this._ticks = this.__ticks;
-    };
-    
-    $.jqplot.DateAxisRenderer.prototype.createTicks = function() {
-        // we're are operating on an axis here
-        var ticks = this._ticks;
-        var userTicks = this.ticks;
-        var name = this.name;
-        // databounds were set on axis initialization.
-        var db = this._dataBounds;
-		var iv = this._intervalStats;
-        var dim, interval;
-        var min, max;
-        var pos1, pos2;
-        var tt, i;
-        
-        // if we already have ticks, use them.
-        // ticks must be in order of increasing value.
-        
-        min = ((this.min != null) ? new $.jsDate(this.min).getTime() : db.min);
-        max = ((this.max != null) ? new $.jsDate(this.max).getTime() : db.max);
-
-        var range = max - min;
-        
-        if (userTicks.length) {
-            // ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed
-            for (i=0; i<userTicks.length; i++){
-                var ut = userTicks[i];
-                var t = new this.tickRenderer(this.tickOptions);
-                if (ut.constructor == Array) {
-                    t.value = new $.jsDate(ut[0]).getTime();
-                    t.label = ut[1];
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(t.value, this.name);
-                    this._ticks.push(t);
-                }
-                
-                else {
-                    t.value = new $.jsDate(ut).getTime();
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(t.value, this.name);
-                    this._ticks.push(t);
-                }
-            }
-            this.numberTicks = userTicks.length;
-            this.min = this._ticks[0].value;
-            this.max = this._ticks[this.numberTicks-1].value;
-            this.daTickInterval = [(this.max - this.min) / (this.numberTicks - 1)/1000, 'seconds'];
-        }
-
-        ////////
-        // We don't have any ticks yet, let's make some!
-        // Doing complete autoscaling, no user options specified
-        ////////
-        
-        else if (this.tickInterval == null && this.min == null && this.max == null && this.numberTicks == null) {
-            var ret = $.jqplot.LinearTickGenerator(min, max); 
-            // calculate a padded max and min, points should be less than these
-            // so that they aren't too close to the edges of the plot.
-            // User can adjust how much padding is allowed with pad, padMin and PadMax options. 
-            var tumin = min + range*(this.padMin - 1);
-            var tumax = max - range*(this.padMax - 1);
-
-            if (min <=tumin || max >= tumax) {
-                tumin = min - range*(this.padMin - 1);
-                tumax = max + range*(this.padMax - 1);
-                ret = $.jqplot.LinearTickGenerator(tumin, tumax);
-            }
-
-            this.min = ret[0];
-            this.max = ret[1];
-            this.numberTicks = ret[2];
-            this.tickInterval = ret[4];
-            this.daTickInterval = [this.tickInterval/1000, 'seconds'];
-
-            for (var i=0; i<this.numberTicks; i++){
-                var min = new $.jsDate(this.min);
-                tt = min.add(i*this.daTickInterval[0], this.daTickInterval[1]).getTime();
-                var t = new this.tickRenderer(this.tickOptions);
-                // var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
-                if (!this.showTicks) {
-                    t.showLabel = false;
-                    t.showMark = false;
-                }
-                else if (!this.showTickMarks) {
-                    t.showMark = false;
-                }
-                t.setTick(tt, this.name);
-                this._ticks.push(t);
-            }           
-        }
-
-        ////////
-        // Some option(s) specified, work around that.
-        ////////
-        
-        else {		
-            if (name == 'xaxis' || name == 'x2axis') {
-                dim = this._plotDimensions.width;
-            }
-            else {
-                dim = this._plotDimensions.height;
-            }
-			
-            // if min, max and number of ticks specified, user can't specify interval.
-            if (this.min != null && this.max != null && this.numberTicks != null) {
-                this.tickInterval = null;
-            }
-            
-            // if user specified a tick interval, convert to usable.
-            if (this.tickInterval != null)
-            {
-                // if interval is a number or can be converted to one, use it.
-                // Assume it is in SECONDS!!!
-                if (Number(this.tickInterval)) {
-                    this.daTickInterval = [Number(this.tickInterval), 'seconds'];
-                }
-                // else, parse out something we can build from.
-                else if (typeof this.tickInterval == "string") {
-                    var parts = this.tickInterval.split(' ');
-                    if (parts.length == 1) {
-                        this.daTickInterval = [1, parts[0]];
-                    }
-                    else if (parts.length == 2) {
-                        this.daTickInterval = [parts[0], parts[1]];
-                    }
-                }
-            }
-            
-            // if min and max are same, space them out a bit
-            if (min == max) {
-                var adj = 24*60*60*500;  // 1/2 day
-                min -= adj;
-                max += adj;
-            }
-
-            range = max - min;
-			
-			var optNumTicks = 2 + parseInt(Math.max(0, dim-100)/100, 10);
-			
-			
-			// Here try to set ticks based on data spacing.
-            // if (this.min == null && this.max == null && this.numberTicks == null && this.tickInterval == null) {
-            //  //
-            // }
-			
-			
-            var rmin, rmax;
-        
-            rmin = (this.min != null) ? new $.jsDate(this.min).getTime() : min - range/2*(this.padMin - 1);
-            rmax = (this.max != null) ? new $.jsDate(this.max).getTime() : max + range/2*(this.padMax - 1);
-            this.min = rmin;
-            this.max = rmax;
-            range = this.max - this.min;
-    
-            if (this.numberTicks == null){
-                // if tickInterval is specified by user, we will ignore computed maximum.
-                // max will be equal or greater to fit even # of ticks.
-                if (this.daTickInterval != null) {
-                    var nc = new $.jsDate(this.max).diff(this.min, this.daTickInterval[1], true);
-                    this.numberTicks = Math.ceil(nc/this.daTickInterval[0]) +1;
-                    // this.max = new $.jsDate(this.min).add(this.numberTicks-1, this.daTickInterval[1]).getTime();
-                    this.max = new $.jsDate(this.min).add((this.numberTicks-1) * this.daTickInterval[0], this.daTickInterval[1]).getTime();
-                }
-                else if (dim > 200) {
-                    this.numberTicks = parseInt(3+(dim-200)/100, 10);
-                }
-                else {
-                    this.numberTicks = 2;
-                }
-            }
-    
-            if (this.daTickInterval == null) {
-                this.daTickInterval = [range / (this.numberTicks-1)/1000, 'seconds'];
-            }
-            for (var i=0; i<this.numberTicks; i++){
-                var min = new $.jsDate(this.min);
-                tt = min.add(i*this.daTickInterval[0], this.daTickInterval[1]).getTime();
-                var t = new this.tickRenderer(this.tickOptions);
-                // var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
-                if (!this.showTicks) {
-                    t.showLabel = false;
-                    t.showMark = false;
-                }
-                else if (!this.showTickMarks) {
-                    t.showMark = false;
-                }
-                t.setTick(tt, this.name);
-                this._ticks.push(t);
-            }
-        }
-
-        if (this.tickInset) {
-            this.min = this.min - this.tickInset * this.tickInterval;
-            this.max = this.max + this.tickInset * this.tickInterval;
-        }
-
-        if (this._daTickInterval == null) {
-            this._daTickInterval = this.daTickInterval;    
-        }
-
-        ticks = null;
-    };
-   
-})(jQuery);
-
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dateAxisRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dateAxisRenderer.min.js
deleted file mode 100644
index 2d13968..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dateAxisRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.DateAxisRenderer=function(){a.jqplot.LinearAxisRenderer.call(this);this.date=new a.jsDate()};a.jqplot.DateAxisRenderer.prototype=new a.jqplot.LinearAxisRenderer();a.jqplot.DateAxisRenderer.prototype.constructor=a.jqplot.DateAxisRenderer;a.jqplot.DateTickFormatter=function(b,c){if(!b){b="%Y/%m/%d"}return a.jsDate.strftime(c,b)};a.jqplot.DateAxisRenderer.prototype.init=function(w){this.tickOptions.formatter=a.jqplot.DateTickFormatter;this.tickInset=0;this.drawBaseline=true;this.baselineWidth=null;this.baselineColor=null;this.daTickInterval=null;this._daTickInterval=null;a.extend(true,this,w);var u=this._dataBounds,h,o,v,p,r,q,b;for(var g=0;g<this._series.length;g++){h={intervals:[],frequencies:{},sortedIntervals:[],min:null,max:null,mean:null};o=0;v=this._series[g];p=v.data;r=v._plotData;q=v._stackData;b=0;for(var f=0;f<p.length;f++){if(this.name=="xaxis"||this.name=="x2axis"){p[f][0]=new a.jsDate(p[f][0]).getTime();r[f][0]=new a.jsDate(p[f][0]).getTime();q[f][0]=new a.jsDate(p[f][0]).getTime();if((p[f][0]!=null&&p[f][0]<u.min)||u.min==null){u.min=p[f][0]}if((p[f][0]!=null&&p[f][0]>u.max)||u.max==null){u.max=p[f][0]}if(f>0){b=Math.abs(p[f][0]-p[f-1][0]);h.intervals.push(b);if(h.frequencies.hasOwnProperty(b)){h.frequencies[b]+=1}else{h.frequencies[b]=1}}o+=b}else{p[f][1]=new a.jsDate(p[f][1]).getTime();r[f][1]=new a.jsDate(p[f][1]).getTime();q[f][1]=new a.jsDate(p[f][1]).getTime();if((p[f][1]!=null&&p[f][1]<u.min)||u.min==null){u.min=p[f][1]}if((p[f][1]!=null&&p[f][1]>u.max)||u.max==null){u.max=p[f][1]}if(f>0){b=Math.abs(p[f][1]-p[f-1][1]);h.intervals.push(b);if(h.frequencies.hasOwnProperty(b)){h.frequencies[b]+=1}else{h.frequencies[b]=1}}}o+=b}if(v.renderer.bands){if(v.renderer.bands.hiData.length){var m=v.renderer.bands.hiData;for(var f=0,e=m.length;f<e;f++){if(this.name==="xaxis"||this.name==="x2axis"){m[f][0]=new a.jsDate(m[f][0]).getTime();if((m[f][0]!=null&&m[f][0]>u.max)||u.max==null){u.max=m[f][0]}}else{m[f][1]=new a.jsDate(m[f][1]).getTime();if((m[f][1]!=null&&m[f][1]>u.max)||u.max==null){u.max=m[f][1]}}}}if(v.renderer.bands.lowData.length){var m=v.renderer.bands.lowData;for(var f=0,e=m.length;f<e;f++){if(this.name==="xaxis"||this.name==="x2axis"){m[f][0]=new a.jsDate(m[f][0]).getTime();if((m[f][0]!=null&&m[f][0]<u.min)||u.min==null){u.min=m[f][0]}}else{m[f][1]=new a.jsDate(m[f][1]).getTime();if((m[f][1]!=null&&m[f][1]<u.min)||u.min==null){u.min=m[f][1]}}}}}var t=0,k=0;for(var c in h.frequencies){h.sortedIntervals.push({interval:c,frequency:h.frequencies[c]})}h.sortedIntervals.sort(function(i,d){return d.frequency-i.frequency});h.min=a.jqplot.arrayMin(h.intervals);h.max=a.jqplot.arrayMax(h.intervals);h.mean=o/p.length;this._intervalStats.push(h);h=o=v=p=r=q=null}u=null};a.jqplot.DateAxisRenderer.prototype.reset=function(){this.min=this._options.min;this.max=this._options.max;this.tickInterval=this._options.tickInterval;this.numberTicks=this._options.numberTicks;this._autoFormatString="";if(this._overrideFormatString&&this.tickOptions&&this.tickOptions.formatString){this.tickOptions.formatString=""}this.daTickInterval=this._daTickInterval};a.jqplot.DateAxisRenderer.prototype.createTicks=function(){var z=this._ticks;var w=this.ticks;var B=this.name;var y=this._dataBounds;var e=this._intervalStats;var q,x;var o,s;var d,c;var b,u;o=((this.min!=null)?new a.jsDate(this.min).getTime():y.min);s=((this.max!=null)?new a.jsDate(this.max).getTime():y.max);var k=s-o;if(w.length){for(u=0;u<w.length;u++){var g=w[u];var j=new this.tickRenderer(this.tickOptions);if(g.constructor==Array){j.value=new a.jsDate(g[0]).getTime();j.label=g[1];if(!this.showTicks){j.showLabel=false;j.showMark=false}else{if(!this.showTickMarks){j.showMark=false}}j.setTick(j.value,this.name);this._ticks.push(j)}else{j.value=new a.jsDate(g).getTime();if(!this.showTicks){j.showLabel=false;j.showMark=false}else{if(!this.showTickMarks){j.showMark=false}}j.setTick(j.value,this.name);this._ticks.push(j)}}this.numberTicks=w.length;this.min=this._ticks[0].value;this.max=this._ticks[this.numberTicks-1].value;this.daTickInterval=[(this.max-this.min)/(this.numberTicks-1)/1000,"seconds"]}else{if(this.tickInterval==null&&this.min==null&&this.max==null&&this.numberTicks==null){var A=a.jqplot.LinearTickGenerator(o,s);var n=o+k*(this.padMin-1);var r=s-k*(this.padMax-1);if(o<=n||s>=r){n=o-k*(this.padMin-1);r=s+k*(this.padMax-1);A=a.jqplot.LinearTickGenerator(n,r)}this.min=A[0];this.max=A[1];this.numberTicks=A[2];this.tickInterval=A[4];this.daTickInterval=[this.tickInterval/1000,"seconds"];for(var u=0;u<this.numberTicks;u++){var o=new a.jsDate(this.min);b=o.add(u*this.daTickInterval[0],this.daTickInterval[1]).getTime();var j=new this.tickRenderer(this.tickOptions);if(!this.showTicks){j.showLabel=false;j.showMark=false}else{if(!this.showTickMarks){j.showMark=false}}j.setTick(b,this.name);this._ticks.push(j)}}else{if(B=="xaxis"||B=="x2axis"){q=this._plotDimensions.width}else{q=this._plotDimensions.height}if(this.min!=null&&this.max!=null&&this.numberTicks!=null){this.tickInterval=null}if(this.tickInterval!=null){if(Number(this.tickInterval)){this.daTickInterval=[Number(this.tickInterval),"seconds"]}else{if(typeof this.tickInterval=="string"){var l=this.tickInterval.split(" ");if(l.length==1){this.daTickInterval=[1,l[0]]}else{if(l.length==2){this.daTickInterval=[l[0],l[1]]}}}}}if(o==s){var h=24*60*60*500;o-=h;s+=h}k=s-o;var v=2+parseInt(Math.max(0,q-100)/100,10);var m,p;m=(this.min!=null)?new a.jsDate(this.min).getTime():o-k/2*(this.padMin-1);p=(this.max!=null)?new a.jsDate(this.max).getTime():s+k/2*(this.padMax-1);this.min=m;this.max=p;k=this.max-this.min;if(this.numberTicks==null){if(this.daTickInterval!=null){var f=new a.jsDate(this.max).diff(this.min,this.daTickInterval[1],true);this.numberTicks=Math.ceil(f/this.daTickInterval[0])+1;this.max=new a.jsDate(this.min).add((this.numberTicks-1)*this.daTickInterval[0],this.daTickInterval[1]).getTime()}else{if(q>200){this.numberTicks=parseInt(3+(q-200)/100,10)}else{this.numberTicks=2}}}if(this.daTickInterval==null){this.daTickInterval=[k/(this.numberTicks-1)/1000,"seconds"]}for(var u=0;u<this.numberTicks;u++){var o=new a.jsDate(this.min);b=o.add(u*this.daTickInterval[0],this.daTickInterval[1]).getTime();var j=new this.tickRenderer(this.tickOptions);if(!this.showTicks){j.showLabel=false;j.showMark=false}else{if(!this.showTickMarks){j.showMark=false}}j.setTick(b,this.name);this._ticks.push(j)}}}if(this.tickInset){this.min=this.min-this.tickInset*this.tickInterval;this.max=this.max+this.tickInset*this.tickInterval}if(this._daTickInterval==null){this._daTickInterval=this.daTickInterval}z=null}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.donutRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.donutRenderer.js
deleted file mode 100644
index e4fdb61..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.donutRenderer.js
+++ /dev/null
@@ -1,800 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-     * Class: $.jqplot.DonutRenderer
-     * Plugin renderer to draw a donut chart.
-     * x values, if present, will be used as slice labels.
-     * y values give slice size.
-     * 
-     * To use this renderer, you need to include the 
-     * donut renderer plugin, for example:
-     * 
-     * > <script type="text/javascript" src="plugins/jqplot.donutRenderer.js"></script>
-     * 
-     * Properties described here are passed into the $.jqplot function
-     * as options on the series renderer.  For example:
-     * 
-     * > plot2 = $.jqplot('chart2', [s1, s2], {
-     * >     seriesDefaults: {
-     * >         renderer:$.jqplot.DonutRenderer,
-     * >         rendererOptions:{
-     * >              sliceMargin: 2,
-     * >              innerDiameter: 110,
-     * >              startAngle: -90
-     * >          }
-     * >      }
-     * > });
-     * 
-     * A donut plot will trigger events on the plot target
-     * according to user interaction.  All events return the event object,
-     * the series index, the point (slice) index, and the point data for 
-     * the appropriate slice.
-     * 
-     * 'jqplotDataMouseOver' - triggered when user mouseing over a slice.
-     * 'jqplotDataHighlight' - triggered the first time user mouses over a slice,
-     * if highlighting is enabled.
-     * 'jqplotDataUnhighlight' - triggered when a user moves the mouse out of
-     * a highlighted slice.
-     * 'jqplotDataClick' - triggered when the user clicks on a slice.
-     * 'jqplotDataRightClick' - tiggered when the user right clicks on a slice if
-     * the "captureRightClick" option is set to true on the plot.
-     */
-    $.jqplot.DonutRenderer = function(){
-        $.jqplot.LineRenderer.call(this);
-    };
-    
-    $.jqplot.DonutRenderer.prototype = new $.jqplot.LineRenderer();
-    $.jqplot.DonutRenderer.prototype.constructor = $.jqplot.DonutRenderer;
-    
-    // called with scope of a series
-    $.jqplot.DonutRenderer.prototype.init = function(options, plot) {
-        // Group: Properties
-        //
-        // prop: diameter
-        // Outer diameter of the donut, auto computed by default
-        this.diameter = null;
-        // prop: innerDiameter
-        // Inner diameter of the donut, auto calculated by default.
-        // If specified will override thickness value.
-        this.innerDiameter = null;
-        // prop: thickness
-        // thickness of the donut, auto computed by default
-        // Overridden by if innerDiameter is specified.
-        this.thickness = null;
-        // prop: padding
-        // padding between the donut and plot edges, legend, etc.
-        this.padding = 20;
-        // prop: sliceMargin
-        // angular spacing between donut slices in degrees.
-        this.sliceMargin = 0;
-        // prop: ringMargin
-        // pixel distance between rings, or multiple series in a donut plot.
-        // null will compute ringMargin based on sliceMargin.
-        this.ringMargin = null;
-        // prop: fill
-        // true or false, wether to fil the slices.
-        this.fill = true;
-        // prop: shadowOffset
-        // offset of the shadow from the slice and offset of 
-        // each succesive stroke of the shadow from the last.
-        this.shadowOffset = 2;
-        // prop: shadowAlpha
-        // transparency of the shadow (0 = transparent, 1 = opaque)
-        this.shadowAlpha = 0.07;
-        // prop: shadowDepth
-        // number of strokes to apply to the shadow, 
-        // each stroke offset shadowOffset from the last.
-        this.shadowDepth = 5;
-        // prop: highlightMouseOver
-        // True to highlight slice when moused over.
-        // This must be false to enable highlightMouseDown to highlight when clicking on a slice.
-        this.highlightMouseOver = true;
-        // prop: highlightMouseDown
-        // True to highlight when a mouse button is pressed over a slice.
-        // This will be disabled if highlightMouseOver is true.
-        this.highlightMouseDown = false;
-        // prop: highlightColors
-        // an array of colors to use when highlighting a slice.
-        this.highlightColors = [];
-        // prop: dataLabels
-        // Either 'label', 'value', 'percent' or an array of labels to place on the pie slices.
-        // Defaults to percentage of each pie slice.
-        this.dataLabels = 'percent';
-        // prop: showDataLabels
-        // true to show data labels on slices.
-        this.showDataLabels = false;
-        // prop: dataLabelFormatString
-        // Format string for data labels.  If none, '%s' is used for "label" and for arrays, '%d' for value and '%d%%' for percentage.
-        this.dataLabelFormatString = null;
-        // prop: dataLabelThreshold
-        // Threshhold in percentage (0 - 100) of pie area, below which no label will be displayed.
-        // This applies to all label types, not just to percentage labels.
-        this.dataLabelThreshold = 3;
-        // prop: dataLabelPositionFactor
-        // A Multiplier (0-1) of the pie radius which controls position of label on slice.
-        // Increasing will slide label toward edge of pie, decreasing will slide label toward center of pie.
-        this.dataLabelPositionFactor = 0.4;
-        // prop: dataLabelNudge
-        // Number of pixels to slide the label away from (+) or toward (-) the center of the pie.
-        this.dataLabelNudge = 0;
-        // prop: startAngle
-        // Angle to start drawing donut in degrees.  
-        // According to orientation of canvas coordinate system:
-        // 0 = on the positive x axis
-        // -90 = on the positive y axis.
-        // 90 = on the negaive y axis.
-        // 180 or - 180 = on the negative x axis.
-        this.startAngle = 0;
-        this.tickRenderer = $.jqplot.DonutTickRenderer;
-        // Used as check for conditions where donut shouldn't be drawn.
-        this._drawData = true;
-        this._type = 'donut';
-        
-        // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
-        if (options.highlightMouseDown && options.highlightMouseOver == null) {
-            options.highlightMouseOver = false;
-        }
-        
-        $.extend(true, this, options);
-        if (this.diameter != null) {
-            this.diameter = this.diameter - this.sliceMargin;
-        }
-        this._diameter = null;
-        this._innerDiameter = null;
-        this._radius = null;
-        this._innerRadius = null;
-        this._thickness = null;
-        // references to the previous series in the plot to properly calculate diameters
-        // and thicknesses of nested rings.
-        this._previousSeries = [];
-        this._numberSeries = 1;
-        // array of [start,end] angles arrays, one for each slice.  In radians.
-        this._sliceAngles = [];
-        // index of the currenty highlighted point, if any
-        this._highlightedPoint = null;
-        
-        // set highlight colors if none provided
-        if (this.highlightColors.length == 0) {
-            for (var i=0; i<this.seriesColors.length; i++){
-                var rgba = $.jqplot.getColorComponents(this.seriesColors[i]);
-                var newrgb = [rgba[0], rgba[1], rgba[2]];
-                var sum = newrgb[0] + newrgb[1] + newrgb[2];
-                for (var j=0; j<3; j++) {
-                    // when darkening, lowest color component can be is 60.
-                    newrgb[j] = (sum > 570) ?  newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]);
-                    newrgb[j] = parseInt(newrgb[j], 10);
-                }
-                this.highlightColors.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')');
-            }
-        }
-        
-        plot.postParseOptionsHooks.addOnce(postParseOptions);
-        plot.postInitHooks.addOnce(postInit);
-        plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
-        plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
-        plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
-        plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
-        plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
-        plot.postDrawHooks.addOnce(postPlotDraw);
-        
-        
-    };
-    
-    $.jqplot.DonutRenderer.prototype.setGridData = function(plot) {
-        // set gridData property.  This will hold angle in radians of each data point.
-        var stack = [];
-        var td = [];
-        var sa = this.startAngle/180*Math.PI;
-        var tot = 0;
-        // don't know if we have any valid data yet, so set plot to not draw.
-        this._drawData = false;
-        for (var i=0; i<this.data.length; i++){
-            if (this.data[i][1] != 0) {
-                // we have data, O.K. to draw.
-                this._drawData = true;
-            }
-            stack.push(this.data[i][1]);
-            td.push([this.data[i][0]]);
-            if (i>0) {
-                stack[i] += stack[i-1];
-            }
-            tot += this.data[i][1];
-        }
-        var fact = Math.PI*2/stack[stack.length - 1];
-        
-        for (var i=0; i<stack.length; i++) {
-            td[i][1] = stack[i] * fact;
-            td[i][2] = this.data[i][1]/tot;
-        }
-        this.gridData = td;
-    };
-    
-    $.jqplot.DonutRenderer.prototype.makeGridData = function(data, plot) {
-        var stack = [];
-        var td = [];
-        var tot = 0;
-        var sa = this.startAngle/180*Math.PI;
-        // don't know if we have any valid data yet, so set plot to not draw.
-        this._drawData = false;
-        for (var i=0; i<data.length; i++){
-            if (this.data[i][1] != 0) {
-                // we have data, O.K. to draw.
-                this._drawData = true;
-            }
-            stack.push(data[i][1]);
-            td.push([data[i][0]]);
-            if (i>0) {
-                stack[i] += stack[i-1];
-            }
-            tot += data[i][1];
-        }
-        var fact = Math.PI*2/stack[stack.length - 1];
-        
-        for (var i=0; i<stack.length; i++) {
-            td[i][1] = stack[i] * fact;
-            td[i][2] = data[i][1]/tot;
-        }
-        return td;
-    };
-    
-    $.jqplot.DonutRenderer.prototype.drawSlice = function (ctx, ang1, ang2, color, isShadow) {
-        var r = this._diameter / 2;
-        var ri = r - this._thickness;
-        var fill = this.fill;
-        // var lineWidth = this.lineWidth;
-        ctx.save();
-        ctx.translate(this._center[0], this._center[1]);
-        // ctx.translate(this.sliceMargin*Math.cos((ang1+ang2)/2), this.sliceMargin*Math.sin((ang1+ang2)/2));
-        
-        if (isShadow) {
-            for (var i=0; i<this.shadowDepth; i++) {
-                ctx.save();
-                ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
-                doDraw();
-            }
-        }
-        
-        else {
-            doDraw();
-        }
-        
-        function doDraw () {
-            // Fix for IE and Chrome that can't seem to draw circles correctly.
-            // ang2 should always be <= 2 pi since that is the way the data is converted.
-             if (ang2 > 6.282 + this.startAngle) {
-                ang2 = 6.282 + this.startAngle;
-                if (ang1 > ang2) {
-                    ang1 = 6.281 + this.startAngle;
-                }
-            }
-            // Fix for IE, where it can't seem to handle 0 degree angles.  Also avoids
-            // ugly line on unfilled donuts.
-            if (ang1 >= ang2) {
-                return;
-            }
-            ctx.beginPath();  
-            ctx.fillStyle = color;
-            ctx.strokeStyle = color;
-            // ctx.lineWidth = lineWidth;
-            ctx.arc(0, 0, r, ang1, ang2, false);
-            ctx.lineTo(ri*Math.cos(ang2), ri*Math.sin(ang2));
-            ctx.arc(0,0, ri, ang2, ang1, true);
-            ctx.closePath();
-            if (fill) {
-                ctx.fill();
-            }
-            else {
-                ctx.stroke();
-            }
-        }
-        
-        if (isShadow) {
-            for (var i=0; i<this.shadowDepth; i++) {
-                ctx.restore();
-            }
-        }
-        
-        ctx.restore();
-    };
-    
-    // called with scope of series
-    $.jqplot.DonutRenderer.prototype.draw = function (ctx, gd, options, plot) {
-        var i;
-        var opts = (options != undefined) ? options : {};
-        // offset and direction of offset due to legend placement
-        var offx = 0;
-        var offy = 0;
-        var trans = 1;
-        // var colorGenerator = new this.colorGenerator(this.seriesColors);
-        if (options.legendInfo && options.legendInfo.placement == 'insideGrid') {
-            var li = options.legendInfo;
-            switch (li.location) {
-                case 'nw':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'w':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'sw':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'ne':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'e':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'se':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'n':
-                    offy = li.height + li.yoffset;
-                    break;
-                case 's':
-                    offy = li.height + li.yoffset;
-                    trans = -1;
-                    break;
-                default:
-                    break;
-            }
-        }
-        
-        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
-        var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
-        var fill = (opts.fill != undefined) ? opts.fill : this.fill;
-        var cw = ctx.canvas.width;
-        var ch = ctx.canvas.height;
-        var w = cw - offx - 2 * this.padding;
-        var h = ch - offy - 2 * this.padding;
-        var mindim = Math.min(w,h);
-        var d = mindim;
-        var ringmargin =  (this.ringMargin == null) ? this.sliceMargin * 2.0 : this.ringMargin;
-        
-        for (var i=0; i<this._previousSeries.length; i++) {
-            d -= 2.0 * this._previousSeries[i]._thickness + 2.0 * ringmargin;
-        }
-        this._diameter = this.diameter || d;
-        if (this.innerDiameter != null) {
-            var od = (this._numberSeries > 1 && this.index > 0) ? this._previousSeries[0]._diameter : this._diameter;
-            this._thickness = this.thickness || (od - this.innerDiameter - 2.0*ringmargin*this._numberSeries) / this._numberSeries/2.0;
-        }
-        else {
-            this._thickness = this.thickness || mindim / 2 / (this._numberSeries + 1) * 0.85;
-        }
-
-        var r = this._radius = this._diameter/2;
-        this._innerRadius = this._radius - this._thickness;
-        var sa = this.startAngle / 180 * Math.PI;
-        this._center = [(cw - trans * offx)/2 + trans * offx, (ch - trans*offy)/2 + trans * offy];
-        
-        if (this.shadow) {
-            var shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')';
-            for (var i=0; i<gd.length; i++) {
-                var ang1 = (i == 0) ? sa : gd[i-1][1] + sa;
-                // Adjust ang1 and ang2 for sliceMargin
-                ang1 += this.sliceMargin/180*Math.PI;
-                this.renderer.drawSlice.call (this, ctx, ang1, gd[i][1]+sa, shadowColor, true);
-            }
-            
-        }
-        for (var i=0; i<gd.length; i++) {
-            var ang1 = (i == 0) ? sa : gd[i-1][1] + sa;
-            // Adjust ang1 and ang2 for sliceMargin
-            ang1 += this.sliceMargin/180*Math.PI;
-            var ang2 = gd[i][1] + sa;
-            this._sliceAngles.push([ang1, ang2]);
-            this.renderer.drawSlice.call (this, ctx, ang1, ang2, this.seriesColors[i], false);
-            
-            if (this.showDataLabels && gd[i][2]*100 >= this.dataLabelThreshold) {
-                var fstr, avgang = (ang1+ang2)/2, label;
-                
-                if (this.dataLabels == 'label') {
-                    fstr = this.dataLabelFormatString || '%s';
-                    label = $.jqplot.sprintf(fstr, gd[i][0]);
-                }
-                else if (this.dataLabels == 'value') {
-                    fstr = this.dataLabelFormatString || '%d';
-                    label = $.jqplot.sprintf(fstr, this.data[i][1]);
-                }
-                else if (this.dataLabels == 'percent') {
-                    fstr = this.dataLabelFormatString || '%d%%';
-                    label = $.jqplot.sprintf(fstr, gd[i][2]*100);
-                }
-                else if (this.dataLabels.constructor == Array) {
-                    fstr = this.dataLabelFormatString || '%s';
-                    label = $.jqplot.sprintf(fstr, this.dataLabels[i]);
-                }
-                
-                var fact = this._innerRadius + this._thickness * this.dataLabelPositionFactor + this.sliceMargin + this.dataLabelNudge;
-                
-                var x = this._center[0] + Math.cos(avgang) * fact + this.canvas._offsets.left;
-                var y = this._center[1] + Math.sin(avgang) * fact + this.canvas._offsets.top;
-                
-                var labelelem = $('<span class="jqplot-donut-series jqplot-data-label" style="position:absolute;">' + label + '</span>').insertBefore(plot.eventCanvas._elem);
-                x -= labelelem.width()/2;
-                y -= labelelem.height()/2;
-                x = Math.round(x);
-                y = Math.round(y);
-                labelelem.css({left: x, top: y});
-            }
-        }
-               
-    };
-    
-    $.jqplot.DonutAxisRenderer = function() {
-        $.jqplot.LinearAxisRenderer.call(this);
-    };
-    
-    $.jqplot.DonutAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
-    $.jqplot.DonutAxisRenderer.prototype.constructor = $.jqplot.DonutAxisRenderer;
-        
-    
-    // There are no traditional axes on a donut chart.  We just need to provide
-    // dummy objects with properties so the plot will render.
-    // called with scope of axis object.
-    $.jqplot.DonutAxisRenderer.prototype.init = function(options){
-        //
-        this.tickRenderer = $.jqplot.DonutTickRenderer;
-        $.extend(true, this, options);
-        // I don't think I'm going to need _dataBounds here.
-        // have to go Axis scaling in a way to fit chart onto plot area
-        // and provide u2p and p2u functionality for mouse cursor, etc.
-        // for convienence set _dataBounds to 0 and 100 and
-        // set min/max to 0 and 100.
-        this._dataBounds = {min:0, max:100};
-        this.min = 0;
-        this.max = 100;
-        this.showTicks = false;
-        this.ticks = [];
-        this.showMark = false;
-        this.show = false; 
-    };
-    
-    
-    
-    
-    $.jqplot.DonutLegendRenderer = function(){
-        $.jqplot.TableLegendRenderer.call(this);
-    };
-    
-    $.jqplot.DonutLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
-    $.jqplot.DonutLegendRenderer.prototype.constructor = $.jqplot.DonutLegendRenderer;
-    
-    /**
-     * Class: $.jqplot.DonutLegendRenderer
-     * Legend Renderer specific to donut plots.  Set by default
-     * when user creates a donut plot.
-     */
-    $.jqplot.DonutLegendRenderer.prototype.init = function(options) {
-        // Group: Properties
-        //
-        // prop: numberRows
-        // Maximum number of rows in the legend.  0 or null for unlimited.
-        this.numberRows = null;
-        // prop: numberColumns
-        // Maximum number of columns in the legend.  0 or null for unlimited.
-        this.numberColumns = null;
-        $.extend(true, this, options);
-    };
-    
-    // called with context of legend
-    $.jqplot.DonutLegendRenderer.prototype.draw = function() {
-        var legend = this;
-        if (this.show) {
-            var series = this._series;
-            var ss = 'position:absolute;';
-            ss += (this.background) ? 'background:'+this.background+';' : '';
-            ss += (this.border) ? 'border:'+this.border+';' : '';
-            ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
-            ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
-            ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
-            ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : '';
-            ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : '';
-            ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : '';
-            ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : '';
-            this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
-            // Donut charts legends don't go by number of series, but by number of data points
-            // in the series.  Refactor things here for that.
-            
-            var pad = false, 
-                reverse = false,
-                nr, nc;
-            var s = series[0];
-            var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors);
-            
-            if (s.show) {
-                var pd = s.data;
-                if (this.numberRows) {
-                    nr = this.numberRows;
-                    if (!this.numberColumns){
-                        nc = Math.ceil(pd.length/nr);
-                    }
-                    else{
-                        nc = this.numberColumns;
-                    }
-                }
-                else if (this.numberColumns) {
-                    nc = this.numberColumns;
-                    nr = Math.ceil(pd.length/this.numberColumns);
-                }
-                else {
-                    nr = pd.length;
-                    nc = 1;
-                }
-                
-                var i, j, tr, td1, td2, lt, rs, color;
-                var idx = 0;    
-                
-                for (i=0; i<nr; i++) {
-                    if (reverse){
-                        tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem);
-                    }
-                    else{
-                        tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem);
-                    }
-                    for (j=0; j<nc; j++) {
-                        if (idx < pd.length){
-                            lt = this.labels[idx] || pd[idx][0].toString();
-                            color = colorGenerator.next();
-                            if (!reverse){
-                                if (i>0){
-                                    pad = true;
-                                }
-                                else{
-                                    pad = false;
-                                }
-                            }
-                            else{
-                                if (i == nr -1){
-                                    pad = false;
-                                }
-                                else{
-                                    pad = true;
-                                }
-                            }
-                            rs = (pad) ? this.rowSpacing : '0';
-                
-                            td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
-                                '<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+
-                                '</div></td>');
-                            td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
-                            if (this.escapeHtml){
-                                td2.text(lt);
-                            }
-                            else {
-                                td2.html(lt);
-                            }
-                            if (reverse) {
-                                td2.prependTo(tr);
-                                td1.prependTo(tr);
-                            }
-                            else {
-                                td1.appendTo(tr);
-                                td2.appendTo(tr);
-                            }
-                            pad = true;
-                        }
-                        idx++;
-                    }   
-                }
-            }
-        }
-        return this._elem;                
-    };
-    
-    // setup default renderers for axes and legend so user doesn't have to
-    // called with scope of plot
-    function preInit(target, data, options) {
-        options = options || {};
-        options.axesDefaults = options.axesDefaults || {};
-        options.legend = options.legend || {};
-        options.seriesDefaults = options.seriesDefaults || {};
-        // only set these if there is a donut series
-        var setopts = false;
-        if (options.seriesDefaults.renderer == $.jqplot.DonutRenderer) {
-            setopts = true;
-        }
-        else if (options.series) {
-            for (var i=0; i < options.series.length; i++) {
-                if (options.series[i].renderer == $.jqplot.DonutRenderer) {
-                    setopts = true;
-                }
-            }
-        }
-        
-        if (setopts) {
-            options.axesDefaults.renderer = $.jqplot.DonutAxisRenderer;
-            options.legend.renderer = $.jqplot.DonutLegendRenderer;
-            options.legend.preDraw = true;
-            options.seriesDefaults.pointLabels = {show: false};
-        }
-    }
-    
-    // called with scope of plot.
-    function postInit(target, data, options) {
-        // if multiple series, add a reference to the previous one so that
-        // donut rings can nest.
-        for (var i=1; i<this.series.length; i++) {
-            if (!this.series[i]._previousSeries.length){
-                for (var j=0; j<i; j++) {
-                    if (this.series[i].renderer.constructor == $.jqplot.DonutRenderer && this.series[j].renderer.constructor == $.jqplot.DonutRenderer) {
-                        this.series[i]._previousSeries.push(this.series[j]);
-                    }
-                }
-            }
-        }
-        for (i=0; i<this.series.length; i++) {
-            if (this.series[i].renderer.constructor == $.jqplot.DonutRenderer) {
-                this.series[i]._numberSeries = this.series.length;
-                // don't allow mouseover and mousedown at same time.
-                if (this.series[i].highlightMouseOver) {
-                    this.series[i].highlightMouseDown = false;
-                }
-            }
-        }
-    }
-    
-    var postParseOptionsRun = false;
-    // called with scope of plot
-    function postParseOptions(options) {
-        for (var i=0; i<this.series.length; i++) {
-            this.series[i].seriesColors = this.seriesColors;
-            this.series[i].colorGenerator = $.jqplot.colorGenerator;
-        }
-    }
-    
-    function highlight (plot, sidx, pidx) {
-        var s = plot.series[sidx];
-        var canvas = plot.plugins.donutRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        s._highlightedPoint = pidx;
-        plot.plugins.donutRenderer.highlightedSeriesIndex = sidx;
-        s.renderer.drawSlice.call(s, canvas._ctx, s._sliceAngles[pidx][0], s._sliceAngles[pidx][1], s.highlightColors[pidx], false);
-    }
-    
-    function unhighlight (plot) {
-        var canvas = plot.plugins.donutRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        for (var i=0; i<plot.series.length; i++) {
-            plot.series[i]._highlightedPoint = null;
-        }
-        plot.plugins.donutRenderer.highlightedSeriesIndex = null;
-        plot.target.trigger('jqplotDataUnhighlight');
-    }
- 
-    function handleMove(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt1 = jQuery.Event('jqplotDataMouseOver');
-            evt1.pageX = ev.pageX;
-            evt1.pageY = ev.pageY;
-            plot.target.trigger(evt1, ins);
-            if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.donutRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, ins[0], ins[1]);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    } 
-    
-    function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.donutRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, ins[0], ins[1]);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    }
-    
-    function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
-        var idx = plot.plugins.donutRenderer.highlightedSeriesIndex;
-        if (idx != null && plot.series[idx].highlightMouseDown) {
-            unhighlight(plot);
-        }
-    }
-    
-    function handleClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt = jQuery.Event('jqplotDataClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }
-    
-    function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var idx = plot.plugins.donutRenderer.highlightedSeriesIndex;
-            if (idx != null && plot.series[idx].highlightMouseDown) {
-                unhighlight(plot);
-            }
-            var evt = jQuery.Event('jqplotDataRightClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }    
-    
-    // called within context of plot
-    // create a canvas which we can draw on.
-    // insert it before the eventCanvas, so eventCanvas will still capture events.
-    function postPlotDraw() {
-        // Memory Leaks patch    
-        if (this.plugins.donutRenderer && this.plugins.donutRenderer.highlightCanvas) {
-            this.plugins.donutRenderer.highlightCanvas.resetCanvas();
-            this.plugins.donutRenderer.highlightCanvas = null;
-        }
-
-        this.plugins.donutRenderer = {highlightedSeriesIndex:null};
-        this.plugins.donutRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
-        // do we have any data labels?  if so, put highlight canvas before those
-        // Fix for broken jquery :first selector with canvas (VML) elements.
-        var labels = $(this.targetId+' .jqplot-data-label');
-        if (labels.length) {
-            $(labels[0]).before(this.plugins.donutRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-donutRenderer-highlight-canvas', this._plotDimensions, this));
-        }
-        // else put highlight canvas before event canvas.
-        else {
-            this.eventCanvas._elem.before(this.plugins.donutRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-donutRenderer-highlight-canvas', this._plotDimensions, this));
-        }
-        var hctx = this.plugins.donutRenderer.highlightCanvas.setContext();
-        this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
-    }
-    
-    $.jqplot.preInitHooks.push(preInit);
-    
-    $.jqplot.DonutTickRenderer = function() {
-        $.jqplot.AxisTickRenderer.call(this);
-    };
-    
-    $.jqplot.DonutTickRenderer.prototype = new $.jqplot.AxisTickRenderer();
-    $.jqplot.DonutTickRenderer.prototype.constructor = $.jqplot.DonutTickRenderer;
-    
-})(jQuery);
-    
-    
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.donutRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.donutRenderer.min.js
deleted file mode 100644
index 214336b..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.donutRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(e){e.jqplot.DonutRenderer=function(){e.jqplot.LineRenderer.call(this)};e.jqplot.DonutRenderer.prototype=new e.jqplot.LineRenderer();e.jqplot.DonutRenderer.prototype.constructor=e.jqplot.DonutRenderer;e.jqplot.DonutRenderer.prototype.init=function(p,t){this.diameter=null;this.innerDiameter=null;this.thickness=null;this.padding=20;this.sliceMargin=0;this.ringMargin=null;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.dataLabels="percent";this.showDataLabels=false;this.dataLabelFormatString=null;this.dataLabelThreshold=3;this.dataLabelPositionFactor=0.4;this.dataLabelNudge=0;this.startAngle=0;this.tickRenderer=e.jqplot.DonutTickRenderer;this._drawData=true;this._type="donut";if(p.highlightMouseDown&&p.highlightMouseOver==null){p.highlightMouseOver=false}e.extend(true,this,p);if(this.diameter!=null){this.diameter=this.diameter-this.sliceMargin}this._diameter=null;this._innerDiameter=null;this._radius=null;this._innerRadius=null;this._thickness=null;this._previousSeries=[];this._numberSeries=1;this._sliceAngles=[];this._highlightedPoint=null;if(this.highlightColors.length==0){for(var r=0;r<this.seriesColors.length;r++){var q=e.jqplot.getColorComponents(this.seriesColors[r]);var n=[q[0],q[1],q[2]];var s=n[0]+n[1]+n[2];for(var o=0;o<3;o++){n[o]=(s>570)?n[o]*0.8:n[o]+0.3*(255-n[o]);n[o]=parseInt(n[o],10)}this.highlightColors.push("rgb("+n[0]+","+n[1]+","+n[2]+")")}}t.postParseOptionsHooks.addOnce(l);t.postInitHooks.addOnce(g);t.eventListenerHooks.addOnce("jqplotMouseMove",b);t.eventListenerHooks.addOnce("jqplotMouseDown",a);t.eventListenerHooks.addOnce("jqplotMouseUp",j);t.eventListenerHooks.addOnce("jqplotClick",f);t.eventListenerHooks.addOnce("jqplotRightClick",m);t.postDrawHooks.addOnce(h)};e.jqplot.DonutRenderer.prototype.setGridData=function(s){var o=[];var t=[];var n=this.startAngle/180*Math.PI;var r=0;this._drawData=false;for(var q=0;q<this.data.length;q++){if(this.data[q][1]!=0){this._drawData=true}o.push(this.data[q][1]);t.push([this.data[q][0]]);if(q>0){o[q]+=o[q-1]}r+=this.data[q][1]}var p=Math.PI*2/o[o.length-1];for(var q=0;q<o.length;q++){t[q][1]=o[q]*p;t[q][2]=this.data[q][1]/r}this.gridData=t};e.jqplot.DonutRenderer.prototype.makeGridData=function(s,t){var o=[];var u=[];var r=0;var n=this.startAngle/180*Math.PI;this._drawData=false;for(var q=0;q<s.length;q++){if(this.data[q][1]!=0){this._drawData=true}o.push(s[q][1]);u.push([s[q][0]]);if(q>0){o[q]+=o[q-1]}r+=s[q][1]}var p=Math.PI*2/o[o.length-1];for(var q=0;q<o.length;q++){u[q][1]=o[q]*p;u[q][2]=s[q][1]/r}return u};e.jqplot.DonutRenderer.prototype.drawSlice=function(x,u,t,p,s){var n=this._diameter/2;var v=n-this._thickness;var w=this.fill;x.save();x.translate(this._center[0],this._center[1]);if(s){for(var q=0;q<this.shadowDepth;q++){x.save();x.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));o()}}else{o()}function o(){if(t>6.282+this.startAngle){t=6.282+this.startAngle;if(u>t){u=6.281+this.startAngle}}if(u>=t){return}x.beginPath();x.fillStyle=p;x.strokeStyle=p;x.arc(0,0,n,u,t,false);x.lineTo(v*Math.cos(t),v*Math.sin(t));x.arc(0,0,v,t,u,true);x.closePath();if(w){x.fill()}else{x.stroke()}}if(s){for(var q=0;q<this.shadowDepth;q++){x.restore()}}x.restore()};e.jqplot.DonutRenderer.prototype.draw=function(N,V,t,P){var Q;var J=(t!=undefined)?t:{};var q=0;var p=0;var u=1;if(t.legendInfo&&t.legendInfo.placement=="insideGrid"){var I=t.legendInfo;switch(I.location){case"nw":q=I.width+I.xoffset;break;case"w":q=I.width+I.xoffset;break;case"sw":q=I.width+I.xoffset;break;case"ne":q=I.width+I.xoffset;u=-1;break;case"e":q=I.width+I.xoffset;u=-1;break;case"se":q=I.width+I.xoffset;u=-1;break;case"n":p=I.height+I.yoffset;break;case"s":p=I.height+I.yoffset;u=-1;break;default:break}}var B=(J.shadow!=undefined)?J.shadow:this.shadow;var W=(J.showLine!=undefined)?J.showLine:this.showLine;var O=(J.fill!=undefined)?J.fill:this.fill;var s=N.canvas.width;var H=N.canvas.height;var G=s-q-2*this.padding;var R=H-p-2*this.padding;var v=Math.min(G,R);var T=v;var X=(this.ringMargin==null)?this.sliceMargin*2:this.ringMargin;for(var Q=0;Q<this._previousSeries.length;Q++){T-=2*this._previousSeries[Q]._thickness+2*X}this._diameter=this.diameter||T;if(this.innerDiameter!=null){var M=(this._numberSeries>1&&this.index>0)?this._previousSeries[0]._diameter:this._diameter;this._thickness=this.thickness||(M-this.innerDiameter-2*X*this._numberSeries)/this._numberSeries/2}else{this._thickness=this.thickness||v/2/(this._numberSeries+1)*0.85}var K=this._radius=this._diameter/2;this._innerRadius=this._radius-this._thickness;var o=this.startAngle/180*Math.PI;this._center=[(s-u*q)/2+u*q,(H-u*p)/2+u*p];if(this.shadow){var L="rgba(0,0,0,"+this.shadowAlpha+")";for(var Q=0;Q<V.length;Q++){var A=(Q==0)?o:V[Q-1][1]+o;A+=this.sliceMargin/180*Math.PI;this.renderer.drawSlice.call(this,N,A,V[Q][1]+o,L,true)}}for(var Q=0;Q<V.length;Q++){var A=(Q==0)?o:V[Q-1][1]+o;A+=this.sliceMargin/180*Math.PI;var z=V[Q][1]+o;this._sliceAngles.push([A,z]);this.renderer.drawSlice.call(this,N,A,z,this.seriesColors[Q],false);if(this.showDataLabels&&V[Q][2]*100>=this.dataLabelThreshold){var S,U=(A+z)/2,C;if(this.dataLabels=="label"){S=this.dataLabelFormatString||"%s";C=e.jqplot.sprintf(S,V[Q][0])}else{if(this.dataLabels=="value"){S=this.dataLabelFormatString||"%d";C=e.jqplot.sprintf(S,this.data[Q][1])}else{if(this.dataLabels=="percent"){S=this.dataLabelFormatString||"%d%%";C=e.jqplot.sprintf(S,V[Q][2]*100)}else{if(this.dataLabels.constructor==Array){S=this.dataLabelFormatString||"%s";C=e.jqplot.sprintf(S,this.dataLabels[Q])}}}}var n=this._innerRadius+this._thickness*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var F=this._center[0]+Math.cos(U)*n+this.canvas._offsets.left;var E=this._center[1]+Math.sin(U)*n+this.canvas._offsets.top;var D=e('<span class="jqplot-donut-series jqplot-data-label" style="position:absolute;">'+C+"</span>").insertBefore(P.eventCanvas._elem);F-=D.width()/2;E-=D.height()/2;F=Math.round(F);E=Math.round(E);D.css({left:F,top:E})}}};e.jqplot.DonutAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.DonutAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.DonutAxisRenderer.prototype.constructor=e.jqplot.DonutAxisRenderer;e.jqplot.DonutAxisRenderer.prototype.init=function(n){this.tickRenderer=e.jqplot.DonutTickRenderer;e.extend(true,this,n);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};e.jqplot.DonutLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.DonutLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.DonutLegendRenderer.prototype.constructor=e.jqplot.DonutLegendRenderer;e.jqplot.DonutLegendRenderer.prototype.init=function(n){this.numberRows=null;this.numberColumns=null;e.extend(true,this,n)};e.jqplot.DonutLegendRenderer.prototype.draw=function(){var q=this;if(this.show){var y=this._series;var B="position:absolute;";B+=(this.background)?"background:"+this.background+";":"";B+=(this.border)?"border:"+this.border+";":"";B+=(this.fontSize)?"font-size:"+this.fontSize+";":"";B+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";B+=(this.textColor)?"color:"+this.textColor+";":"";B+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";B+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";B+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";B+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=e('<table class="jqplot-table-legend" style="'+B+'"></table>');var F=false,x=false,n,v;var z=y[0];var o=new e.jqplot.ColorGenerator(z.seriesColors);if(z.show){var G=z.data;if(this.numberRows){n=this.numberRows;if(!this.numberColumns){v=Math.ceil(G.length/n)}else{v=this.numberColumns}}else{if(this.numberColumns){v=this.numberColumns;n=Math.ceil(G.length/this.numberColumns)}else{n=G.length;v=1}}var E,D,p,t,r,u,w,C;var A=0;for(E=0;E<n;E++){if(x){p=e('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{p=e('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(D=0;D<v;D++){if(A<G.length){u=this.labels[A]||G[A][0].toString();C=o.next();if(!x){if(E>0){F=true}else{F=false}}else{if(E==n-1){F=false}else{F=true}}w=(F)?this.rowSpacing:"0";t=e('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+w+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+C+';"></div></div></td>');r=e('<td class="jqplot-table-legend" style="padding-top:'+w+';"></td>');if(this.escapeHtml){r.text(u)}else{r.html(u)}if(x){r.prependTo(p);t.prependTo(p)}else{t.appendTo(p);r.appendTo(p)}F=true}A++}}}}return this._elem};function c(r,q,o){o=o||{};o.axesDefaults=o.axesDefaults||{};o.legend=o.legend||{};o.seriesDefaults=o.seriesDefaults||{};var n=false;if(o.seriesDefaults.renderer==e.jqplot.DonutRenderer){n=true}else{if(o.series){for(var p=0;p<o.series.length;p++){if(o.series[p].renderer==e.jqplot.DonutRenderer){n=true}}}}if(n){o.axesDefaults.renderer=e.jqplot.DonutAxisRenderer;o.legend.renderer=e.jqplot.DonutLegendRenderer;o.legend.preDraw=true;o.seriesDefaults.pointLabels={show:false}}}function g(r,q,o){for(var p=1;p<this.series.length;p++){if(!this.series[p]._previousSeries.length){for(var n=0;n<p;n++){if(this.series[p].renderer.constructor==e.jqplot.DonutRenderer&&this.series[n].renderer.constructor==e.jqplot.DonutRenderer){this.series[p]._previousSeries.push(this.series[n])}}}}for(p=0;p<this.series.length;p++){if(this.series[p].renderer.constructor==e.jqplot.DonutRenderer){this.series[p]._numberSeries=this.series.length;if(this.series[p].highlightMouseOver){this.series[p].highlightMouseDown=false}}}}var k=false;function l(n){for(var o=0;o<this.series.length;o++){this.series[o].seriesColors=this.seriesColors;this.series[o].colorGenerator=e.jqplot.colorGenerator}}function d(r,q,p){var o=r.series[q];var n=r.plugins.donutRenderer.highlightCanvas;n._ctx.clearRect(0,0,n._ctx.canvas.width,n._ctx.canvas.height);o._highlightedPoint=p;r.plugins.donutRenderer.highlightedSeriesIndex=q;o.renderer.drawSlice.call(o,n._ctx,o._sliceAngles[p][0],o._sliceAngles[p][1],o.highlightColors[p],false)}function i(p){var n=p.plugins.donutRenderer.highlightCanvas;n._ctx.clearRect(0,0,n._ctx.canvas.width,n._ctx.canvas.height);for(var o=0;o<p.series.length;o++){p.series[o]._highlightedPoint=null}p.plugins.donutRenderer.highlightedSeriesIndex=null;p.target.trigger("jqplotDataUnhighlight")}function b(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];var o=jQuery.Event("jqplotDataMouseOver");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p);if(s.series[p[0]].highlightMouseOver&&!(p[0]==s.plugins.donutRenderer.highlightedSeriesIndex&&p[1]==s.series[p[0]]._highlightedPoint)){var n=jQuery.Event("jqplotDataHighlight");n.pageX=r.pageX;n.pageY=r.pageY;s.target.trigger(n,p);d(s,p[0],p[1])}}else{if(t==null){i(s)}}}function a(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];if(r.series[o[0]].highlightMouseDown&&!(o[0]==r.plugins.donutRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){var n=jQuery.Event("jqplotDataHighlight");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o);d(r,o[0],o[1])}}else{if(s==null){i(r)}}}function j(p,o,s,r,q){var n=q.plugins.donutRenderer.highlightedSeriesIndex;if(n!=null&&q.series[n].highlightMouseDown){i(q)}}function f(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var n=jQuery.Event("jqplotDataClick");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o)}}function m(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];var n=s.plugins.donutRenderer.highlightedSeriesIndex;if(n!=null&&s.series[n].highlightMouseDown){i(s)}var o=jQuery.Event("jqplotDataRightClick");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p)}}function h(){if(this.plugins.donutRenderer&&this.plugins.donutRenderer.highlightCanvas){this.plugins.donutRenderer.highlightCanvas.resetCanvas();this.plugins.donutRenderer.highlightCanvas=null}this.plugins.donutRenderer={highlightedSeriesIndex:null};this.plugins.donutRenderer.highlightCanvas=new e.jqplot.GenericCanvas();var o=e(this.targetId+" .jqplot-data-label");if(o.length){e(o[0]).before(this.plugins.donutRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-donutRenderer-highlight-canvas",this._plotDimensions,this))}else{this.eventCanvas._elem.before(this.plugins.donutRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-donutRenderer-highlight-canvas",this._plotDimensions,this))}var n=this.plugins.donutRenderer.highlightCanvas.setContext();this.eventCanvas._elem.bind("mouseleave",{plot:this},function(p){i(p.data.plot)})}e.jqplot.preInitHooks.push(c);e.jqplot.DonutTickRenderer=function(){e.jqplot.AxisTickRenderer.call(this)};e.jqplot.DonutTickRenderer.prototype=new e.jqplot.AxisTickRenderer();e.jqplot.DonutTickRenderer.prototype.constructor=e.jqplot.DonutTickRenderer})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dragable.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dragable.js
deleted file mode 100644
index e4204dc..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dragable.js
+++ /dev/null
@@ -1,224 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    
-    /**
-     * Class: $.jqplot.Dragable
-     * Plugin to make plotted points dragable by the user.
-     */
-    $.jqplot.Dragable = function(options) {
-        // Group: Properties
-        this.markerRenderer = new $.jqplot.MarkerRenderer({shadow:false});
-        this.shapeRenderer = new $.jqplot.ShapeRenderer();
-        this.isDragging = false;
-        this.isOver = false;
-        this._ctx;
-        this._elem;
-        this._point;
-        this._gridData;
-        // prop: color
-        // CSS color spec for the dragged point (and adjacent line segment or bar).
-        this.color;
-        // prop: constrainTo
-        // Constrain dragging motion to an axis or to none.
-        // Allowable values are 'none', 'x', 'y'
-        this.constrainTo = 'none';  // 'x', 'y', or 'none';
-        $.extend(true, this, options);
-    };
-    
-    function DragCanvas() {
-        $.jqplot.GenericCanvas.call(this);
-        this.isDragging = false;
-        this.isOver = false;
-        this._neighbor;
-        this._cursors = [];
-    }
-    
-    DragCanvas.prototype = new $.jqplot.GenericCanvas();
-    DragCanvas.prototype.constructor = DragCanvas;
-    
-    
-    // called within scope of series
-    $.jqplot.Dragable.parseOptions = function (defaults, opts) {
-        var options = opts || {};
-        this.plugins.dragable = new $.jqplot.Dragable(options.dragable);
-        // since this function is called before series options are parsed,
-        // we can set this here and it will be overridden if needed.
-        this.isDragable = $.jqplot.config.enablePlugins;
-    };
-    
-    // called within context of plot
-    // create a canvas which we can draw on.
-    // insert it before the eventCanvas, so eventCanvas will still capture events.
-    // add a new DragCanvas object to the plot plugins to handle drawing on this new canvas.
-    $.jqplot.Dragable.postPlotDraw = function() {
-        // Memory Leaks patch    
-        if (this.plugins.dragable && this.plugins.dragable.highlightCanvas) {
-            this.plugins.dragable.highlightCanvas.resetCanvas();
-            this.plugins.dragable.highlightCanvas = null;
-        }
-
-        this.plugins.dragable = {previousCursor:'auto', isOver:false};
-        this.plugins.dragable.dragCanvas = new DragCanvas();
-        
-        this.eventCanvas._elem.before(this.plugins.dragable.dragCanvas.createElement(this._gridPadding, 'jqplot-dragable-canvas', this._plotDimensions, this));
-        var dctx = this.plugins.dragable.dragCanvas.setContext();
-    };
-    
-    //$.jqplot.preInitHooks.push($.jqplot.Dragable.init);
-    $.jqplot.preParseSeriesOptionsHooks.push($.jqplot.Dragable.parseOptions);
-    $.jqplot.postDrawHooks.push($.jqplot.Dragable.postPlotDraw);
-    $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMove]);
-    $.jqplot.eventListenerHooks.push(['jqplotMouseDown', handleDown]);
-    $.jqplot.eventListenerHooks.push(['jqplotMouseUp', handleUp]);
-
-    
-    function initDragPoint(plot, neighbor) {
-        var s = plot.series[neighbor.seriesIndex];
-        var drag = s.plugins.dragable;
-        
-        // first, init the mark renderer for the dragged point
-        var smr = s.markerRenderer;
-        var mr = drag.markerRenderer;
-        mr.style = smr.style;
-        mr.lineWidth = smr.lineWidth + 2.5;
-        mr.size = smr.size + 5;
-        if (!drag.color) {
-            var rgba = $.jqplot.getColorComponents(smr.color);
-            var newrgb = [rgba[0], rgba[1], rgba[2]];
-            var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]);
-            drag.color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')';
-        }
-        mr.color = drag.color;
-        mr.init();
-
-        var start = (neighbor.pointIndex > 0) ? neighbor.pointIndex - 1 : 0;
-        var end = neighbor.pointIndex+2;
-        drag._gridData = s.gridData.slice(start, end);
-    }
-    
-    function handleMove(ev, gridpos, datapos, neighbor, plot) {
-        if (plot.plugins.dragable.dragCanvas.isDragging) {
-            var dc = plot.plugins.dragable.dragCanvas;
-            var dp = dc._neighbor;
-            var s = plot.series[dp.seriesIndex];
-            var drag = s.plugins.dragable;
-            var gd = s.gridData;
-            
-            // compute the new grid position with any constraints.
-            var x = (drag.constrainTo == 'y') ? dp.gridData[0] : gridpos.x;
-            var y = (drag.constrainTo == 'x') ? dp.gridData[1] : gridpos.y;
-            
-            // compute data values for any listeners.
-            var xu = s._xaxis.series_p2u(x);
-            var yu = s._yaxis.series_p2u(y);
-            
-            // clear the canvas then redraw effect at new position.
-            var ctx = dc._ctx;
-            ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-            
-            // adjust our gridData for the new mouse position
-            if (dp.pointIndex > 0) {
-                drag._gridData[1] = [x, y];
-            }
-            else {
-                drag._gridData[0] = [x, y];
-            }
-            plot.series[dp.seriesIndex].draw(dc._ctx, {gridData:drag._gridData, shadow:false, preventJqPlotSeriesDrawTrigger:true, color:drag.color, markerOptions:{color:drag.color, shadow:false}, trendline:{show:false}});
-            plot.target.trigger('jqplotSeriesPointChange', [dp.seriesIndex, dp.pointIndex, [xu,yu], [x,y]]);
-        }
-        else if (neighbor != null) {
-            var series = plot.series[neighbor.seriesIndex];
-            if (series.isDragable) {
-                var dc = plot.plugins.dragable.dragCanvas;
-                if (!dc.isOver) {
-                    dc._cursors.push(ev.target.style.cursor);
-                    ev.target.style.cursor = "pointer";
-                }
-                dc.isOver = true;
-            }
-        }
-        else if (neighbor == null) {
-            var dc = plot.plugins.dragable.dragCanvas;
-            if (dc.isOver) {
-                ev.target.style.cursor = dc._cursors.pop();
-                dc.isOver = false;
-            }
-        }
-    }
-    
-    function handleDown(ev, gridpos, datapos, neighbor, plot) {
-        var dc = plot.plugins.dragable.dragCanvas;
-        dc._cursors.push(ev.target.style.cursor);
-        if (neighbor != null) {
-            var s = plot.series[neighbor.seriesIndex];
-            var drag = s.plugins.dragable;
-            if (s.isDragable && !dc.isDragging) {
-                dc._neighbor = neighbor;
-                dc.isDragging = true;
-                initDragPoint(plot, neighbor);
-                drag.markerRenderer.draw(s.gridData[neighbor.pointIndex][0], s.gridData[neighbor.pointIndex][1], dc._ctx);
-                ev.target.style.cursor = "move";
-                plot.target.trigger('jqplotDragStart', [neighbor.seriesIndex, neighbor.pointIndex, gridpos, datapos]);
-            }
-        }
-        // Just in case of a hickup, we'll clear the drag canvas and reset.
-        else {
-           var ctx = dc._ctx;
-           ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-           dc.isDragging = false;
-        }
-    }
-    
-    function handleUp(ev, gridpos, datapos, neighbor, plot) {
-        if (plot.plugins.dragable.dragCanvas.isDragging) {
-            var dc = plot.plugins.dragable.dragCanvas;
-            // clear the canvas
-            var ctx = dc._ctx;
-            ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-            dc.isDragging = false;
-            // redraw the series canvas at the new point.
-            var dp = dc._neighbor;
-            var s = plot.series[dp.seriesIndex];
-            var drag = s.plugins.dragable;
-            // compute the new grid position with any constraints.
-            var x = (drag.constrainTo == 'y') ? dp.data[0] : datapos[s.xaxis];
-            var y = (drag.constrainTo == 'x') ? dp.data[1] : datapos[s.yaxis];
-            // var x = datapos[s.xaxis];
-            // var y = datapos[s.yaxis];
-            s.data[dp.pointIndex][0] = x;
-            s.data[dp.pointIndex][1] = y;
-            plot.drawSeries({preventJqPlotSeriesDrawTrigger:true}, dp.seriesIndex);
-            dc._neighbor = null;
-            ev.target.style.cursor = dc._cursors.pop();
-            plot.target.trigger('jqplotDragStop', [gridpos, datapos]);
-        }
-    }
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dragable.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dragable.min.js
deleted file mode 100644
index 989fed5..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.dragable.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(d){d.jqplot.Dragable=function(g){this.markerRenderer=new d.jqplot.MarkerRenderer({shadow:false});this.shapeRenderer=new d.jqplot.ShapeRenderer();this.isDragging=false;this.isOver=false;this._ctx;this._elem;this._point;this._gridData;this.color;this.constrainTo="none";d.extend(true,this,g)};function b(){d.jqplot.GenericCanvas.call(this);this.isDragging=false;this.isOver=false;this._neighbor;this._cursors=[]}b.prototype=new d.jqplot.GenericCanvas();b.prototype.constructor=b;d.jqplot.Dragable.parseOptions=function(i,h){var g=h||{};this.plugins.dragable=new d.jqplot.Dragable(g.dragable);this.isDragable=d.jqplot.config.enablePlugins};d.jqplot.Dragable.postPlotDraw=function(){if(this.plugins.dragable&&this.plugins.dragable.highlightCanvas){this.plugins.dragable.highlightCanvas.resetCanvas();this.plugins.dragable.highlightCanvas=null}this.plugins.dragable={previousCursor:"auto",isOver:false};this.plugins.dragable.dragCanvas=new b();this.eventCanvas._elem.before(this.plugins.dragable.dragCanvas.createElement(this._gridPadding,"jqplot-dragable-canvas",this._plotDimensions,this));var g=this.plugins.dragable.dragCanvas.setContext()};d.jqplot.preParseSeriesOptionsHooks.push(d.jqplot.Dragable.parseOptions);d.jqplot.postDrawHooks.push(d.jqplot.Dragable.postPlotDraw);d.jqplot.eventListenerHooks.push(["jqplotMouseMove",e]);d.jqplot.eventListenerHooks.push(["jqplotMouseDown",c]);d.jqplot.eventListenerHooks.push(["jqplotMouseUp",a]);function f(n,p){var q=n.series[p.seriesIndex];var m=q.plugins.dragable;var h=q.markerRenderer;var i=m.markerRenderer;i.style=h.style;i.lineWidth=h.lineWidth+2.5;i.size=h.size+5;if(!m.color){var l=d.jqplot.getColorComponents(h.color);var o=[l[0],l[1],l[2]];var k=(l[3]>=0.6)?l[3]*0.6:l[3]*(2-l[3]);m.color="rgba("+o[0]+","+o[1]+","+o[2]+","+k+")"}i.color=m.color;i.init();var g=(p.pointIndex>0)?p.pointIndex-1:0;var j=p.pointIndex+2;m._gridData=q.gridData.slice(g,j)}function e(o,l,h,t,m){if(m.plugins.dragable.dragCanvas.isDragging){var u=m.plugins.dragable.dragCanvas;var i=u._neighbor;var w=m.series[i.seriesIndex];var k=w.plugins.dragable;var r=w.gridData;var p=(k.constrainTo=="y")?i.gridData[0]:l.x;var n=(k.constrainTo=="x")?i.gridData[1]:l.y;var g=w._xaxis.series_p2u(p);var q=w._yaxis.series_p2u(n);var v=u._ctx;v.clearRect(0,0,v.canvas.width,v.canvas.height);if(i.pointIndex>0){k._gridData[1]=[p,n]}else{k._gridData[0]=[p,n]}m.series[i.seriesIndex].draw(u._ctx,{gridData:k._gridData,shadow:false,preventJqPlotSeriesDrawTrigger:true,color:k.color,markerOptions:{color:k.color,shadow:false},trendline:{show:false}});m.target.trigger("jqplotSeriesPointChange",[i.seriesIndex,i.pointIndex,[g,q],[p,n]])}else{if(t!=null){var j=m.series[t.seriesIndex];if(j.isDragable){var u=m.plugins.dragable.dragCanvas;if(!u.isOver){u._cursors.push(o.target.style.cursor);o.target.style.cursor="pointer"}u.isOver=true}}else{if(t==null){var u=m.plugins.dragable.dragCanvas;if(u.isOver){o.target.style.cursor=u._cursors.pop();u.isOver=false}}}}}function c(k,i,g,l,j){var m=j.plugins.dragable.dragCanvas;m._cursors.push(k.target.style.cursor);if(l!=null){var o=j.series[l.seriesIndex];var h=o.plugins.dragable;if(o.isDragable&&!m.isDragging){m._neighbor=l;m.isDragging=true;f(j,l);h.markerRenderer.draw(o.gridData[l.pointIndex][0],o.gridData[l.pointIndex][1],m._ctx);k.target.style.cursor="move";j.target.trigger("jqplotDragStart",[l.seriesIndex,l.pointIndex,i,g])}}else{var n=m._ctx;n.clearRect(0,0,n.canvas.width,n.canvas.height);m.isDragging=false}}function a(m,j,g,o,k){if(k.plugins.dragable.dragCanvas.isDragging){var p=k.plugins.dragable.dragCanvas;var q=p._ctx;q.clearRect(0,0,q.canvas.width,q.canvas.height);p.isDragging=false;var h=p._neighbor;var r=k.series[h.seriesIndex];var i=r.plugins.dragable;var n=(i.constrainTo=="y")?h.data[0]:g[r.xaxis];var l=(i.constrainTo=="x")?h.data[1]:g[r.yaxis];r.data[h.pointIndex][0]=n;r.data[h.pointIndex][1]=l;k.drawSeries({preventJqPlotSeriesDrawTrigger:true},h.seriesIndex);p._neighbor=null;m.target.style.cursor=p._cursors.pop();k.target.trigger("jqplotDragStop",[j,g])}}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.enhancedLegendRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.enhancedLegendRenderer.js
deleted file mode 100644
index 941b911..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.enhancedLegendRenderer.js
+++ /dev/null
@@ -1,241 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    // class $.jqplot.EnhancedLegendRenderer
-    // Legend renderer which can specify the number of rows and/or columns in the legend.
-    $.jqplot.EnhancedLegendRenderer = function(){
-        $.jqplot.TableLegendRenderer.call(this);
-    };
-    
-    $.jqplot.EnhancedLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
-    $.jqplot.EnhancedLegendRenderer.prototype.constructor = $.jqplot.EnhancedLegendRenderer;
-    
-    // called with scope of legend.
-    $.jqplot.EnhancedLegendRenderer.prototype.init = function(options) {
-        // prop: numberRows
-        // Maximum number of rows in the legend.  0 or null for unlimited.
-        this.numberRows = null;
-        // prop: numberColumns
-        // Maximum number of columns in the legend.  0 or null for unlimited.
-        this.numberColumns = null;
-        // prop: seriesToggle
-        // false to not enable series on/off toggling on the legend.
-        // true or a fadein/fadeout speed (number of milliseconds or 'fast', 'normal', 'slow') 
-        // to enable show/hide of series on click of legend item.
-        this.seriesToggle = 'normal';
-        // prop: disableIEFading
-        // true to toggle series with a show/hide method only and not allow fading in/out.  
-        // This is to overcome poor performance of fade in some versions of IE.
-        this.disableIEFading = true;
-        $.extend(true, this, options);
-        
-        if (this.seriesToggle) {
-            $.jqplot.postDrawHooks.push(postDraw);
-        }
-    };
-    
-    // called with scope of legend
-    $.jqplot.EnhancedLegendRenderer.prototype.draw = function() {
-        var legend = this;
-        if (this.show) {
-            var series = this._series;
-			var s;
-            var ss = 'position:absolute;';
-            ss += (this.background) ? 'background:'+this.background+';' : '';
-            ss += (this.border) ? 'border:'+this.border+';' : '';
-            ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
-            ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
-            ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
-            ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : '';
-            ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : '';
-            ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : '';
-            ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : '';
-            this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
-            if (this.seriesToggle) {
-                this._elem.css('z-index', '3');
-            }
-        
-            var pad = false, 
-                reverse = false,
-                nr, nc;
-            if (this.numberRows) {
-                nr = this.numberRows;
-                if (!this.numberColumns){
-                    nc = Math.ceil(series.length/nr);
-                }
-                else{
-                    nc = this.numberColumns;
-                }
-            }
-            else if (this.numberColumns) {
-                nc = this.numberColumns;
-                nr = Math.ceil(series.length/this.numberColumns);
-            }
-            else {
-                nr = series.length;
-                nc = 1;
-            }
-                
-            var i, j, tr, td1, td2, lt, rs, div, div0, div1;
-            var idx = 0;
-            // check to see if we need to reverse
-            for (i=series.length-1; i>=0; i--) {
-                if (nc == 1 && series[i]._stack || series[i].renderer.constructor == $.jqplot.BezierCurveRenderer){
-                    reverse = true;
-                }
-            }    
-                
-            for (i=0; i<nr; i++) {
-                tr = $(document.createElement('tr'));
-                tr.addClass('jqplot-table-legend');
-                if (reverse){
-                    tr.prependTo(this._elem);
-                }
-                else{
-                    tr.appendTo(this._elem);
-                }
-                for (j=0; j<nc; j++) {
-                    if (idx < series.length && series[idx].show && series[idx].showLabel){
-                        s = series[idx];
-                        lt = this.labels[idx] || s.label.toString();
-                        if (lt) {
-                            var color = s.color;
-                            if (!reverse){
-                                if (i>0){
-                                    pad = true;
-                                }
-                                else{
-                                    pad = false;
-                                }
-                            }
-                            else{
-                                if (i == nr -1){
-                                    pad = false;
-                                }
-                                else{
-                                    pad = true;
-                                }
-                            }
-                            rs = (pad) ? this.rowSpacing : '0';
-
-                            td1 = $(document.createElement('td'));
-                            td1.addClass('jqplot-table-legend jqplot-table-legend-swatch');
-                            td1.css({textAlign: 'center', paddingTop: rs});
-
-                            div0 = $(document.createElement('div'));
-                            div0.addClass('jqplot-table-legend-swatch-outline');
-                            div1 = $(document.createElement('div'));
-                            div1.addClass('jqplot-table-legend-swatch');
-                            div1.css({backgroundColor: color, borderColor: color});
-
-                            td1.append(div0.append(div1));
-
-                            td2 = $(document.createElement('td'));
-                            td2.addClass('jqplot-table-legend jqplot-table-legend-label');
-                            td2.css('paddingTop', rs);
-                    
-                            // td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
-                            //     '<div><div class="jqplot-table-legend-swatch" style="background-color:'+color+';border-color:'+color+';"></div>'+
-                            //     '</div></td>');
-                            // td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
-                            if (this.escapeHtml){
-                                td2.text(lt);
-                            }
-                            else {
-                                td2.html(lt);
-                            }
-                            if (reverse) {
-                                if (this.showLabels) {td2.prependTo(tr);}
-                                if (this.showSwatches) {td1.prependTo(tr);}
-                            }
-                            else {
-                                if (this.showSwatches) {td1.appendTo(tr);}
-                                if (this.showLabels) {td2.appendTo(tr);}
-                            }
-                            
-                            if (this.seriesToggle) {
-
-                                // add an overlay for clicking series on/off
-                                // div0 = $(document.createElement('div'));
-                                // div0.addClass('jqplot-table-legend-overlay');
-                                // div0.css({position:'relative', left:0, top:0, height:'100%', width:'100%'});
-                                // tr.append(div0);
-
-                                var speed;
-                                if (typeof(this.seriesToggle) == 'string' || typeof(this.seriesToggle) == 'number') {
-                                    if (!$.jqplot.use_excanvas || !this.disableIEFading) {
-                                        speed = this.seriesToggle;
-                                    }
-                                } 
-                                if (this.showSwatches) {
-                                    td1.bind('click', {series:s, speed:speed}, handleToggle);
-                                    td1.addClass('jqplot-seriesToggle');
-                                }
-                                if (this.showLabels)  {
-                                    td2.bind('click', {series:s, speed:speed}, handleToggle);
-                                    td2.addClass('jqplot-seriesToggle');
-                                }
-                            }
-                            
-                            pad = true;
-                        }
-                    }
-                    idx++;
-                }
-                
-                td1 = td2 = div0 = div1 = null;   
-            }
-        }
-        return this._elem;
-    };
-
-    var handleToggle = function (ev) {
-        ev.data.series.toggleDisplay(ev);
-        if (ev.data.series.canvas._elem.hasClass('jqplot-series-hidden')) {
-            $(this).addClass('jqplot-series-hidden');
-            $(this).next('.jqplot-table-legend-label').addClass('jqplot-series-hidden');
-            $(this).prev('.jqplot-table-legend-swatch').addClass('jqplot-series-hidden');
-
-        }
-        else {
-            $(this).removeClass('jqplot-series-hidden');
-            $(this).next('.jqplot-table-legend-label').removeClass('jqplot-series-hidden');
-            $(this).prev('.jqplot-table-legend-swatch').removeClass('jqplot-series-hidden');
-        }
-    };
-    
-    // called with scope of plot.
-    var postDraw = function () {
-        if (this.legend.renderer.constructor == $.jqplot.EnhancedLegendRenderer && this.legend.seriesToggle){
-            var e = this.legend._elem.detach();
-            this.eventCanvas._elem.after(e);
-        }
-    };
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.enhancedLegendRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.enhancedLegendRenderer.min.js
deleted file mode 100644
index 23048b8..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.enhancedLegendRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(c){c.jqplot.EnhancedLegendRenderer=function(){c.jqplot.TableLegendRenderer.call(this)};c.jqplot.EnhancedLegendRenderer.prototype=new c.jqplot.TableLegendRenderer();c.jqplot.EnhancedLegendRenderer.prototype.constructor=c.jqplot.EnhancedLegendRenderer;c.jqplot.EnhancedLegendRenderer.prototype.init=function(d){this.numberRows=null;this.numberColumns=null;this.seriesToggle="normal";this.disableIEFading=true;c.extend(true,this,d);if(this.seriesToggle){c.jqplot.postDrawHooks.push(b)}};c.jqplot.EnhancedLegendRenderer.prototype.draw=function(){var f=this;if(this.show){var q=this._series;var r;var v="position:absolute;";v+=(this.background)?"background:"+this.background+";":"";v+=(this.border)?"border:"+this.border+";":"";v+=(this.fontSize)?"font-size:"+this.fontSize+";":"";v+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";v+=(this.textColor)?"color:"+this.textColor+";":"";v+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";v+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";v+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";v+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=c('<table class="jqplot-table-legend" style="'+v+'"></table>');if(this.seriesToggle){this._elem.css("z-index","3")}var A=false,p=false,d,n;if(this.numberRows){d=this.numberRows;if(!this.numberColumns){n=Math.ceil(q.length/d)}else{n=this.numberColumns}}else{if(this.numberColumns){n=this.numberColumns;d=Math.ceil(q.length/this.numberColumns)}else{d=q.length;n=1}}var z,x,e,l,k,m,o,t,h,g;var u=0;for(z=q.length-1;z>=0;z--){if(n==1&&q[z]._stack||q[z].renderer.constructor==c.jqplot.BezierCurveRenderer){p=true}}for(z=0;z<d;z++){e=c(document.createElement("tr"));e.addClass("jqplot-table-legend");if(p){e.prependTo(this._elem)}else{e.appendTo(this._elem)}for(x=0;x<n;x++){if(u<q.length&&q[u].show&&q[u].showLabel){r=q[u];m=this.labels[u]||r.label.toString();if(m){var w=r.color;if(!p){if(z>0){A=true}else{A=false}}else{if(z==d-1){A=false}else{A=true}}o=(A)?this.rowSpacing:"0";l=c(document.createElement("td"));l.addClass("jqplot-table-legend jqplot-table-legend-swatch");l.css({textAlign:"center",paddingTop:o});h=c(document.createElement("div"));h.addClass("jqplot-table-legend-swatch-outline");g=c(document.createElement("div"));g.addClass("jqplot-table-legend-swatch");g.css({backgroundColor:w,borderColor:w});l.append(h.append(g));k=c(document.createElement("td"));k.addClass("jqplot-table-legend jqplot-table-legend-label");k.css("paddingTop",o);if(this.escapeHtml){k.text(m)}else{k.html(m)}if(p){if(this.showLabels){k.prependTo(e)}if(this.showSwatches){l.prependTo(e)}}else{if(this.showSwatches){l.appendTo(e)}if(this.showLabels){k.appendTo(e)}}if(this.seriesToggle){var y;if(typeof(this.seriesToggle)=="string"||typeof(this.seriesToggle)=="number"){if(!c.jqplot.use_excanvas||!this.disableIEFading){y=this.seriesToggle}}if(this.showSwatches){l.bind("click",{series:r,speed:y},a);l.addClass("jqplot-seriesToggle")}if(this.showLabels){k.bind("click",{series:r,speed:y},a);k.addClass("jqplot-seriesToggle")}}A=true}}u++}l=k=h=g=null}}return this._elem};var a=function(d){d.data.series.toggleDisplay(d);if(d.data.series.canvas._elem.hasClass("jqplot-series-hidden")){c(this).addClass("jqplot-series-hidden");c(this).next(".jqplot-table-legend-label").addClass("jqplot-series-hidden");c(this).prev(".jqplot-table-legend-swatch").addClass("jqplot-series-hidden")}else{c(this).removeClass("jqplot-series-hidden");c(this).next(".jqplot-table-legend-label").removeClass("jqplot-series-hidden");c(this).prev(".jqplot-table-legend-swatch").removeClass("jqplot-series-hidden")}};var b=function(){if(this.legend.renderer.constructor==c.jqplot.EnhancedLegendRenderer&&this.legend.seriesToggle){var d=this.legend._elem.detach();this.eventCanvas._elem.after(d)}}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.funnelRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.funnelRenderer.js
deleted file mode 100644
index 2170b2a..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.funnelRenderer.js
+++ /dev/null
@@ -1,938 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-     * Class: $.jqplot.FunnelRenderer
-     * Plugin renderer to draw a funnel chart.
-     * x values, if present, will be used as labels.
-     * y values give area size.
-     * 
-     * Funnel charts will draw a single series
-     * only.
-     * 
-     * To use this renderer, you need to include the 
-     * funnel renderer plugin, for example:
-     * 
-     * > <script type="text/javascript" src="plugins/jqplot.funnelRenderer.js"></script>
-     * 
-     * Properties described here are passed into the $.jqplot function
-     * as options on the series renderer.  For example:
-     * 
-     * > plot2 = $.jqplot('chart2', [s1, s2], {
-     * >     seriesDefaults: {
-     * >         renderer:$.jqplot.FunnelRenderer,
-     * >         rendererOptions:{
-     * >              sectionMargin: 12,
-     * >              widthRatio: 0.3
-     * >          }
-     * >      }
-     * > });
-     * 
-     * IMPORTANT
-     * 
-     * *The funnel renderer will reorder data in descending order* so the largest value in
-     * the data set is first and displayed on top of the funnel.  Data will then
-     * be displayed in descending order down the funnel.  The area of each funnel
-     * section will correspond to the value of each data point relative to the sum
-     * of all values.  That is section area is proportional to section value divided by 
-     * sum of all section values.
-     * 
-     * If your data is not in descending order when passed into the plot, *it will be
-     * reordered* when stored in the series.data property.  A copy of the unordered
-     * data is kept in the series._unorderedData property.
-     * 
-     * A funnel plot will trigger events on the plot target
-     * according to user interaction.  All events return the event object,
-     * the series index, the point (section) index, and the point data for 
-     * the appropriate section. *Note* the point index will referr to the ordered
-     * data, not the original unordered data.
-     * 
-     * 'jqplotDataMouseOver' - triggered when mousing over a section.
-     * 'jqplotDataHighlight' - triggered the first time user mouses over a section,
-     * if highlighting is enabled.
-     * 'jqplotDataUnhighlight' - triggered when a user moves the mouse out of
-     * a highlighted section.
-     * 'jqplotDataClick' - triggered when the user clicks on a section.
-     * 'jqplotDataRightClick' - tiggered when the user right clicks on a section if
-     * the "captureRightClick" option is set to true on the plot.
-     */
-    $.jqplot.FunnelRenderer = function(){
-        $.jqplot.LineRenderer.call(this);
-    };
-    
-    $.jqplot.FunnelRenderer.prototype = new $.jqplot.LineRenderer();
-    $.jqplot.FunnelRenderer.prototype.constructor = $.jqplot.FunnelRenderer;
-    
-    // called with scope of a series
-    $.jqplot.FunnelRenderer.prototype.init = function(options, plot) {
-        // Group: Properties
-        //
-        // prop: padding
-        // padding between the funnel and plot edges, legend, etc.
-        this.padding = {top: 20, right: 20, bottom: 20, left: 20};
-        // prop: sectionMargin
-        // spacing between funnel sections in pixels.
-        this.sectionMargin = 6;
-        // prop: fill
-        // true or false, wether to fill the areas.
-        this.fill = true;
-        // prop: shadowOffset
-        // offset of the shadow from the area and offset of 
-        // each succesive stroke of the shadow from the last.
-        this.shadowOffset = 2;
-        // prop: shadowAlpha
-        // transparency of the shadow (0 = transparent, 1 = opaque)
-        this.shadowAlpha = 0.07;
-        // prop: shadowDepth
-        // number of strokes to apply to the shadow, 
-        // each stroke offset shadowOffset from the last.
-        this.shadowDepth = 5;
-        // prop: highlightMouseOver
-        // True to highlight area when moused over.
-        // This must be false to enable highlightMouseDown to highlight when clicking on a area.
-        this.highlightMouseOver = true;
-        // prop: highlightMouseDown
-        // True to highlight when a mouse button is pressed over a area.
-        // This will be disabled if highlightMouseOver is true.
-        this.highlightMouseDown = false;
-        // prop: highlightColors
-        // array of colors to use when highlighting an area.
-        this.highlightColors = [];
-        // prop: widthRatio
-        // The ratio of the width of the top of the funnel to the bottom.
-        // a ratio of 0 will make an upside down pyramid. 
-        this.widthRatio = 0.2;
-        // prop: lineWidth
-        // width of line if areas are stroked and not filled.
-        this.lineWidth = 2;
-        // prop: dataLabels
-        // Either 'label', 'value', 'percent' or an array of labels to place on the pie slices.
-        // Defaults to percentage of each pie slice.
-        this.dataLabels = 'percent';
-        // prop: showDataLabels
-        // true to show data labels on slices.
-        this.showDataLabels = false;
-        // prop: dataLabelFormatString
-        // Format string for data labels.  If none, '%s' is used for "label" and for arrays, '%d' for value and '%d%%' for percentage.
-        this.dataLabelFormatString = null;
-        // prop: dataLabelThreshold
-        // Threshhold in percentage (0 - 100) of pie area, below which no label will be displayed.
-        // This applies to all label types, not just to percentage labels.
-        this.dataLabelThreshold = 3;
-        this._type = 'funnel';
-        
-        this.tickRenderer = $.jqplot.FunnelTickRenderer;
-        
-        // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
-        if (options.highlightMouseDown && options.highlightMouseOver == null) {
-            options.highlightMouseOver = false;
-        }
-        
-        $.extend(true, this, options);
-        
-        // index of the currenty highlighted point, if any
-        this._highlightedPoint = null;
-        
-        // lengths of bases, or horizontal sides of areas of trapezoid.
-        this._bases = [];
-        // total area
-        this._atot;
-        // areas of segments.
-        this._areas = [];
-        // vertical lengths of segments.
-        this._lengths = [];
-        // angle of the funnel to vertical.
-        this._angle;
-        this._dataIndices = [];
-        
-        // sort data
-        this._unorderedData = $.extend(true, [], this.data);
-        var idxs = $.extend(true, [], this.data);
-        for (var i=0; i<idxs.length; i++) {
-            idxs[i].push(i);
-        }
-        this.data.sort( function (a, b) { return b[1] - a[1]; } );
-        idxs.sort( function (a, b) { return b[1] - a[1]; });
-        for (var i=0; i<idxs.length; i++) {
-            this._dataIndices.push(idxs[i][2]);
-        }
-        
-        // set highlight colors if none provided
-        if (this.highlightColors.length == 0) {
-            for (var i=0; i<this.seriesColors.length; i++){
-                var rgba = $.jqplot.getColorComponents(this.seriesColors[i]);
-                var newrgb = [rgba[0], rgba[1], rgba[2]];
-                var sum = newrgb[0] + newrgb[1] + newrgb[2];
-                for (var j=0; j<3; j++) {
-                    // when darkening, lowest color component can be is 60.
-                    newrgb[j] = (sum > 570) ?  newrgb[j] * 0.8 : newrgb[j] + 0.4 * (255 - newrgb[j]);
-                    newrgb[j] = parseInt(newrgb[j], 10);
-                }
-                this.highlightColors.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')');
-            }
-        }
-
-        plot.postParseOptionsHooks.addOnce(postParseOptions);
-        plot.postInitHooks.addOnce(postInit);
-        plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
-        plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
-        plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
-        plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
-        plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
-        plot.postDrawHooks.addOnce(postPlotDraw);        
-        
-    };
-    
-    // gridData will be of form [label, percentage of total]
-    $.jqplot.FunnelRenderer.prototype.setGridData = function(plot) {
-        // set gridData property.  This will hold angle in radians of each data point.
-        var sum = 0;
-        var td = [];
-        for (var i=0; i<this.data.length; i++){
-            sum += this.data[i][1];
-            td.push([this.data[i][0], this.data[i][1]]);
-        }
-        
-        // normalize y values, so areas are proportional.
-        for (var i=0; i<td.length; i++) {
-            td[i][1] = td[i][1]/sum;
-        }
-        
-        this._bases = new Array(td.length + 1);
-        this._lengths = new Array(td.length);
-        
-        this.gridData = td;
-    };
-    
-    $.jqplot.FunnelRenderer.prototype.makeGridData = function(data, plot) {
-        // set gridData property.  This will hold angle in radians of each data point.
-        var sum = 0;
-        var td = [];
-        for (var i=0; i<this.data.length; i++){
-            sum += this.data[i][1];
-            td.push([this.data[i][0], this.data[i][1]]);
-        }
-        
-        // normalize y values, so areas are proportional.
-        for (var i=0; i<td.length; i++) {
-            td[i][1] = td[i][1]/sum;
-        }
-        
-        this._bases = new Array(td.length + 1);
-        this._lengths = new Array(td.length);
-        
-        return td;
-    };
-    
-    $.jqplot.FunnelRenderer.prototype.drawSection = function (ctx, vertices, color, isShadow) {
-        var fill = this.fill;
-        var lineWidth = this.lineWidth;
-        ctx.save();
-        
-        if (isShadow) {
-            for (var i=0; i<this.shadowDepth; i++) {
-                ctx.save();
-                ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
-                doDraw();
-            }
-        }
-        
-        else {
-            doDraw();
-        }
-        
-        function doDraw () {
-            ctx.beginPath();  
-            ctx.fillStyle = color;
-            ctx.strokeStyle = color;
-            ctx.lineWidth = lineWidth;
-            ctx.moveTo(vertices[0][0], vertices[0][1]);
-            for (var i=1; i<4; i++) {
-                ctx.lineTo(vertices[i][0], vertices[i][1]);
-            }
-            ctx.closePath();
-            if (fill) {
-                ctx.fill();
-            }
-            else {
-                ctx.stroke();
-            }
-        }
-        
-        if (isShadow) {
-            for (var i=0; i<this.shadowDepth; i++) {
-                ctx.restore();
-            }
-        }
-        
-        ctx.restore();
-    };
-    
-    // called with scope of series
-    $.jqplot.FunnelRenderer.prototype.draw = function (ctx, gd, options, plot) {
-        var i;
-        var opts = (options != undefined) ? options : {};
-        // offset and direction of offset due to legend placement
-        var offx = 0;
-        var offy = 0;
-        var trans = 1;
-        this._areas = [];
-        // var colorGenerator = new this.colorGenerator(this.seriesColors);
-        if (options.legendInfo && options.legendInfo.placement == 'insideGrid') {
-            var li = options.legendInfo;
-            switch (li.location) {
-                case 'nw':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'w':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'sw':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'ne':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'e':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'se':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'n':
-                    offy = li.height + li.yoffset;
-                    break;
-                case 's':
-                    offy = li.height + li.yoffset;
-                    trans = -1;
-                    break;
-                default:
-                    break;
-            }
-        }
-        
-        var loff = (trans==1) ? this.padding.left + offx : this.padding.left;
-        var toff = (trans==1) ? this.padding.top + offy : this.padding.top;
-        var roff = (trans==-1) ? this.padding.right + offx : this.padding.right;
-        var boff = (trans==-1) ? this.padding.bottom + offy : this.padding.bottom;
-        
-        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
-        var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
-        var fill = (opts.fill != undefined) ? opts.fill : this.fill;
-        var cw = ctx.canvas.width;
-        var ch = ctx.canvas.height;
-        this._bases[0] = cw - loff - roff;
-        var ltot = this._length = ch - toff - boff;
-
-        var hend = this._bases[0]*this.widthRatio;
-        this._atot = ltot/2 * (this._bases[0] + this._bases[0]*this.widthRatio);
-
-        this._angle = Math.atan((this._bases[0] - hend)/2/ltot);
-
-        for (i=0; i<gd.length; i++) {
-            this._areas.push(gd[i][1] * this._atot);
-        }
-
-        
-        var guess, err, count, lsum=0;
-        var tolerance = 0.0001;
-
-        for (i=0; i<this._areas.length; i++) {
-            guess = this._areas[i]/this._bases[i];
-            err = 999999;
-            this._lengths[i] = guess;
-            count = 0;
-            while (err > this._lengths[i]*tolerance && count < 100) {
-                this._lengths[i] = this._areas[i]/(this._bases[i] - this._lengths[i] * Math.tan(this._angle));
-                err = Math.abs(this._lengths[i] - guess);
-                this._bases[i+1] = this._bases[i] - (2*this._lengths[i]*Math.tan(this._angle));
-                guess = this._lengths[i];
-                count++;
-            }
-            lsum += this._lengths[i];
-        }
-        
-        // figure out vertices of each section
-        this._vertices = new Array(gd.length);
-        
-        // these are 4 coners of entire trapezoid
-        var p0 = [loff, toff],
-            p1 = [loff+this._bases[0], toff],
-            p2 = [loff + (this._bases[0] - this._bases[this._bases.length-1])/2, toff + this._length],
-            p3 = [p2[0] + this._bases[this._bases.length-1], p2[1]];
-            
-        // equations of right and left sides, returns x, y values given height of section (y value)
-        function findleft (l) {
-            var m = (p0[1] - p2[1])/(p0[0] - p2[0]);
-            var b = p0[1] - m*p0[0];
-            var y = l + p0[1];
-            
-            return [(y - b)/m, y];
-        }
-        
-        function findright (l) {
-            var m = (p1[1] - p3[1])/(p1[0] - p3[0]);
-            var b = p1[1] - m*p1[0];
-            var y = l + p1[1];
-            
-            return [(y - b)/m, y];
-        }
-        
-        var x = offx, y = offy;
-        var h=0, adj=0;
-        
-        for (i=0; i<gd.length; i++) {
-            this._vertices[i] = new Array();
-            var v = this._vertices[i];
-            var sm = this.sectionMargin;
-            if (i == 0) {
-                adj = 0;
-            }
-            if (i == 1) {
-                adj = sm/3;
-            }
-            else if (i > 0 && i < gd.length-1) {
-                adj = sm/2;
-            }
-            else if (i == gd.length -1) {
-                adj = 2*sm/3;
-            }
-            v.push(findleft(h+adj));
-            v.push(findright(h+adj));
-            h += this._lengths[i];
-            if (i == 0) {
-                adj = -2*sm/3;
-            }
-            else if (i > 0 && i < gd.length-1) {
-                adj = -sm/2;
-            }
-            else if (i == gd.length - 1) {
-                adj = 0;
-            }
-            v.push(findright(h+adj));
-            v.push(findleft(h+adj));
-            
-        }
-
-        if (this.shadow) {
-            var shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')';
-            for (var i=0; i<gd.length; i++) {
-                this.renderer.drawSection.call (this, ctx, this._vertices[i], shadowColor, true);
-            }
-            
-        }
-        for (var i=0; i<gd.length; i++) {
-            var v = this._vertices[i];
-            this.renderer.drawSection.call (this, ctx, v, this.seriesColors[i]);
-            
-            if (this.showDataLabels && gd[i][1]*100 >= this.dataLabelThreshold) {
-                var fstr, label;
-                
-                if (this.dataLabels == 'label') {
-                    fstr = this.dataLabelFormatString || '%s';
-                    label = $.jqplot.sprintf(fstr, gd[i][0]);
-                }
-                else if (this.dataLabels == 'value') {
-                    fstr = this.dataLabelFormatString || '%d';
-                    label = $.jqplot.sprintf(fstr, this.data[i][1]);
-                }
-                else if (this.dataLabels == 'percent') {
-                    fstr = this.dataLabelFormatString || '%d%%';
-                    label = $.jqplot.sprintf(fstr, gd[i][1]*100);
-                }
-                else if (this.dataLabels.constructor == Array) {
-                    fstr = this.dataLabelFormatString || '%s';
-                    label = $.jqplot.sprintf(fstr, this.dataLabels[this._dataIndices[i]]);
-                }
-                
-                var fact = (this._radius ) * this.dataLabelPositionFactor + this.sliceMargin + this.dataLabelNudge;
-                
-                var x = (v[0][0] + v[1][0])/2 + this.canvas._offsets.left;
-                var y = (v[1][1] + v[2][1])/2 + this.canvas._offsets.top;
-                
-                var labelelem = $('<span class="jqplot-funnel-series jqplot-data-label" style="position:absolute;">' + label + '</span>').insertBefore(plot.eventCanvas._elem);
-                x -= labelelem.width()/2;
-                y -= labelelem.height()/2;
-                x = Math.round(x);
-                y = Math.round(y);
-                labelelem.css({left: x, top: y});
-            }
-            
-        }
-               
-    };
-    
-    $.jqplot.FunnelAxisRenderer = function() {
-        $.jqplot.LinearAxisRenderer.call(this);
-    };
-    
-    $.jqplot.FunnelAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
-    $.jqplot.FunnelAxisRenderer.prototype.constructor = $.jqplot.FunnelAxisRenderer;
-        
-    
-    // There are no traditional axes on a funnel chart.  We just need to provide
-    // dummy objects with properties so the plot will render.
-    // called with scope of axis object.
-    $.jqplot.FunnelAxisRenderer.prototype.init = function(options){
-        //
-        this.tickRenderer = $.jqplot.FunnelTickRenderer;
-        $.extend(true, this, options);
-        // I don't think I'm going to need _dataBounds here.
-        // have to go Axis scaling in a way to fit chart onto plot area
-        // and provide u2p and p2u functionality for mouse cursor, etc.
-        // for convienence set _dataBounds to 0 and 100 and
-        // set min/max to 0 and 100.
-        this._dataBounds = {min:0, max:100};
-        this.min = 0;
-        this.max = 100;
-        this.showTicks = false;
-        this.ticks = [];
-        this.showMark = false;
-        this.show = false; 
-    };
-    
-    
-    
-    /**
-     * Class: $.jqplot.FunnelLegendRenderer
-     * Legend Renderer specific to funnel plots.  Set by default
-     * when the user creates a funnel plot.
-     */
-    $.jqplot.FunnelLegendRenderer = function(){
-        $.jqplot.TableLegendRenderer.call(this);
-    };
-    
-    $.jqplot.FunnelLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
-    $.jqplot.FunnelLegendRenderer.prototype.constructor = $.jqplot.FunnelLegendRenderer;
-    
-    $.jqplot.FunnelLegendRenderer.prototype.init = function(options) {
-        // Group: Properties
-        //
-        // prop: numberRows
-        // Maximum number of rows in the legend.  0 or null for unlimited.
-        this.numberRows = null;
-        // prop: numberColumns
-        // Maximum number of columns in the legend.  0 or null for unlimited.
-        this.numberColumns = null;
-        $.extend(true, this, options);
-    };
-    
-    // called with context of legend
-    $.jqplot.FunnelLegendRenderer.prototype.draw = function() {
-        var legend = this;
-        if (this.show) {
-            var series = this._series;
-            var ss = 'position:absolute;';
-            ss += (this.background) ? 'background:'+this.background+';' : '';
-            ss += (this.border) ? 'border:'+this.border+';' : '';
-            ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
-            ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
-            ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
-            ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : '';
-            ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : '';
-            ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : '';
-            ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : '';
-            this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
-            // Funnel charts legends don't go by number of series, but by number of data points
-            // in the series.  Refactor things here for that.
-            
-            var pad = false, 
-                reverse = false,
-                nr, nc;
-            var s = series[0];
-            var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors);
-            
-            if (s.show) {
-                var pd = s.data;
-                if (this.numberRows) {
-                    nr = this.numberRows;
-                    if (!this.numberColumns){
-                        nc = Math.ceil(pd.length/nr);
-                    }
-                    else{
-                        nc = this.numberColumns;
-                    }
-                }
-                else if (this.numberColumns) {
-                    nc = this.numberColumns;
-                    nr = Math.ceil(pd.length/this.numberColumns);
-                }
-                else {
-                    nr = pd.length;
-                    nc = 1;
-                }
-                
-                var i, j, tr, td1, td2, lt, rs, color;
-                var idx = 0;    
-                
-                for (i=0; i<nr; i++) {
-                    if (reverse){
-                        tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem);
-                    }
-                    else{
-                        tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem);
-                    }
-                    for (j=0; j<nc; j++) {
-                        if (idx < pd.length){
-                            lt = this.labels[idx] || pd[idx][0].toString();
-                            color = colorGenerator.next();
-                            if (!reverse){
-                                if (i>0){
-                                    pad = true;
-                                }
-                                else{
-                                    pad = false;
-                                }
-                            }
-                            else{
-                                if (i == nr -1){
-                                    pad = false;
-                                }
-                                else{
-                                    pad = true;
-                                }
-                            }
-                            rs = (pad) ? this.rowSpacing : '0';
-                
-                            td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
-                                '<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+
-                                '</div></td>');
-                            td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
-                            if (this.escapeHtml){
-                                td2.text(lt);
-                            }
-                            else {
-                                td2.html(lt);
-                            }
-                            if (reverse) {
-                                td2.prependTo(tr);
-                                td1.prependTo(tr);
-                            }
-                            else {
-                                td1.appendTo(tr);
-                                td2.appendTo(tr);
-                            }
-                            pad = true;
-                        }
-                        idx++;
-                    }   
-                }
-            }
-        }
-        return this._elem;                
-    };
-    
-    // $.jqplot.FunnelLegendRenderer.prototype.pack = function(offsets) {
-    //     if (this.show) {
-    //         // fake a grid for positioning
-    //         var grid = {_top:offsets.top, _left:offsets.left, _right:offsets.right, _bottom:this._plotDimensions.height - offsets.bottom};        
-    //         if (this.placement == 'insideGrid') {
-    //             switch (this.location) {
-    //                 case 'nw':
-    //                     var a = grid._left + this.xoffset;
-    //                     var b = grid._top + this.yoffset;
-    //                     this._elem.css('left', a);
-    //                     this._elem.css('top', b);
-    //                     break;
-    //                 case 'n':
-    //                     var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-    //                     var b = grid._top + this.yoffset;
-    //                     this._elem.css('left', a);
-    //                     this._elem.css('top', b);
-    //                     break;
-    //                 case 'ne':
-    //                     var a = offsets.right + this.xoffset;
-    //                     var b = grid._top + this.yoffset;
-    //                     this._elem.css({right:a, top:b});
-    //                     break;
-    //                 case 'e':
-    //                     var a = offsets.right + this.xoffset;
-    //                     var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-    //                     this._elem.css({right:a, top:b});
-    //                     break;
-    //                 case 'se':
-    //                     var a = offsets.right + this.xoffset;
-    //                     var b = offsets.bottom + this.yoffset;
-    //                     this._elem.css({right:a, bottom:b});
-    //                     break;
-    //                 case 's':
-    //                     var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-    //                     var b = offsets.bottom + this.yoffset;
-    //                     this._elem.css({left:a, bottom:b});
-    //                     break;
-    //                 case 'sw':
-    //                     var a = grid._left + this.xoffset;
-    //                     var b = offsets.bottom + this.yoffset;
-    //                     this._elem.css({left:a, bottom:b});
-    //                     break;
-    //                 case 'w':
-    //                     var a = grid._left + this.xoffset;
-    //                     var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-    //                     this._elem.css({left:a, top:b});
-    //                     break;
-    //                 default:  // same as 'se'
-    //                     var a = grid._right - this.xoffset;
-    //                     var b = grid._bottom + this.yoffset;
-    //                     this._elem.css({right:a, bottom:b});
-    //                     break;
-    //             }
-    //             
-    //         }
-    //         else {
-    //             switch (this.location) {
-    //                 case 'nw':
-    //                     var a = this._plotDimensions.width - grid._left + this.xoffset;
-    //                     var b = grid._top + this.yoffset;
-    //                     this._elem.css('right', a);
-    //                     this._elem.css('top', b);
-    //                     break;
-    //                 case 'n':
-    //                     var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-    //                     var b = this._plotDimensions.height - grid._top + this.yoffset;
-    //                     this._elem.css('left', a);
-    //                     this._elem.css('bottom', b);
-    //                     break;
-    //                 case 'ne':
-    //                     var a = this._plotDimensions.width - offsets.right + this.xoffset;
-    //                     var b = grid._top + this.yoffset;
-    //                     this._elem.css({left:a, top:b});
-    //                     break;
-    //                 case 'e':
-    //                     var a = this._plotDimensions.width - offsets.right + this.xoffset;
-    //                     var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-    //                     this._elem.css({left:a, top:b});
-    //                     break;
-    //                 case 'se':
-    //                     var a = this._plotDimensions.width - offsets.right + this.xoffset;
-    //                     var b = offsets.bottom + this.yoffset;
-    //                     this._elem.css({left:a, bottom:b});
-    //                     break;
-    //                 case 's':
-    //                     var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-    //                     var b = this._plotDimensions.height - offsets.bottom + this.yoffset;
-    //                     this._elem.css({left:a, top:b});
-    //                     break;
-    //                 case 'sw':
-    //                     var a = this._plotDimensions.width - grid._left + this.xoffset;
-    //                     var b = offsets.bottom + this.yoffset;
-    //                     this._elem.css({right:a, bottom:b});
-    //                     break;
-    //                 case 'w':
-    //                     var a = this._plotDimensions.width - grid._left + this.xoffset;
-    //                     var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-    //                     this._elem.css({right:a, top:b});
-    //                     break;
-    //                 default:  // same as 'se'
-    //                     var a = grid._right - this.xoffset;
-    //                     var b = grid._bottom + this.yoffset;
-    //                     this._elem.css({right:a, bottom:b});
-    //                     break;
-    //             }
-    //         }
-    //     } 
-    // };
-    
-    // setup default renderers for axes and legend so user doesn't have to
-    // called with scope of plot
-    function preInit(target, data, options) {
-        options = options || {};
-        options.axesDefaults = options.axesDefaults || {};
-        options.legend = options.legend || {};
-        options.seriesDefaults = options.seriesDefaults || {};
-        // only set these if there is a funnel series
-        var setopts = false;
-        if (options.seriesDefaults.renderer == $.jqplot.FunnelRenderer) {
-            setopts = true;
-        }
-        else if (options.series) {
-            for (var i=0; i < options.series.length; i++) {
-                if (options.series[i].renderer == $.jqplot.FunnelRenderer) {
-                    setopts = true;
-                }
-            }
-        }
-        
-        if (setopts) {
-            options.axesDefaults.renderer = $.jqplot.FunnelAxisRenderer;
-            options.legend.renderer = $.jqplot.FunnelLegendRenderer;
-            options.legend.preDraw = true;
-            options.sortData = false;
-            options.seriesDefaults.pointLabels = {show: false};
-        }
-    }
-    
-    function postInit(target, data, options) {
-        // if multiple series, add a reference to the previous one so that
-        // funnel rings can nest.
-        for (var i=0; i<this.series.length; i++) {
-            if (this.series[i].renderer.constructor == $.jqplot.FunnelRenderer) {
-                // don't allow mouseover and mousedown at same time.
-                if (this.series[i].highlightMouseOver) {
-                    this.series[i].highlightMouseDown = false;
-                }
-            }
-        }
-    }
-    
-    // called with scope of plot
-    function postParseOptions(options) {
-        for (var i=0; i<this.series.length; i++) {
-            this.series[i].seriesColors = this.seriesColors;
-            this.series[i].colorGenerator = $.jqplot.colorGenerator;
-        }
-    }
-    
-    function highlight (plot, sidx, pidx) {
-        var s = plot.series[sidx];
-        var canvas = plot.plugins.funnelRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        s._highlightedPoint = pidx;
-        plot.plugins.funnelRenderer.highlightedSeriesIndex = sidx;
-        s.renderer.drawSection.call(s, canvas._ctx, s._vertices[pidx], s.highlightColors[pidx], false);
-    }
-    
-    function unhighlight (plot) {
-        var canvas = plot.plugins.funnelRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        for (var i=0; i<plot.series.length; i++) {
-            plot.series[i]._highlightedPoint = null;
-        }
-        plot.plugins.funnelRenderer.highlightedSeriesIndex = null;
-        plot.target.trigger('jqplotDataUnhighlight');
-    }
-    
-    function handleMove(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt1 = jQuery.Event('jqplotDataMouseOver');
-            evt1.pageX = ev.pageX;
-            evt1.pageY = ev.pageY;
-            plot.target.trigger(evt1, ins);
-            if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.funnelRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, ins[0], ins[1]);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    }
-    
-    function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.funnelRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, ins[0], ins[1]);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    }
-    
-    function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
-        var idx = plot.plugins.funnelRenderer.highlightedSeriesIndex;
-        if (idx != null && plot.series[idx].highlightMouseDown) {
-            unhighlight(plot);
-        }
-    }
-    
-    function handleClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt = jQuery.Event('jqplotDataClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }
-    
-    function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var idx = plot.plugins.funnelRenderer.highlightedSeriesIndex;
-            if (idx != null && plot.series[idx].highlightMouseDown) {
-                unhighlight(plot);
-            }
-            var evt = jQuery.Event('jqplotDataRightClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }
-    
-    // called within context of plot
-    // create a canvas which we can draw on.
-    // insert it before the eventCanvas, so eventCanvas will still capture events.
-    function postPlotDraw() {
-        // Memory Leaks patch    
-        if (this.plugins.funnelRenderer && this.plugins.funnelRenderer.highlightCanvas) {
-            this.plugins.funnelRenderer.highlightCanvas.resetCanvas();
-            this.plugins.funnelRenderer.highlightCanvas = null;
-        }
-
-        this.plugins.funnelRenderer = {};
-        this.plugins.funnelRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
-        
-        // do we have any data labels?  if so, put highlight canvas before those
-        var labels = $(this.targetId+' .jqplot-data-label');
-        if (labels.length) {
-            $(labels[0]).before(this.plugins.funnelRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-funnelRenderer-highlight-canvas', this._plotDimensions, this));
-        }
-        // else put highlight canvas before event canvas.
-        else {
-            this.eventCanvas._elem.before(this.plugins.funnelRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-funnelRenderer-highlight-canvas', this._plotDimensions, this));
-        }
-        var hctx = this.plugins.funnelRenderer.highlightCanvas.setContext();
-        this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
-    }
-    
-    $.jqplot.preInitHooks.push(preInit);
-    
-    $.jqplot.FunnelTickRenderer = function() {
-        $.jqplot.AxisTickRenderer.call(this);
-    };
-    
-    $.jqplot.FunnelTickRenderer.prototype = new $.jqplot.AxisTickRenderer();
-    $.jqplot.FunnelTickRenderer.prototype.constructor = $.jqplot.FunnelTickRenderer;
-    
-})(jQuery);
-    
-    
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.funnelRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.funnelRenderer.min.js
deleted file mode 100644
index 83dff8f..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.funnelRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(e){e.jqplot.FunnelRenderer=function(){e.jqplot.LineRenderer.call(this)};e.jqplot.FunnelRenderer.prototype=new e.jqplot.LineRenderer();e.jqplot.FunnelRenderer.prototype.constructor=e.jqplot.FunnelRenderer;e.jqplot.FunnelRenderer.prototype.init=function(p,t){this.padding={top:20,right:20,bottom:20,left:20};this.sectionMargin=6;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.widthRatio=0.2;this.lineWidth=2;this.dataLabels="percent";this.showDataLabels=false;this.dataLabelFormatString=null;this.dataLabelThreshold=3;this._type="funnel";this.tickRenderer=e.jqplot.FunnelTickRenderer;if(p.highlightMouseDown&&p.highlightMouseOver==null){p.highlightMouseOver=false}e.extend(true,this,p);this._highlightedPoint=null;this._bases=[];this._atot;this._areas=[];this._lengths=[];this._angle;this._dataIndices=[];this._unorderedData=e.extend(true,[],this.data);var o=e.extend(true,[],this.data);for(var r=0;r<o.length;r++){o[r].push(r)}this.data.sort(function(v,u){return u[1]-v[1]});o.sort(function(v,u){return u[1]-v[1]});for(var r=0;r<o.length;r++){this._dataIndices.push(o[r][2])}if(this.highlightColors.length==0){for(var r=0;r<this.seriesColors.length;r++){var q=e.jqplot.getColorComponents(this.seriesColors[r]);var m=[q[0],q[1],q[2]];var s=m[0]+m[1]+m[2];for(var n=0;n<3;n++){m[n]=(s>570)?m[n]*0.8:m[n]+0.4*(255-m[n]);m[n]=parseInt(m[n],10)}this.highlightColors.push("rgb("+m[0]+","+m[1]+","+m[2]+")")}}t.postParseOptionsHooks.addOnce(k);t.postInitHooks.addOnce(g);t.eventListenerHooks.addOnce("jqplotMouseMove",a);t.eventListenerHooks.addOnce("jqplotMouseDown",b);t.eventListenerHooks.addOnce("jqplotMouseUp",j);t.eventListenerHooks.addOnce("jqplotClick",f);t.eventListenerHooks.addOnce("jqplotRightClick",l);t.postDrawHooks.addOnce(h)};e.jqplot.FunnelRenderer.prototype.setGridData=function(o){var n=0;var p=[];for(var m=0;m<this.data.length;m++){n+=this.data[m][1];p.push([this.data[m][0],this.data[m][1]])}for(var m=0;m<p.length;m++){p[m][1]=p[m][1]/n}this._bases=new Array(p.length+1);this._lengths=new Array(p.length);this.gridData=p};e.jqplot.FunnelRenderer.prototype.makeGridData=function(o,p){var n=0;var q=[];for(var m=0;m<this.data.length;m++){n+=this.data[m][1];q.push([this.data[m][0],this.data[m][1]])}for(var m=0;m<q.length;m++){q[m][1]=q[m][1]/n}this._bases=new Array(q.length+1);this._lengths=new Array(q.length);return q};e.jqplot.FunnelRenderer.prototype.drawSection=function(n,p,o,s){var t=this.fill;var m=this.lineWidth;n.save();if(s){for(var r=0;r<this.shadowDepth;r++){n.save();n.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));q()}}else{q()}function q(){n.beginPath();n.fillStyle=o;n.strokeStyle=o;n.lineWidth=m;n.moveTo(p[0][0],p[0][1]);for(var u=1;u<4;u++){n.lineTo(p[u][0],p[u][1])}n.closePath();if(t){n.fill()}else{n.stroke()}}if(s){for(var r=0;r<this.shadowDepth;r++){n.restore()}}n.restore()};e.jqplot.FunnelRenderer.prototype.draw=function(G,B,J,p){var Y;var L=(J!=undefined)?J:{};var w=0;var u=0;var R=1;this._areas=[];if(J.legendInfo&&J.legendInfo.placement=="insideGrid"){var O=J.legendInfo;switch(O.location){case"nw":w=O.width+O.xoffset;break;case"w":w=O.width+O.xoffset;break;case"sw":w=O.width+O.xoffset;break;case"ne":w=O.width+O.xoffset;R=-1;break;case"e":w=O.width+O.xoffset;R=-1;break;case"se":w=O.width+O.xoffset;R=-1;break;case"n":u=O.height+O.yoffset;break;case"s":u=O.height+O.yoffset;R=-1;break;default:break}}var t=(R==1)?this.padding.left+w:this.padding.left;var F=(R==1)?this.padding.top+u:this.padding.top;var M=(R==-1)?this.padding.right+w:this.padding.right;var o=(R==-1)?this.padding.bottom+u:this.padding.bottom;var P=(L.shadow!=undefined)?L.shadow:this.shadow;var q=(L.showLine!=undefined)?L.showLine:this.showLine;var C=(L.fill!=undefined)?L.fill:this.fill;var H=G.canvas.width;var N=G.canvas.height;this._bases[0]=H-t-M;var I=this._length=N-F-o;var r=this._bases[0]*this.widthRatio;this._atot=I/2*(this._bases[0]+this._bases[0]*this.widthRatio);this._angle=Math.atan((this._bases[0]-r)/2/I);for(Y=0;Y<B.length;Y++){this._areas.push(B[Y][1]*this._atot)}var E,aa,W,Q=0;var n=0.0001;for(Y=0;Y<this._areas.length;Y++){E=this._areas[Y]/this._bases[Y];aa=999999;this._lengths[Y]=E;W=0;while(aa>this._lengths[Y]*n&&W<100){this._lengths[Y]=this._areas[Y]/(this._bases[Y]-this._lengths[Y]*Math.tan(this._angle));aa=Math.abs(this._lengths[Y]-E);this._bases[Y+1]=this._bases[Y]-(2*this._lengths[Y]*Math.tan(this._angle));E=this._lengths[Y];W++}Q+=this._lengths[Y]}this._vertices=new Array(B.length);var ae=[t,F],ad=[t+this._bases[0],F],ac=[t+(this._bases[0]-this._bases[this._bases.length-1])/2,F+this._length],ab=[ac[0]+this._bases[this._bases.length-1],ac[1]];function V(ag){var x=(ae[1]-ac[1])/(ae[0]-ac[0]);var v=ae[1]-x*ae[0];var ah=ag+ae[1];return[(ah-v)/x,ah]}function D(ag){var x=(ad[1]-ab[1])/(ad[0]-ab[0]);var v=ad[1]-x*ad[0];var ah=ag+ad[1];return[(ah-v)/x,ah]}var T=w,S=u;var Z=0,m=0;for(Y=0;Y<B.length;Y++){this._vertices[Y]=new Array();var U=this._vertices[Y];var A=this.sectionMargin;if(Y==0){m=0}if(Y==1){m=A/3}else{if(Y>0&&Y<B.length-1){m=A/2}else{if(Y==B.length-1){m=2*A/3}}}U.push(V(Z+m));U.push(D(Z+m));Z+=this._lengths[Y];if(Y==0){m=-2*A/3}else{if(Y>0&&Y<B.length-1){m=-A/2}else{if(Y==B.length-1){m=0}}}U.push(D(Z+m));U.push(V(Z+m))}if(this.shadow){var af="rgba(0,0,0,"+this.shadowAlpha+")";for(var Y=0;Y<B.length;Y++){this.renderer.drawSection.call(this,G,this._vertices[Y],af,true)}}for(var Y=0;Y<B.length;Y++){var U=this._vertices[Y];this.renderer.drawSection.call(this,G,U,this.seriesColors[Y]);if(this.showDataLabels&&B[Y][1]*100>=this.dataLabelThreshold){var K,X;if(this.dataLabels=="label"){K=this.dataLabelFormatString||"%s";X=e.jqplot.sprintf(K,B[Y][0])}else{if(this.dataLabels=="value"){K=this.dataLabelFormatString||"%d";X=e.jqplot.sprintf(K,this.data[Y][1])}else{if(this.dataLabels=="percent"){K=this.dataLabelFormatString||"%d%%";X=e.jqplot.sprintf(K,B[Y][1]*100)}else{if(this.dataLabels.constructor==Array){K=this.dataLabelFormatString||"%s";X=e.jqplot.sprintf(K,this.dataLabels[this._dataIndices[Y]])}}}}var s=(this._radius)*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var T=(U[0][0]+U[1][0])/2+this.canvas._offsets.left;var S=(U[1][1]+U[2][1])/2+this.canvas._offsets.top;var z=e('<span class="jqplot-funnel-series jqplot-data-label" style="position:absolute;">'+X+"</span>").insertBefore(p.eventCanvas._elem);T-=z.width()/2;S-=z.height()/2;T=Math.round(T);S=Math.round(S);z.css({left:T,top:S})}}};e.jqplot.FunnelAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.FunnelAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.FunnelAxisRenderer.prototype.constructor=e.jqplot.FunnelAxisRenderer;e.jqplot.FunnelAxisRenderer.prototype.init=function(m){this.tickRenderer=e.jqplot.FunnelTickRenderer;e.extend(true,this,m);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};e.jqplot.FunnelLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.FunnelLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.FunnelLegendRenderer.prototype.constructor=e.jqplot.FunnelLegendRenderer;e.jqplot.FunnelLegendRenderer.prototype.init=function(m){this.numberRows=null;this.numberColumns=null;e.extend(true,this,m)};e.jqplot.FunnelLegendRenderer.prototype.draw=function(){var p=this;if(this.show){var x=this._series;var A="position:absolute;";A+=(this.background)?"background:"+this.background+";":"";A+=(this.border)?"border:"+this.border+";":"";A+=(this.fontSize)?"font-size:"+this.fontSize+";":"";A+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";A+=(this.textColor)?"color:"+this.textColor+";":"";A+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";A+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";A+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";A+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=e('<table class="jqplot-table-legend" style="'+A+'"></table>');var E=false,w=false,m,u;var y=x[0];var n=new e.jqplot.ColorGenerator(y.seriesColors);if(y.show){var F=y.data;if(this.numberRows){m=this.numberRows;if(!this.numberColumns){u=Math.ceil(F.length/m)}else{u=this.numberColumns}}else{if(this.numberColumns){u=this.numberColumns;m=Math.ceil(F.length/this.numberColumns)}else{m=F.length;u=1}}var D,C,o,r,q,t,v,B;var z=0;for(D=0;D<m;D++){if(w){o=e('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{o=e('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(C=0;C<u;C++){if(z<F.length){t=this.labels[z]||F[z][0].toString();B=n.next();if(!w){if(D>0){E=true}else{E=false}}else{if(D==m-1){E=false}else{E=true}}v=(E)?this.rowSpacing:"0";r=e('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+v+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+B+';"></div></div></td>');q=e('<td class="jqplot-table-legend" style="padding-top:'+v+';"></td>');if(this.escapeHtml){q.text(t)}else{q.html(t)}if(w){q.prependTo(o);r.prependTo(o)}else{r.appendTo(o);q.appendTo(o)}E=true}z++}}}}return this._elem};function c(q,p,n){n=n||{};n.axesDefaults=n.axesDefaults||{};n.legend=n.legend||{};n.seriesDefaults=n.seriesDefaults||{};var m=false;if(n.seriesDefaults.renderer==e.jqplot.FunnelRenderer){m=true}else{if(n.series){for(var o=0;o<n.series.length;o++){if(n.series[o].renderer==e.jqplot.FunnelRenderer){m=true}}}}if(m){n.axesDefaults.renderer=e.jqplot.FunnelAxisRenderer;n.legend.renderer=e.jqplot.FunnelLegendRenderer;n.legend.preDraw=true;n.sortData=false;n.seriesDefaults.pointLabels={show:false}}}function g(p,o,m){for(var n=0;n<this.series.length;n++){if(this.series[n].renderer.constructor==e.jqplot.FunnelRenderer){if(this.series[n].highlightMouseOver){this.series[n].highlightMouseDown=false}}}}function k(m){for(var n=0;n<this.series.length;n++){this.series[n].seriesColors=this.seriesColors;this.series[n].colorGenerator=e.jqplot.colorGenerator}}function d(q,p,o){var n=q.series[p];var m=q.plugins.funnelRenderer.highlightCanvas;m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);n._highlightedPoint=o;q.plugins.funnelRenderer.highlightedSeriesIndex=p;n.renderer.drawSection.call(n,m._ctx,n._vertices[o],n.highlightColors[o],false)}function i(o){var m=o.plugins.funnelRenderer.highlightCanvas;m._ctx.clearRect(0,0,m._ctx.canvas.width,m._ctx.canvas.height);for(var n=0;n<o.series.length;n++){o.series[n]._highlightedPoint=null}o.plugins.funnelRenderer.highlightedSeriesIndex=null;o.target.trigger("jqplotDataUnhighlight")}function a(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var n=jQuery.Event("jqplotDataMouseOver");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o);if(r.series[o[0]].highlightMouseOver&&!(o[0]==r.plugins.funnelRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){var m=jQuery.Event("jqplotDataHighlight");m.pageX=q.pageX;m.pageY=q.pageY;r.target.trigger(m,o);d(r,o[0],o[1])}}else{if(s==null){i(r)}}}function b(p,o,s,r,q){if(r){var n=[r.seriesIndex,r.pointIndex,r.data];if(q.series[n[0]].highlightMouseDown&&!(n[0]==q.plugins.funnelRenderer.highlightedSeriesIndex&&n[1]==q.series[n[0]]._highlightedPoint)){var m=jQuery.Event("jqplotDataHighlight");m.pageX=p.pageX;m.pageY=p.pageY;q.target.trigger(m,n);d(q,n[0],n[1])}}else{if(r==null){i(q)}}}function j(o,n,r,q,p){var m=p.plugins.funnelRenderer.highlightedSeriesIndex;if(m!=null&&p.series[m].highlightMouseDown){i(p)}}function f(p,o,s,r,q){if(r){var n=[r.seriesIndex,r.pointIndex,r.data];var m=jQuery.Event("jqplotDataClick");m.pageX=p.pageX;m.pageY=p.pageY;q.target.trigger(m,n)}}function l(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var m=r.plugins.funnelRenderer.highlightedSeriesIndex;if(m!=null&&r.series[m].highlightMouseDown){i(r)}var n=jQuery.Event("jqplotDataRightClick");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o)}}function h(){if(this.plugins.funnelRenderer&&this.plugins.funnelRenderer.highlightCanvas){this.plugins.funnelRenderer.highlightCanvas.resetCanvas();this.plugins.funnelRenderer.highlightCanvas=null}this.plugins.funnelRenderer={};this.plugins.funnelRenderer.highlightCanvas=new e.jqplot.GenericCanvas();var n=e(this.targetId+" .jqplot-data-label");if(n.length){e(n[0]).before(this.plugins.funnelRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-funnelRenderer-highlight-canvas",this._plotDimensions,this))}else{this.eventCanvas._elem.before(this.plugins.funnelRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-funnelRenderer-highlight-canvas",this._plotDimensions,this))}var m=this.plugins.funnelRenderer.highlightCanvas.setContext();this.eventCanvas._elem.bind("mouseleave",{plot:this},function(o){i(o.data.plot)})}e.jqplot.preInitHooks.push(c);e.jqplot.FunnelTickRenderer=function(){e.jqplot.AxisTickRenderer.call(this)};e.jqplot.FunnelTickRenderer.prototype=new e.jqplot.AxisTickRenderer();e.jqplot.FunnelTickRenderer.prototype.constructor=e.jqplot.FunnelTickRenderer})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.highlighter.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.highlighter.js
deleted file mode 100644
index ec50c25..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.highlighter.js
+++ /dev/null
@@ -1,454 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMove]);
-    
-    /**
-     * Class: $.jqplot.Highlighter
-     * Plugin which will highlight data points when they are moused over.
-     * 
-     * To use this plugin, include the js
-     * file in your source:
-     * 
-     * > <script type="text/javascript" src="plugins/jqplot.highlighter.js"></script>
-     * 
-     * A tooltip providing information about the data point is enabled by default.
-     * To disable the tooltip, set "showTooltip" to false.
-     * 
-     * You can control what data is displayed in the tooltip with various
-     * options.  The "tooltipAxes" option controls wether the x, y or both
-     * data values are displayed.
-     * 
-     * Some chart types (e.g. hi-low-close) have more than one y value per
-     * data point. To display the additional values in the tooltip, set the
-     * "yvalues" option to the desired number of y values present (3 for a hlc chart).
-     * 
-     * By default, data values will be formatted with the same formatting
-     * specifiers as used to format the axis ticks.  A custom format code
-     * can be supplied with the tooltipFormatString option.  This will apply 
-     * to all values in the tooltip.  
-     * 
-     * For more complete control, the "formatString" option can be set.  This
-     * Allows conplete control over tooltip formatting.  Values are passed to
-     * the format string in an order determined by the "tooltipAxes" and "yvalues"
-     * options.  So, if you have a hi-low-close chart and you just want to display 
-     * the hi-low-close values in the tooltip, you could set a formatString like:
-     * 
-     * > highlighter: {
-     * >     tooltipAxes: 'y',
-     * >     yvalues: 3,
-     * >     formatString:'<table class="jqplot-highlighter">
-     * >         <tr><td>hi:</td><td>%s</td></tr>
-     * >         <tr><td>low:</td><td>%s</td></tr>
-     * >         <tr><td>close:</td><td>%s</td></tr></table>'
-     * > }
-     * 
-     */
-    $.jqplot.Highlighter = function(options) {
-        // Group: Properties
-        //
-        //prop: show
-        // true to show the highlight.
-        this.show = $.jqplot.config.enablePlugins;
-        // prop: markerRenderer
-        // Renderer used to draw the marker of the highlighted point.
-        // Renderer will assimilate attributes from the data point being highlighted,
-        // so no attributes need set on the renderer directly.
-        // Default is to turn off shadow drawing on the highlighted point.
-        this.markerRenderer = new $.jqplot.MarkerRenderer({shadow:false});
-        // prop: showMarker
-        // true to show the marker
-        this.showMarker  = true;
-        // prop: lineWidthAdjust
-        // Pixels to add to the lineWidth of the highlight.
-        this.lineWidthAdjust = 2.5;
-        // prop: sizeAdjust
-        // Pixels to add to the overall size of the highlight.
-        this.sizeAdjust = 5;
-        // prop: showTooltip
-        // Show a tooltip with data point values.
-        this.showTooltip = true;
-        // prop: tooltipLocation
-        // Where to position tooltip, 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'
-        this.tooltipLocation = 'nw';
-        // prop: fadeTooltip
-        // true = fade in/out tooltip, flase = show/hide tooltip
-        this.fadeTooltip = true;
-        // prop: tooltipFadeSpeed
-        // 'slow', 'def', 'fast', or number of milliseconds.
-        this.tooltipFadeSpeed = "fast";
-        // prop: tooltipOffset
-        // Pixel offset of tooltip from the highlight.
-        this.tooltipOffset = 2;
-        // prop: tooltipAxes
-        // Which axes to display in tooltip, 'x', 'y' or 'both', 'xy' or 'yx'
-        // 'both' and 'xy' are equivalent, 'yx' reverses order of labels.
-        this.tooltipAxes = 'both';
-        // prop; tooltipSeparator
-        // String to use to separate x and y axes in tooltip.
-        this.tooltipSeparator = ', ';
-        // prop; tooltipContentEditor
-        // Function used to edit/augment/replace the formatted tooltip contents.
-        // Called as str = tooltipContentEditor(str, seriesIndex, pointIndex)
-        // where str is the generated tooltip html and seriesIndex and pointIndex identify
-        // the data point being highlighted. Should return the html for the tooltip contents.
-        this.tooltipContentEditor = null;
-        // prop: useAxesFormatters
-        // Use the x and y axes formatters to format the text in the tooltip.
-        this.useAxesFormatters = true;
-        // prop: tooltipFormatString
-        // sprintf format string for the tooltip.
-        // Uses Ash Searle's javascript sprintf implementation
-        // found here: http://hexmen.com/blog/2007/03/printf-sprintf/
-        // See http://perldoc.perl.org/functions/sprintf.html for reference.
-        // Additional "p" and "P" format specifiers added by Chris Leonello.
-        this.tooltipFormatString = '%.5P';
-        // prop: formatString
-        // alternative to tooltipFormatString
-        // will format the whole tooltip text, populating with x, y values as
-        // indicated by tooltipAxes option.  So, you could have a tooltip like:
-        // 'Date: %s, number of cats: %d' to format the whole tooltip at one go.
-        // If useAxesFormatters is true, values will be formatted according to
-        // Axes formatters and you can populate your tooltip string with 
-        // %s placeholders.
-        this.formatString = null;
-        // prop: yvalues
-        // Number of y values to expect in the data point array.
-        // Typically this is 1.  Certain plots, like OHLC, will
-        // have more y values in each data point array.
-        this.yvalues = 1;
-        // prop: bringSeriesToFront
-        // This option requires jQuery 1.4+
-        // True to bring the series of the highlighted point to the front
-        // of other series.
-        this.bringSeriesToFront = false;
-        this._tooltipElem;
-        this.isHighlighting = false;
-        this.currentNeighbor = null;
-
-        $.extend(true, this, options);
-    };
-    
-    var locations = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
-    var locationIndicies = {'nw':0, 'n':1, 'ne':2, 'e':3, 'se':4, 's':5, 'sw':6, 'w':7};
-    var oppositeLocations = ['se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];
-    
-    // axis.renderer.tickrenderer.formatter
-    
-    // called with scope of plot
-    $.jqplot.Highlighter.init = function (target, data, opts){
-        var options = opts || {};
-        // add a highlighter attribute to the plot
-        this.plugins.highlighter = new $.jqplot.Highlighter(options.highlighter);
-    };
-    
-    // called within scope of series
-    $.jqplot.Highlighter.parseOptions = function (defaults, options) {
-        // Add a showHighlight option to the series 
-        // and set it to true by default.
-        this.showHighlight = true;
-    };
-    
-    // called within context of plot
-    // create a canvas which we can draw on.
-    // insert it before the eventCanvas, so eventCanvas will still capture events.
-    $.jqplot.Highlighter.postPlotDraw = function() {
-        // Memory Leaks patch    
-        if (this.plugins.highlighter && this.plugins.highlighter.highlightCanvas) {
-            this.plugins.highlighter.highlightCanvas.resetCanvas();
-            this.plugins.highlighter.highlightCanvas = null;
-        }
-
-        if (this.plugins.highlighter && this.plugins.highlighter._tooltipElem) {
-            this.plugins.highlighter._tooltipElem.emptyForce();
-            this.plugins.highlighter._tooltipElem = null;
-        }
-
-        this.plugins.highlighter.highlightCanvas = new $.jqplot.GenericCanvas();
-        
-        this.eventCanvas._elem.before(this.plugins.highlighter.highlightCanvas.createElement(this._gridPadding, 'jqplot-highlight-canvas', this._plotDimensions, this));
-        this.plugins.highlighter.highlightCanvas.setContext();
-
-        var elem = document.createElement('div');
-        this.plugins.highlighter._tooltipElem = $(elem);
-        elem = null;
-        this.plugins.highlighter._tooltipElem.addClass('jqplot-highlighter-tooltip');
-        this.plugins.highlighter._tooltipElem.css({position:'absolute', display:'none'});
-        
-        this.eventCanvas._elem.before(this.plugins.highlighter._tooltipElem);
-    };
-    
-    $.jqplot.preInitHooks.push($.jqplot.Highlighter.init);
-    $.jqplot.preParseSeriesOptionsHooks.push($.jqplot.Highlighter.parseOptions);
-    $.jqplot.postDrawHooks.push($.jqplot.Highlighter.postPlotDraw);
-    
-    function draw(plot, neighbor) {
-        var hl = plot.plugins.highlighter;
-        var s = plot.series[neighbor.seriesIndex];
-        var smr = s.markerRenderer;
-        var mr = hl.markerRenderer;
-        mr.style = smr.style;
-        mr.lineWidth = smr.lineWidth + hl.lineWidthAdjust;
-        mr.size = smr.size + hl.sizeAdjust;
-        var rgba = $.jqplot.getColorComponents(smr.color);
-        var newrgb = [rgba[0], rgba[1], rgba[2]];
-        var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]);
-        mr.color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')';
-        mr.init();
-        mr.draw(s.gridData[neighbor.pointIndex][0], s.gridData[neighbor.pointIndex][1], hl.highlightCanvas._ctx);
-    }
-    
-    function showTooltip(plot, series, neighbor) {
-        // neighbor looks like: {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]}
-        // gridData should be x,y pixel coords on the grid.
-        // add the plot._gridPadding to that to get x,y in the target.
-        var hl = plot.plugins.highlighter;
-        var elem = hl._tooltipElem;
-        var serieshl = series.highlighter || {};
-
-        var opts = $.extend(true, {}, hl, serieshl);
-
-        if (opts.useAxesFormatters) {
-            var xf = series._xaxis._ticks[0].formatter;
-            var yf = series._yaxis._ticks[0].formatter;
-            var xfstr = series._xaxis._ticks[0].formatString;
-            var yfstr = series._yaxis._ticks[0].formatString;
-            var str;
-            var xstr = xf(xfstr, neighbor.data[0]);
-            var ystrs = [];
-            for (var i=1; i<opts.yvalues+1; i++) {
-                ystrs.push(yf(yfstr, neighbor.data[i]));
-            }
-            if (typeof opts.formatString === 'string') {
-                switch (opts.tooltipAxes) {
-                    case 'both':
-                    case 'xy':
-                        ystrs.unshift(xstr);
-                        ystrs.unshift(opts.formatString);
-                        str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
-                        break;
-                    case 'yx':
-                        ystrs.push(xstr);
-                        ystrs.unshift(opts.formatString);
-                        str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
-                        break;
-                    case 'x':
-                        str = $.jqplot.sprintf.apply($.jqplot.sprintf, [opts.formatString, xstr]);
-                        break;
-                    case 'y':
-                        ystrs.unshift(opts.formatString);
-                        str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
-                        break;
-                    default: // same as xy
-                        ystrs.unshift(xstr);
-                        ystrs.unshift(opts.formatString);
-                        str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs);
-                        break;
-                } 
-            }
-            else {
-                switch (opts.tooltipAxes) {
-                    case 'both':
-                    case 'xy':
-                        str = xstr;
-                        for (var i=0; i<ystrs.length; i++) {
-                            str += opts.tooltipSeparator + ystrs[i];
-                        }
-                        break;
-                    case 'yx':
-                        str = '';
-                        for (var i=0; i<ystrs.length; i++) {
-                            str += ystrs[i] + opts.tooltipSeparator;
-                        }
-                        str += xstr;
-                        break;
-                    case 'x':
-                        str = xstr;
-                        break;
-                    case 'y':
-                        str = ystrs.join(opts.tooltipSeparator);
-                        break;
-                    default: // same as 'xy'
-                        str = xstr;
-                        for (var i=0; i<ystrs.length; i++) {
-                            str += opts.tooltipSeparator + ystrs[i];
-                        }
-                        break;
-                    
-                }                
-            }
-        }
-        else {
-            var str;
-            if (typeof opts.formatString ===  'string') {
-                str = $.jqplot.sprintf.apply($.jqplot.sprintf, [opts.formatString].concat(neighbor.data));
-            }
-
-            else {
-                if (opts.tooltipAxes == 'both' || opts.tooltipAxes == 'xy') {
-                    str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]) + opts.tooltipSeparator + $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]);
-                }
-                else if (opts.tooltipAxes == 'yx') {
-                    str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]) + opts.tooltipSeparator + $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]);
-                }
-                else if (opts.tooltipAxes == 'x') {
-                    str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]);
-                }
-                else if (opts.tooltipAxes == 'y') {
-                    str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]);
-                } 
-            }
-        }
-        if ($.isFunction(opts.tooltipContentEditor)) {
-            // args str, seriesIndex, pointIndex are essential so the hook can look up
-            // extra data for the point.
-            str = opts.tooltipContentEditor(str, neighbor.seriesIndex, neighbor.pointIndex, plot);
-        }
-        elem.html(str);
-        var gridpos = {x:neighbor.gridData[0], y:neighbor.gridData[1]};
-        var ms = 0;
-        var fact = 0.707;
-        if (series.markerRenderer.show == true) { 
-            ms = (series.markerRenderer.size + opts.sizeAdjust)/2;
-        }
-		
-		var loc = locations;
-		if (series.fillToZero && series.fill && neighbor.data[1] < 0) {
-			loc = oppositeLocations;
-		}
-		
-        switch (loc[locationIndicies[opts.tooltipLocation]]) {
-            case 'nw':
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms;
-                var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms;
-                break;
-            case 'n':
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2;
-                var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - ms;
-                break;
-            case 'ne':
-                var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + fact * ms;
-                var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms;
-                break;
-            case 'e':
-                var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + ms;
-                var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2;
-                break;
-            case 'se':
-                var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + fact * ms;
-                var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + fact * ms;
-                break;
-            case 's':
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2;
-                var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + ms;
-                break;
-            case 'sw':
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms;
-                var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + fact * ms;
-                break;
-            case 'w':
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - ms;
-                var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2;
-                break;
-            default: // same as 'nw'
-                var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms;
-                var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms;
-                break;
-        }
-        elem.css('left', x);
-        elem.css('top', y);
-        if (opts.fadeTooltip) {
-            // Fix for stacked up animations.  Thnanks Trevor!
-            elem.stop(true,true).fadeIn(opts.tooltipFadeSpeed);
-        }
-        else {
-            elem.show();
-        }
-        elem = null;
-        
-    }
-    
-    function handleMove(ev, gridpos, datapos, neighbor, plot) {
-        var hl = plot.plugins.highlighter;
-        var c = plot.plugins.cursor;
-        if (hl.show) {
-            if (neighbor == null && hl.isHighlighting) {
-                var ctx = hl.highlightCanvas._ctx;
-                ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-                if (hl.fadeTooltip) {
-                    hl._tooltipElem.fadeOut(hl.tooltipFadeSpeed);
-                }
-                else {
-                    hl._tooltipElem.hide();
-                }
-                if (hl.bringSeriesToFront) {
-                    plot.restorePreviousSeriesOrder();
-                }
-                hl.isHighlighting = false;
-                hl.currentNeighbor = null;
-                ctx = null;
-            }
-            else if (neighbor != null && plot.series[neighbor.seriesIndex].showHighlight && !hl.isHighlighting) {
-                hl.isHighlighting = true;
-                hl.currentNeighbor = neighbor;
-                if (hl.showMarker) {
-                    draw(plot, neighbor);
-                }
-                if (hl.showTooltip && (!c || !c._zoom.started)) {
-                    showTooltip(plot, plot.series[neighbor.seriesIndex], neighbor);
-                }
-                if (hl.bringSeriesToFront) {
-                    plot.moveSeriesToFront(neighbor.seriesIndex);
-                }
-            }
-            // check to see if we're highlighting the wrong point.
-            else if (neighbor != null && hl.isHighlighting && hl.currentNeighbor != neighbor) {
-                // highlighting the wrong point.
-
-                // if new series allows highlighting, highlight new point.
-                if (plot.series[neighbor.seriesIndex].showHighlight) {
-                    var ctx = hl.highlightCanvas._ctx;
-                    ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-                    hl.isHighlighting = true;
-                    hl.currentNeighbor = neighbor;
-                    if (hl.showMarker) {
-                        draw(plot, neighbor);
-                    }
-                    if (hl.showTooltip && (!c || !c._zoom.started)) {
-                        showTooltip(plot, plot.series[neighbor.seriesIndex], neighbor);
-                    }
-                    if (hl.bringSeriesToFront) {
-                        plot.moveSeriesToFront(neighbor.seriesIndex);
-                    }                    
-                }                
-            }
-        }
-    }
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.highlighter.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.highlighter.min.js
deleted file mode 100644
index 3924bd7..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.highlighter.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(d){d.jqplot.eventListenerHooks.push(["jqplotMouseMove",f]);d.jqplot.Highlighter=function(h){this.show=d.jqplot.config.enablePlugins;this.markerRenderer=new d.jqplot.MarkerRenderer({shadow:false});this.showMarker=true;this.lineWidthAdjust=2.5;this.sizeAdjust=5;this.showTooltip=true;this.tooltipLocation="nw";this.fadeTooltip=true;this.tooltipFadeSpeed="fast";this.tooltipOffset=2;this.tooltipAxes="both";this.tooltipSeparator=", ";this.tooltipContentEditor=null;this.useAxesFormatters=true;this.tooltipFormatString="%.5P";this.formatString=null;this.yvalues=1;this.bringSeriesToFront=false;this._tooltipElem;this.isHighlighting=false;this.currentNeighbor=null;d.extend(true,this,h)};var b=["nw","n","ne","e","se","s","sw","w"];var e={nw:0,n:1,ne:2,e:3,se:4,s:5,sw:6,w:7};var c=["se","s","sw","w","nw","n","ne","e"];d.jqplot.Highlighter.init=function(k,j,i){var h=i||{};this.plugins.highlighter=new d.jqplot.Highlighter(h.highlighter)};d.jqplot.Highlighter.parseOptions=function(i,h){this.showHighlight=true};d.jqplot.Highlighter.postPlotDraw=function(){if(this.plugins.highlighter&&this.plugins.highlighter.highlightCanvas){this.plugins.highlighter.highlightCanvas.resetCanvas();this.plugins.highlighter.highlightCanvas=null}if(this.plugins.highlighter&&this.plugins.highlighter._tooltipElem){this.plugins.highlighter._tooltipElem.emptyForce();this.plugins.highlighter._tooltipElem=null}this.plugins.highlighter.highlightCanvas=new d.jqplot.GenericCanvas();this.eventCanvas._elem.before(this.plugins.highlighter.highlightCanvas.createElement(this._gridPadding,"jqplot-highlight-canvas",this._plotDimensions,this));this.plugins.highlighter.highlightCanvas.setContext();var h=document.createElement("div");this.plugins.highlighter._tooltipElem=d(h);h=null;this.plugins.highlighter._tooltipElem.addClass("jqplot-highlighter-tooltip");this.plugins.highlighter._tooltipElem.css({position:"absolute",display:"none"});this.eventCanvas._elem.before(this.plugins.highlighter._tooltipElem)};d.jqplot.preInitHooks.push(d.jqplot.Highlighter.init);d.jqplot.preParseSeriesOptionsHooks.push(d.jqplot.Highlighter.parseOptions);d.jqplot.postDrawHooks.push(d.jqplot.Highlighter.postPlotDraw);function a(m,o){var j=m.plugins.highlighter;var p=m.series[o.seriesIndex];var h=p.markerRenderer;var i=j.markerRenderer;i.style=h.style;i.lineWidth=h.lineWidth+j.lineWidthAdjust;i.size=h.size+j.sizeAdjust;var l=d.jqplot.getColorComponents(h.color);var n=[l[0],l[1],l[2]];var k=(l[3]>=0.6)?l[3]*0.6:l[3]*(2-l[3]);i.color="rgba("+n[0]+","+n[1]+","+n[2]+","+k+")";i.init();i.draw(p.gridData[o.pointIndex][0],p.gridData[o.pointIndex][1],j.highlightCanvas._ctx)}function g(A,q,m){var k=A.plugins.highlighter;var D=k._tooltipElem;var r=q.highlighter||{};var t=d.extend(true,{},k,r);if(t.useAxesFormatters){var w=q._xaxis._ticks[0].formatter;var h=q._yaxis._ticks[0].formatter;var E=q._xaxis._ticks[0].formatString;var s=q._yaxis._ticks[0].formatString;var z;var u=w(E,m.data[0]);var l=[];for(var B=1;B<t.yvalues+1;B++){l.push(h(s,m.data[B]))}if(typeof t.formatString==="string"){switch(t.tooltipAxes){case"both":case"xy":l.unshift(u);l.unshift(t.formatString);z=d.jqplot.sprintf.apply(d.jqplot.sprintf,l);break;case"yx":l.push(u);l.unshift(t.formatString);z=d.jqplot.sprintf.apply(d.jqplot.sprintf,l);break;case"x":z=d.jqplot.sprintf.apply(d.jqplot.sprintf,[t.formatString,u]);break;case"y":l.unshift(t.formatString);z=d.jqplot.sprintf.apply(d.jqplot.sprintf,l);break;default:l.unshift(u);l.unshift(t.formatString);z=d.jqplot.sprintf.apply(d.jqplot.sprintf,l);break}}else{switch(t.tooltipAxes){case"both":case"xy":z=u;for(var B=0;B<l.length;B++){z+=t.tooltipSeparator+l[B]}break;case"yx":z="";for(var B=0;B<l.length;B++){z+=l[B]+t.tooltipSeparator}z+=u;break;case"x":z=u;break;case"y":z=l.join(t.tooltipSeparator);break;default:z=u;for(var B=0;B<l.length;B++){z+=t.tooltipSeparator+l[B]}break}}}else{var z;if(typeof t.formatString==="string"){z=d.jqplot.sprintf.apply(d.jqplot.sprintf,[t.formatString].concat(m.data))}else{if(t.tooltipAxes=="both"||t.tooltipAxes=="xy"){z=d.jqplot.sprintf(t.tooltipFormatString,m.data[0])+t.tooltipSeparator+d.jqplot.sprintf(t.tooltipFormatString,m.data[1])}else{if(t.tooltipAxes=="yx"){z=d.jqplot.sprintf(t.tooltipFormatString,m.data[1])+t.tooltipSeparator+d.jqplot.sprintf(t.tooltipFormatString,m.data[0])}else{if(t.tooltipAxes=="x"){z=d.jqplot.sprintf(t.tooltipFormatString,m.data[0])}else{if(t.tooltipAxes=="y"){z=d.jqplot.sprintf(t.tooltipFormatString,m.data[1])}}}}}}if(d.isFunction(t.tooltipContentEditor)){z=t.tooltipContentEditor(z,m.seriesIndex,m.pointIndex,A)}D.html(z);var C={x:m.gridData[0],y:m.gridData[1]};var v=0;var j=0.707;if(q.markerRenderer.show==true){v=(q.markerRenderer.size+t.sizeAdjust)/2}var o=b;if(q.fillToZero&&q.fill&&m.data[1]<0){o=c}switch(o[e[t.tooltipLocation]]){case"nw":var p=C.x+A._gridPadding.left-D.outerWidth(true)-t.tooltipOffset-j*v;var n=C.y+A._gridPadding.top-t.tooltipOffset-D.outerHeight(true)-j*v;break;case"n":var p=C.x+A._gridPadding.left-D.outerWidth(true)/2;var n=C.y+A._gridPadding.top-t.tooltipOffset-D.outerHeight(true)-v;break;case"ne":var p=C.x+A._gridPadding.left+t.tooltipOffset+j*v;var n=C.y+A._gridPadding.top-t.tooltipOffset-D.outerHeight(true)-j*v;break;case"e":var p=C.x+A._gridPadding.left+t.tooltipOffset+v;var n=C.y+A._gridPadding.top-D.outerHeight(true)/2;break;case"se":var p=C.x+A._gridPadding.left+t.tooltipOffset+j*v;var n=C.y+A._gridPadding.top+t.tooltipOffset+j*v;break;case"s":var p=C.x+A._gridPadding.left-D.outerWidth(true)/2;var n=C.y+A._gridPadding.top+t.tooltipOffset+v;break;case"sw":var p=C.x+A._gridPadding.left-D.outerWidth(true)-t.tooltipOffset-j*v;var n=C.y+A._gridPadding.top+t.tooltipOffset+j*v;break;case"w":var p=C.x+A._gridPadding.left-D.outerWidth(true)-t.tooltipOffset-v;var n=C.y+A._gridPadding.top-D.outerHeight(true)/2;break;default:var p=C.x+A._gridPadding.left-D.outerWidth(true)-t.tooltipOffset-j*v;var n=C.y+A._gridPadding.top-t.tooltipOffset-D.outerHeight(true)-j*v;break}D.css("left",p);D.css("top",n);if(t.fadeTooltip){D.stop(true,true).fadeIn(t.tooltipFadeSpeed)}else{D.show()}D=null}function f(k,j,n,m,l){var h=l.plugins.highlighter;var o=l.plugins.cursor;if(h.show){if(m==null&&h.isHighlighting){var i=h.highlightCanvas._ctx;i.clearRect(0,0,i.canvas.width,i.canvas.height);if(h.fadeTooltip){h._tooltipElem.fadeOut(h.tooltipFadeSpeed)}else{h._tooltipElem.hide()}if(h.bringSeriesToFront){l.restorePreviousSeriesOrder()}h.isHighlighting=false;h.currentNeighbor=null;i=null}else{if(m!=null&&l.series[m.seriesIndex].showHighlight&&!h.isHighlighting){h.isHighlighting=true;h.currentNeighbor=m;if(h.showMarker){a(l,m)}if(h.showTooltip&&(!o||!o._zoom.started)){g(l,l.series[m.seriesIndex],m)}if(h.bringSeriesToFront){l.moveSeriesToFront(m.seriesIndex)}}else{if(m!=null&&h.isHighlighting&&h.currentNeighbor!=m){if(l.series[m.seriesIndex].showHighlight){var i=h.highlightCanvas._ctx;i.clearRect(0,0,i.canvas.width,i.canvas.height);h.isHighlighting=true;h.currentNeighbor=m;if(h.showMarker){a(l,m)}if(h.showTooltip&&(!o||!o._zoom.started)){g(l,l.series[m.seriesIndex],m)}if(h.bringSeriesToFront){l.moveSeriesToFront(m.seriesIndex)}}}}}}}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.json2.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.json2.js
deleted file mode 100644
index 46fb942..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.json2.js
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
-    2010-11-01 Chris Leonello
-    
-    Slightly modified version of the original json2.js to put JSON
-    functions under the $.jqplot namespace.
-    
-    licensing and orignal comments follow:
-    
-    http://www.JSON.org/json2.js
-    2010-08-25
-    
-    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.
-
-        $.jqplot.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.
-            $.jqplot.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 = $.jqplot.JSON.stringify(['e', {pluribus: 'unum'}]);
-            // text is '["e",{"pluribus":"unum"}]'
-
-
-            text = $.jqplot.JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
-            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
-
-            text = $.jqplot.JSON.stringify([new Date()], function (key, value) {
-                return this[key] instanceof Date ?
-                    'Date(' + this[key] + ')' : value;
-            });
-            // text is '["Date(---current time---)"]'
-
-
-        $.jqplot.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 = $.jqplot.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 = $.jqplot.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.
-*/
-
-(function($) {
-
-    $.jqplot.JSON = window.JSON;
-
-    if (!window.JSON) {
-        $.jqplot.JSON = {};
-    }
-    
-    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 (key) {
-
-            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 (key) {
-            return this.valueOf();
-        };
-    }
-
-    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
-        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
-        gap,
-        indent,
-        meta = {    // table of character substitutions
-            '\b': '\\b',
-            '\t': '\\t',
-            '\n': '\\n',
-            '\f': '\\f',
-            '\r': '\\r',
-            '"' : '\\"',
-            '\\': '\\\\'
-        },
-        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) {
-                    k = rep[i];
-                    if (typeof k === 'string') {
-                        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.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 $.jqplot.JSON.stringify !== 'function') {
-        $.jqplot.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('$.jqplot.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 $.jqplot.JSON.parse !== 'function') {
-        $.jqplot.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.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('$.jqplot.JSON.parse');
-        };
-    }
-})(jQuery);
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.json2.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.json2.min.js
deleted file mode 100644
index 492ac43..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.json2.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function($){$.jqplot.JSON=window.JSON;if(!window.JSON){$.jqplot.JSON={}}function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){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(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){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){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof $.jqplot.JSON.stringify!=="function"){$.jqplot.JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("$.jqplot.JSON.stringify")}return str("",{"":value})}}if(typeof $.jqplot.JSON.parse!=="function"){$.jqplot.JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}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)})}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,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("$.jqplot.JSON.parse")}}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.logAxisRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.logAxisRenderer.js
deleted file mode 100644
index e4e28f2..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.logAxisRenderer.js
+++ /dev/null
@@ -1,450 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-    *  class: $.jqplot.LogAxisRenderer
-    *  A plugin for a jqPlot to render a logarithmic axis.
-    * 
-    *  To use this renderer, include the plugin in your source
-    *  > <script type="text/javascript" language="javascript" src="plugins/jqplot.logAxisRenderer.js"></script>
-    *  
-    *  and supply the appropriate options to your plot
-    *  
-    *  > {axes:{xaxis:{renderer:$.jqplot.LogAxisRenderer}}}
-    **/ 
-    $.jqplot.LogAxisRenderer = function() {
-        $.jqplot.LinearAxisRenderer.call(this);
-        // prop: axisDefaults
-        // Default properties which will be applied directly to the series.
-        //
-        // Group: Properties
-        //
-        // Properties
-        //
-        /// base - the logarithmic base, commonly 2, 10 or Math.E
-        // tickDistribution - 'even' or 'power'.  'even' gives equal pixel
-        // spacing of the ticks on the plot.  'power' gives ticks in powers
-        // of 10.
-        this.axisDefaults = {
-            base : 10,
-            tickDistribution :'even'
-        };
-    };
-    
-    $.jqplot.LogAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
-    $.jqplot.LogAxisRenderer.prototype.constructor = $.jqplot.LogAxisRenderer;
-    
-    $.jqplot.LogAxisRenderer.prototype.init = function(options) {
-        // prop: drawBaseline
-        // True to draw the axis baseline.
-        this.drawBaseline = true;
-        $.extend(true, this.renderer, options);
-        for (var d in this.renderer.axisDefaults) {
-            if (this[d] == null) {
-                this[d] = this.renderer.axisDefaults[d];
-            }
-        }
-        var db = this._dataBounds;
-        // Go through all the series attached to this axis and find
-        // the min/max bounds for this axis.
-        for (var i=0; i<this._series.length; i++) {
-            var s = this._series[i];
-            var d = s.data;
-            
-            for (var j=0; j<d.length; j++) { 
-                if (this.name == 'xaxis' || this.name == 'x2axis') {
-                    if ((d[j][0] != null && d[j][0] < db.min) || db.min == null) {
-                        db.min = d[j][0];
-                    }
-                    if ((d[j][0] != null && d[j][0] > db.max) || db.max == null) {
-                        db.max = d[j][0];
-                    }
-                }              
-                else {
-                    if ((d[j][1] != null && d[j][1] < db.min) || db.min == null) {
-                        db.min = d[j][1];
-                    }
-                    if ((d[j][1] != null && d[j][1] > db.max) || db.max == null) {
-                        db.max = d[j][1];
-                    }
-                }               
-            }
-        }
-    };
-    
-    $.jqplot.LogAxisRenderer.prototype.createTicks = function() {
-        // we're are operating on an axis here
-        var ticks = this._ticks;
-        var userTicks = this.ticks;
-        var name = this.name;
-        var db = this._dataBounds;
-        var dim, interval;
-        var min, max;
-        var pos1, pos2;
-        var tt, i;
-
-        // if we already have ticks, use them.
-        // ticks must be in order of increasing value.
-        if (userTicks.length) {
-            // ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed
-            for (i=0; i<userTicks.length; i++){
-                var ut = userTicks[i];
-                var t = new this.tickRenderer(this.tickOptions);
-                if (ut.constructor == Array) {
-                    t.value = ut[0];
-                    t.label = ut[1];
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(ut[0], this.name);
-                    this._ticks.push(t);
-                }
-
-                else if ($.isPlainObject(ut)) {
-                    $.extend(true, t, ut);
-                    t.axis = this.name;
-                    this._ticks.push(t);
-                }
-                
-                else {
-                    t.value = ut;
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(ut, this.name);
-                    this._ticks.push(t);
-                }
-            }
-            this.numberTicks = userTicks.length;
-            this.min = this._ticks[0].value;
-            this.max = this._ticks[this.numberTicks-1].value;
-        }
-        
-        // we don't have any ticks yet, let's make some!
-        else {
-            if (name == 'xaxis' || name == 'x2axis') {
-                dim = this._plotDimensions.width;
-            }
-            else {
-                dim = this._plotDimensions.height;
-            }
-        
-            min = ((this.min != null) ? this.min : db.min);
-            max = ((this.max != null) ? this.max : db.max);
-            
-            // if min and max are same, space them out a bit
-            if (min == max) {
-                var adj = 0.05;
-                min = min*(1-adj);
-                max = max*(1+adj);
-            }
-            
-            // perform some checks
-            if (this.min != null && this.min <= 0) {
-                throw('log axis minimum must be greater than 0');
-            }
-            if (this.max != null && this.max <= 0) {
-                throw('log axis maximum must be greater than 0');
-            }
-            // if (this.pad >1.99) this.pad = 1.99;
-            var range = max - min;
-            var rmin, rmax;
-
-            if (this.tickDistribution == 'even') {                    
-                rmin = (this.min != null) ? this.min : min - min*((this.padMin-1)/2);
-                rmax = (this.max != null) ? this.max : max + max*((this.padMax-1)/2);
-                this.min = rmin;
-                this.max = rmax;
-                range = this.max - this.min;            
-        
-                if (this.numberTicks == null){
-                    if (dim > 100) {
-                        this.numberTicks = parseInt(3+(dim-100)/75, 10);
-                    }
-                    else {
-                        this.numberTicks = 2;
-                    }
-                }
-    
-                var u = Math.pow(this.base, (1/(this.numberTicks-1)*Math.log(this.max/this.min)/Math.log(this.base)));
-                for (var i=0; i<this.numberTicks; i++){
-                    tt = this.min * Math.pow(u, i);
-                    var t = new this.tickRenderer(this.tickOptions);
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(tt, this.name);
-                    this._ticks.push(t);
-                }
-                
-            }
-            
-            else if (this.tickDistribution == 'power'){
-                // for power distribution, open up range to get a nice power of axis.renderer.base.
-                // power distribution won't respect the user's min/max settings.
-                rmin = Math.pow(this.base, Math.ceil(Math.log(min*(2-this.padMin))/Math.log(this.base))-1);
-                rmax = Math.pow(this.base, Math.floor(Math.log(max*this.padMax)/Math.log(this.base))+1);
-                this.min = rmin;
-                this.max = rmax;
-                range = this.max - this.min;            
-        
-                var fittedTicks = 0;
-                var minorTicks = 0;
-                if (this.numberTicks == null){
-                    if (dim > 100) {
-                        this.numberTicks = Math.round(Math.log(this.max/this.min)/Math.log(this.base) + 1);
-                        if (this.numberTicks < 2) {
-                            this.numberTicks = 2;
-                        }
-                        fittedTicks = parseInt(3+(dim-100)/75, 10);
-                    }
-                    else {
-                        this.numberTicks = 2;
-                        fittedTicks = 2;
-                    }
-                    // if we don't have enough ticks, add some intermediate ticks
-                    // how many to have between major ticks.
-                    if (this.numberTicks < fittedTicks-1) {
-                        minorTicks = Math.floor(fittedTicks/this.numberTicks);
-                    }
-                }
-
-                for (var i=0; i<this.numberTicks; i++){
-                    tt = Math.pow(this.base, i - this.numberTicks + 1) * this.max;
-                    var t = new this.tickRenderer(this.tickOptions);
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(tt, this.name);
-                    this._ticks.push(t);
-            
-                    if (minorTicks && i<this.numberTicks-1) {
-                        var tt1 = Math.pow(this.base, i - this.numberTicks + 2) * this.max;
-                        var spread = tt1 - tt;
-                        var interval = tt1 / (minorTicks+1);
-                        for (var j=minorTicks-1; j>=0; j--) {
-                            var val = tt1-interval*(j+1);
-                            var t = new this.tickRenderer(this.tickOptions);
-                            if (!this.showTicks) {
-                                t.showLabel = false;
-                                t.showMark = false;
-                            }
-                            else if (!this.showTickMarks) {
-                                t.showMark = false;
-                            }
-                            t.setTick(val, this.name);
-                            this._ticks.push(t);
-                        }
-                    }       
-                }                    
-            }       
-        }
-    };
-    
-    $.jqplot.LogAxisRenderer.prototype.pack = function(pos, offsets) {
-        var lb = parseInt(this.base, 10);
-        var ticks = this._ticks;
-        var trans = function (v) { return Math.log(v)/Math.log(lb); };
-        var invtrans = function (v) { return Math.pow(Math.E, (Math.log(lb)*v)); };
-        var max = trans(this.max);
-        var min = trans(this.min);
-        var offmax = offsets.max;
-        var offmin = offsets.min;
-        var lshow = (this._label == null) ? false : this._label.show;
-        
-        for (var p in pos) {
-            this._elem.css(p, pos[p]);
-        }
-        
-        this._offsets = offsets;
-        // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left.
-        var pixellength = offmax - offmin;
-        var unitlength = max - min;
-        
-        // point to unit and unit to point conversions references to Plot DOM element top left corner.
-        this.p2u = function(p){
-            return invtrans((p - offmin) * unitlength / pixellength + min);
-        };
-        
-        this.u2p = function(u){
-            return (trans(u) - min) * pixellength / unitlength + offmin;
-        };
-        
-        if (this.name == 'xaxis' || this.name == 'x2axis'){
-            this.series_u2p = function(u){
-                return (trans(u) - min) * pixellength / unitlength;
-            };
-            this.series_p2u = function(p){
-                return invtrans(p * unitlength / pixellength + min);
-            };
-        }
-        // yaxis is max at top of canvas.
-        else {
-            this.series_u2p = function(u){
-                return (trans(u) - max) * pixellength / unitlength;
-            };
-            this.series_p2u = function(p){
-                return invtrans(p * unitlength / pixellength + max);
-            };
-        }
-        
-        if (this.show) {
-            if (this.name == 'xaxis' || this.name == 'x2axis') {
-                for (var i=0; i<ticks.length; i++) {
-                    var t = ticks[i];
-                    if (t.show && t.showLabel) {
-                        var shim;
-                        
-                        if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
-                            switch (t.labelPosition) {
-                                case 'auto':
-                                    // position at end
-                                    if (t.angle < 0) {
-                                        shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    }
-                                    // position at start
-                                    else {
-                                        shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'end':
-                                    shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                                case 'start':
-                                    shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    break;
-                                case 'middle':
-                                    shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                                default:
-                                    shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                            }
-                        }
-                        else {
-                            shim = -t.getWidth()/2;
-                        }
-                        // var shim = t.getWidth()/2;
-                        var val = this.u2p(t.value) + shim + 'px';
-                        t._elem.css('left', val);
-                        t.pack();
-                    }
-                }
-                if (lshow) {
-                    var w = this._label._elem.outerWidth(true);
-                    this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px');
-                    if (this.name == 'xaxis') {
-                        this._label._elem.css('bottom', '0px');
-                    }
-                    else {
-                        this._label._elem.css('top', '0px');
-                    }
-                    this._label.pack();
-                }
-            }
-            else {
-                for (var i=0; i<ticks.length; i++) {
-                    var t = ticks[i];
-                    if (t.show && t.showLabel) {                        
-                        var shim;
-                        if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
-                            switch (t.labelPosition) {
-                                case 'auto':
-                                    // position at end
-                                case 'end':
-                                    if (t.angle < 0) {
-                                        shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
-                                    }
-                                    else {
-                                        shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'start':
-                                    if (t.angle > 0) {
-                                        shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
-                                    }
-                                    else {
-                                        shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'middle':
-                                    // if (t.angle > 0) {
-                                    //     shim = -t.getHeight()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    // }
-                                    // else {
-                                    //     shim = -t.getHeight()/2 - t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    // }
-                                    shim = -t.getHeight()/2;
-                                    break;
-                                default:
-                                    shim = -t.getHeight()/2;
-                                    break;
-                            }
-                        }
-                        else {
-                            shim = -t.getHeight()/2;
-                        }
-                        
-                        var val = this.u2p(t.value) + shim + 'px';
-                        t._elem.css('top', val);
-                        t.pack();
-                    }
-                }
-                if (lshow) {
-                    var h = this._label._elem.outerHeight(true);
-                    this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px');
-                    if (this.name == 'yaxis') {
-                        this._label._elem.css('left', '0px');
-                    }
-                    else {
-                        this._label._elem.css('right', '0px');
-                    }   
-                    this._label.pack();
-                }
-            }
-        }        
-    };
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.logAxisRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.logAxisRenderer.min.js
deleted file mode 100644
index fc5713e..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.logAxisRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.LogAxisRenderer=function(){a.jqplot.LinearAxisRenderer.call(this);this.axisDefaults={base:10,tickDistribution:"even"}};a.jqplot.LogAxisRenderer.prototype=new a.jqplot.LinearAxisRenderer();a.jqplot.LogAxisRenderer.prototype.constructor=a.jqplot.LogAxisRenderer;a.jqplot.LogAxisRenderer.prototype.init=function(e){this.drawBaseline=true;a.extend(true,this.renderer,e);for(var h in this.renderer.axisDefaults){if(this[h]==null){this[h]=this.renderer.axisDefaults[h]}}var b=this._dataBounds;for(var f=0;f<this._series.length;f++){var g=this._series[f];var h=g.data;for(var c=0;c<h.length;c++){if(this.name=="xaxis"||this.name=="x2axis"){if((h[c][0]!=null&&h[c][0]<b.min)||b.min==null){b.min=h[c][0]}if((h[c][0]!=null&&h[c][0]>b.max)||b.max==null){b.max=h[c][0]}}else{if((h[c][1]!=null&&h[c][1]<b.min)||b.min==null){b.min=h[c][1]}if((h[c][1]!=null&&h[c][1]>b.max)||b.max==null){b.max=h[c][1]}}}}};a.jqplot.LogAxisRenderer.prototype.createTicks=function(){var A=this._ticks;var x=this.ticks;var D=this.name;var z=this._dataBounds;var s,y;var o,v;var e,d;var b,w;if(x.length){for(w=0;w<x.length;w++){var f=x[w];var k=new this.tickRenderer(this.tickOptions);if(f.constructor==Array){k.value=f[0];k.label=f[1];if(!this.showTicks){k.showLabel=false;k.showMark=false}else{if(!this.showTickMarks){k.showMark=false}}k.setTick(f[0],this.name);this._ticks.push(k)}else{if(a.isPlainObject(f)){a.extend(true,k,f);k.axis=this.name;this._ticks.push(k)}else{k.value=f;if(!this.showTicks){k.showLabel=false;k.showMark=false}else{if(!this.showTickMarks){k.showMark=false}}k.setTick(f,this.name);this._ticks.push(k)}}}this.numberTicks=x.length;this.min=this._ticks[0].value;this.max=this._ticks[this.numberTicks-1].value}else{if(D=="xaxis"||D=="x2axis"){s=this._plotDimensions.width}else{s=this._plotDimensions.height}o=((this.min!=null)?this.min:z.min);v=((this.max!=null)?this.max:z.max);if(o==v){var g=0.05;o=o*(1-g);v=v*(1+g)}if(this.min!=null&&this.min<=0){throw ("log axis minimum must be greater than 0")}if(this.max!=null&&this.max<=0){throw ("log axis maximum must be greater than 0")}var l=v-o;var n,r;if(this.tickDistribution=="even"){n=(this.min!=null)?this.min:o-o*((this.padMin-1)/2);r=(this.max!=null)?this.max:v+v*((this.padMax-1)/2);this.min=n;this.max=r;l=this.max-this.min;if(this.numberTicks==null){if(s>100){this.numberTicks=parseInt(3+(s-100)/75,10)}else{this.numberTicks=2}}var h=Math.pow(this.base,(1/(this.numberTicks-1)*Math.log(this.max/this.min)/Math.log(this.base)));for(var w=0;w<this.numberTicks;w++){b=this.min*Math.pow(h,w);var k=new this.tickRenderer(this.tickOptions);if(!this.showTicks){k.showLabel=false;k.showMark=false}else{if(!this.showTickMarks){k.showMark=false}}k.setTick(b,this.name);this._ticks.push(k)}}else{if(this.tickDistribution=="power"){n=Math.pow(this.base,Math.ceil(Math.log(o*(2-this.padMin))/Math.log(this.base))-1);r=Math.pow(this.base,Math.floor(Math.log(v*this.padMax)/Math.log(this.base))+1);this.min=n;this.max=r;l=this.max-this.min;var q=0;var c=0;if(this.numberTicks==null){if(s>100){this.numberTicks=Math.round(Math.log(this.max/this.min)/Math.log(this.base)+1);if(this.numberTicks<2){this.numberTicks=2}q=parseInt(3+(s-100)/75,10)}else{this.numberTicks=2;q=2}if(this.numberTicks<q-1){c=Math.floor(q/this.numberTicks)}}for(var w=0;w<this.numberTicks;w++){b=Math.pow(this.base,w-this.numberTicks+1)*this.max;var k=new this.tickRenderer(this.tickOptions);if(!this.showTicks){k.showLabel=false;k.showMark=false}else{if(!this.showTickMarks){k.showMark=false}}k.setTick(b,this.name);this._ticks.push(k);if(c&&w<this.numberTicks-1){var m=Math.pow(this.base,w-this.numberTicks+2)*this.max;var B=m-b;var y=m/(c+1);for(var p=c-1;p>=0;p--){var C=m-y*(p+1);var k=new this.tickRenderer(this.tickOptions);if(!this.showTicks){k.showLabel=false;k.showMark=false}else{if(!this.showTickMarks){k.showMark=false}}k.setTick(C,this.name);this._ticks.push(k)}}}}}}};a.jqplot.LogAxisRenderer.prototype.pack=function(f,e){var r=parseInt(this.base,10);var y=this._ticks;var d=function(h){return Math.log(h)/Math.log(r)};var b=function(h){return Math.pow(Math.E,(Math.log(r)*h))};var u=d(this.max);var s=d(this.min);var m=e.max;var k=e.min;var o=(this._label==null)?false:this._label.show;for(var q in f){this._elem.css(q,f[q])}this._offsets=e;var g=m-k;var j=u-s;this.p2u=function(h){return b((h-k)*j/g+s)};this.u2p=function(h){return(d(h)-s)*g/j+k};if(this.name=="xaxis"||this.name=="x2axis"){this.series_u2p=function(h){return(d(h)-s)*g/j};this.series_p2u=function(h){return b(h*j/g+s)}}else{this.series_u2p=function(h){return(d(h)-u)*g/j};this.series_p2u=function(h){return b(h*j/g+u)}}if(this.show){if(this.name=="xaxis"||this.name=="x2axis"){for(var v=0;v<y.length;v++){var n=y[v];if(n.show&&n.showLabel){var c;if(n.constructor==a.jqplot.CanvasAxisTickRenderer&&n.angle){switch(n.labelPosition){case"auto":if(n.angle<0){c=-n.getWidth()+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2}else{c=-n._textRenderer.height*Math.sin(n._textRenderer.angle)/2}break;case"end":c=-n.getWidth()+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2;break;case"start":c=-n._textRenderer.height*Math.sin(n._textRenderer.angle)/2;break;case"middle":c=-n.getWidth()/2+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2;break;default:c=-n.getWidth()/2+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2;break}}else{c=-n.getWidth()/2}var z=this.u2p(n.value)+c+"px";n._elem.css("left",z);n.pack()}}if(o){var l=this._label._elem.outerWidth(true);this._label._elem.css("left",k+g/2-l/2+"px");if(this.name=="xaxis"){this._label._elem.css("bottom","0px")}else{this._label._elem.css("top","0px")}this._label.pack()}}else{for(var v=0;v<y.length;v++){var n=y[v];if(n.show&&n.showLabel){var c;if(n.constructor==a.jqplot.CanvasAxisTickRenderer&&n.angle){switch(n.labelPosition){case"auto":case"end":if(n.angle<0){c=-n._textRenderer.height*Math.cos(-n._textRenderer.angle)/2}else{c=-n.getHeight()+n._textRenderer.height*Math.cos(n._textRenderer.angle)/2}break;case"start":if(n.angle>0){c=-n._textRenderer.height*Math.cos(-n._textRenderer.angle)/2}else{c=-n.getHeight()+n._textRenderer.height*Math.cos(n._textRenderer.angle)/2}break;case"middle":c=-n.getHeight()/2;break;default:c=-n.getHeight()/2;break}}else{c=-n.getHeight()/2}var z=this.u2p(n.value)+c+"px";n._elem.css("top",z);n.pack()}}if(o){var x=this._label._elem.outerHeight(true);this._label._elem.css("top",m-g/2-x/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{this._label._elem.css("right","0px")}this._label.pack()}}}}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoAxisRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoAxisRenderer.js
deleted file mode 100644
index e74d4eb..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoAxisRenderer.js
+++ /dev/null
@@ -1,610 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    // class: $.jqplot.MekkoAxisRenderer
-    // An axis renderer for a Mekko chart.
-    // Should be used with a Mekko chart where the mekkoRenderer is used on the series.
-    // Displays the Y axis as a range from 0 to 1 (0 to 100%) and the x axis with a tick
-    // for each series scaled to the sum of all the y values.
-    $.jqplot.MekkoAxisRenderer = function() {
-    };
-    
-    // called with scope of axis object.
-    $.jqplot.MekkoAxisRenderer.prototype.init = function(options){
-        // prop: tickMode
-        // How to space the ticks on the axis.
-        // 'bar' will place a tick at the width of each bar.  
-        // This is the default for the x axis.
-        // 'even' will place ticks at even intervals.  This is
-        // the default for x2 axis and y axis.  y axis cannot be changed.
-        this.tickMode;
-        // prop: barLabelRenderer
-        // renderer to use to draw labels under each bar.
-        this.barLabelRenderer = $.jqplot.AxisLabelRenderer;
-        // prop: barLabels
-        // array of labels to put under each bar.
-        this.barLabels = this.barLabels || [];
-        // prop: barLabelOptions
-        // options object to pass to the bar label renderer.
-        this.barLabelOptions = {};
-        this.tickOptions = $.extend(true, {showGridline:false}, this.tickOptions);
-        this._barLabels = [];
-        $.extend(true, this, options);
-        if (this.name == 'yaxis') {
-            this.tickOptions.formatString = this.tickOptions.formatString || "%d\%";
-        }
-        var db = this._dataBounds;
-        db.min = 0;
-        // for y axes, scale always go from 0 to 1 (0 to 100%)
-        if (this.name == 'yaxis' || this.name == 'y2axis') {
-            db.max = 100;
-            this.tickMode = 'even';
-        }
-        // For x axes, scale goes from 0 to sum of all y values.
-        else if (this.name == 'xaxis'){
-            this.tickMode = (this.tickMode == null) ? 'bar' : this.tickMode;
-            for (var i=0; i<this._series.length; i++) {
-                db.max += this._series[i]._sumy;
-            }
-        }
-        else if (this.name == 'x2axis'){
-            this.tickMode = (this.tickMode == null) ? 'even' : this.tickMode;
-            for (var i=0; i<this._series.length; i++) {
-                db.max += this._series[i]._sumy;
-            }
-        }
-    };
-    
-    // called with scope of axis
-    $.jqplot.MekkoAxisRenderer.prototype.draw = function(ctx, plot) {
-        if (this.show) {
-            // populate the axis label and value properties.
-            // createTicks is a method on the renderer, but
-            // call it within the scope of the axis.
-            this.renderer.createTicks.call(this);
-            // fill a div with axes labels in the right direction.
-            // Need to pregenerate each axis to get it's bounds and
-            // position it and the labels correctly on the plot.
-            var dim=0;
-            var temp;
-            
-            var elem = document.createElement('div');
-            this._elem = $(elem);
-            this._elem.addClass('jqplot-axis jqplot-'+this.name);
-            this._elem.css('position', 'absolute');
-            elem = null;
-            
-            if (this.name == 'xaxis' || this.name == 'x2axis') {
-                this._elem.width(this._plotDimensions.width);
-            }
-            else {
-                this._elem.height(this._plotDimensions.height);
-            }
-            
-            // draw the axis label
-            // create a _label object.
-            this.labelOptions.axis = this.name;
-            this._label = new this.labelRenderer(this.labelOptions);
-            if (this._label.show) {
-                this._elem.append(this._label.draw(ctx));
-            }
-            
-            var t, tick, elem;
-            if (this.showTicks) {
-                t = this._ticks;
-                for (var i=0; i<t.length; i++) {
-                    tick = t[i];
-                    if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
-                        this._elem.append(tick.draw(ctx));
-                    }
-                }
-            }
-            
-            // draw the series labels
-            for (i=0; i<this.barLabels.length; i++) {
-                this.barLabelOptions.axis = this.name;
-                this.barLabelOptions.label = this.barLabels[i];
-                this._barLabels.push(new this.barLabelRenderer(this.barLabelOptions));
-                if (this.tickMode != 'bar') {
-                    this._barLabels[i].show = false;
-                }
-                if (this._barLabels[i].show) {
-                    var elem = this._barLabels[i].draw(ctx, plot);
-                    elem.removeClass('jqplot-'+this.name+'-label');
-                    elem.addClass('jqplot-'+this.name+'-tick');
-                    elem.addClass('jqplot-mekko-barLabel');
-                    elem.appendTo(this._elem);
-                    elem = null;
-                }   
-            }
-            
-        }
-        return this._elem;
-    };
-    
-    // called with scope of an axis
-    $.jqplot.MekkoAxisRenderer.prototype.reset = function() {
-        this.min = this._min;
-        this.max = this._max;
-        this.tickInterval = this._tickInterval;
-        this.numberTicks = this._numberTicks;
-        // this._ticks = this.__ticks;
-    };
-    
-    // called with scope of axis
-    $.jqplot.MekkoAxisRenderer.prototype.set = function() { 
-        var dim = 0;
-        var temp;
-        var w = 0;
-        var h = 0;
-        var lshow = (this._label == null) ? false : this._label.show;
-        if (this.show && this.showTicks) {
-            var t = this._ticks;
-            for (var i=0; i<t.length; i++) {
-                var tick = t[i];
-                if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
-                    if (this.name == 'xaxis' || this.name == 'x2axis') {
-                        temp = tick._elem.outerHeight(true);
-                    }
-                    else {
-                        temp = tick._elem.outerWidth(true);
-                    }
-                    if (temp > dim) {
-                        dim = temp;
-                    }
-                }
-            }
-            
-            if (lshow) {
-                w = this._label._elem.outerWidth(true);
-                h = this._label._elem.outerHeight(true); 
-            }
-            if (this.name == 'xaxis') {
-                dim = dim + h;
-                this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'});
-            }
-            else if (this.name == 'x2axis') {
-                dim = dim + h;
-                this._elem.css({'height':dim+'px', left:'0px', top:'0px'});
-            }
-            else if (this.name == 'yaxis') {
-                dim = dim + w;
-                this._elem.css({'width':dim+'px', left:'0px', top:'0px'});
-                if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
-                    this._label._elem.css('width', w+'px');
-                }
-            }
-            else {
-                dim = dim + w;
-                this._elem.css({'width':dim+'px', right:'0px', top:'0px'});
-                if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
-                    this._label._elem.css('width', w+'px');
-                }
-            }
-        }  
-    };    
-    
-    // called with scope of axis
-    $.jqplot.MekkoAxisRenderer.prototype.createTicks = function() {
-        // we're are operating on an axis here
-        var ticks = this._ticks;
-        var userTicks = this.ticks;
-        var name = this.name;
-        // databounds were set on axis initialization.
-        var db = this._dataBounds;
-        var dim, interval;
-        var min, max;
-        var pos1, pos2;
-        var t, tt, i, j;
-        
-        // if we already have ticks, use them.
-        // ticks must be in order of increasing value.
-        
-        if (userTicks.length) {
-            // ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed
-            for (i=0; i<userTicks.length; i++){
-                var ut = userTicks[i];
-                var t = new this.tickRenderer(this.tickOptions);
-                if (ut.constructor == Array) {
-                    t.value = ut[0];
-                    t.label = ut[1];
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(ut[0], this.name);
-                    this._ticks.push(t);
-                }
-                
-                else {
-                    t.value = ut;
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(ut, this.name);
-                    this._ticks.push(t);
-                }
-            }
-            this.numberTicks = userTicks.length;
-            this.min = this._ticks[0].value;
-            this.max = this._ticks[this.numberTicks-1].value;
-            this.tickInterval = (this.max - this.min) / (this.numberTicks - 1);
-        }
-        
-        // we don't have any ticks yet, let's make some!
-        else {
-            if (name == 'xaxis' || name == 'x2axis') {
-                dim = this._plotDimensions.width;
-            }
-            else {
-                dim = this._plotDimensions.height;
-            }
-            
-            // if min, max and number of ticks specified, user can't specify interval.
-            if (this.min != null && this.max != null && this.numberTicks != null) {
-                this.tickInterval = null;
-            }
-        
-            min = (this.min != null) ? this.min : db.min;
-            max = (this.max != null) ? this.max : db.max;
-            
-            // if min and max are same, space them out a bit.+
-            if (min == max) {
-                var adj = 0.05;
-                if (min > 0) {
-                    adj = Math.max(Math.log(min)/Math.LN10, 0.05);
-                }
-                min -= adj;
-                max += adj;
-            }
-
-            var range = max - min;
-            var rmin, rmax;
-            var temp, prev, curr;
-            var ynumticks = [3,5,6,11,21];
-            
-            // yaxis divide ticks in nice intervals from 0 to 1.
-            if (this.name == 'yaxis' || this.name == 'y2axis') { 
-                this.min = 0;
-                this.max = 100; 
-                // user didn't specify number of ticks.
-                if (!this.numberTicks){
-                    if (this.tickInterval) {
-                        this.numberTicks = 3 + Math.ceil(range / this.tickInterval);
-                    }
-                    else {
-                        temp = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing);
-                        for (i=0; i<ynumticks.length; i++) {
-                            curr = temp/ynumticks[i];
-                            if (curr == 1) {
-                                this.numberTicks = ynumticks[i];
-                                break;
-                            }
-                            else if (curr > 1) {
-                                prev = curr;
-                                continue;
-                            }
-                            else if (curr < 1) {
-                                // was prev or is curr closer to one?
-                                if (Math.abs(prev - 1) < Math.abs(curr - 1)) {
-                                    this.numberTicks = ynumticks[i-1];
-                                    break;
-                                }
-                                else {
-                                    this.numberTicks = ynumticks[i];
-                                    break;
-                                }
-                            }
-                            else if (i == ynumticks.length -1) {
-                                this.numberTicks = ynumticks[i];
-                            }
-                        }
-                        this.tickInterval = range / (this.numberTicks - 1);
-                    }
-                }
-                
-                // user did specify number of ticks.
-                else {
-                    this.tickInterval = range / (this.numberTicks - 1);
-                }
-
-                for (var i=0; i<this.numberTicks; i++){
-                    tt = this.min + i * this.tickInterval;
-                    t = new this.tickRenderer(this.tickOptions);
-                    // var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(tt, this.name);
-                    this._ticks.push(t);
-                }
-            }
-            
-            // for x axes, have number ot ticks equal to number of series and ticks placed
-            // at sum of y values for each series.
-            else if (this.tickMode == 'bar') {
-                this.min = 0;
-                this.numberTicks = this._series.length + 1;
-                t = new this.tickRenderer(this.tickOptions);
-                if (!this.showTicks) {
-                    t.showLabel = false;
-                    t.showMark = false;
-                }
-                else if (!this.showTickMarks) {
-                    t.showMark = false;
-                }
-                t.setTick(0, this.name);
-                this._ticks.push(t);
-                
-                temp = 0;
-
-                for (i=1; i<this.numberTicks; i++){
-                    temp += this._series[i-1]._sumy;
-                    t = new this.tickRenderer(this.tickOptions);
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(temp, this.name);
-                    this._ticks.push(t);
-                }
-                this.max = this.max || temp;
-                
-                // if user specified a max and it is greater than sum, add a tick
-                if (this.max > temp) {
-                     t = new this.tickRenderer(this.tickOptions);
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(this.max, this.name);
-                    this._ticks.push(t);
-                    
-                }
-            }
-            
-            else if (this.tickMode == 'even') {
-                this.min = 0;
-                this.max = this.max || db.max;
-                // get a desired number of ticks
-                var nt = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing);
-                range = this.max - this.min;
-                this.numberTicks = nt;
-                this.tickInterval = range / (this.numberTicks - 1);
-
-                for (i=0; i<this.numberTicks; i++){
-                    tt = this.min + i * this.tickInterval;
-                    t = new this.tickRenderer(this.tickOptions);
-                    // var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(tt, this.name);
-                    this._ticks.push(t);
-                }
-                
-            }
-        }
-    };
-    
-    // called with scope of axis
-    $.jqplot.MekkoAxisRenderer.prototype.pack = function(pos, offsets) {
-        var ticks = this._ticks;
-        var max = this.max;
-        var min = this.min;
-        var offmax = offsets.max;
-        var offmin = offsets.min;
-        var lshow = (this._label == null) ? false : this._label.show;
-        
-        for (var p in pos) {
-            this._elem.css(p, pos[p]);
-        }
-        
-        this._offsets = offsets;
-        // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left.
-        var pixellength = offmax - offmin;
-        var unitlength = max - min;
-        
-        // point to unit and unit to point conversions references to Plot DOM element top left corner.
-        this.p2u = function(p){
-            return (p - offmin) * unitlength / pixellength + min;
-        };
-        
-        this.u2p = function(u){
-            return (u - min) * pixellength / unitlength + offmin;
-        };
-                
-        if (this.name == 'xaxis' || this.name == 'x2axis'){
-            this.series_u2p = function(u){
-                return (u - min) * pixellength / unitlength;
-            };
-            this.series_p2u = function(p){
-                return p * unitlength / pixellength + min;
-            };
-        }
-        
-        else {
-            this.series_u2p = function(u){
-                return (u - max) * pixellength / unitlength;
-            };
-            this.series_p2u = function(p){
-                return p * unitlength / pixellength + max;
-            };
-        }
-        
-        if (this.show) {
-            if (this.name == 'xaxis' || this.name == 'x2axis') {
-                for (var i=0; i<ticks.length; i++) {
-                    var t = ticks[i];
-                    if (t.show && t.showLabel) {
-                        var shim;
-                        
-                        if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
-                            // will need to adjust auto positioning based on which axis this is.
-                            var temp = (this.name == 'xaxis') ? 1 : -1;
-                            switch (t.labelPosition) {
-                                case 'auto':
-                                    // position at end
-                                    if (temp * t.angle < 0) {
-                                        shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    }
-                                    // position at start
-                                    else {
-                                        shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'end':
-                                    shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                                case 'start':
-                                    shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    break;
-                                case 'middle':
-                                    shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                                default:
-                                    shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                            }
-                        }
-                        else {
-                            shim = -t.getWidth()/2;
-                        }
-                        var val = this.u2p(t.value) + shim + 'px';
-                        t._elem.css('left', val);
-                        t.pack();
-                    }
-                }
-                var w;
-                if (lshow) {
-                    w = this._label._elem.outerWidth(true);
-                    this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px');
-                    if (this.name == 'xaxis') {
-                        this._label._elem.css('bottom', '0px');
-                    }
-                    else {
-                        this._label._elem.css('top', '0px');
-                    }
-                    this._label.pack();
-                }
-                // now show the labels under the bars.
-                var b, l, r;
-                for (var i=0; i<this.barLabels.length; i++) {
-                    b = this._barLabels[i];
-                    if (b.show) {
-                        w = b.getWidth();
-                        l = this._ticks[i].getLeft() + this._ticks[i].getWidth();
-                        r = this._ticks[i+1].getLeft();
-                        b._elem.css('left', (r+l-w)/2+'px');
-                        b._elem.css('top', this._ticks[i]._elem.css('top'));
-                        b.pack();
-                    }
-                }
-            }
-            else {
-                for (var i=0; i<ticks.length; i++) {
-                    var t = ticks[i];
-                    if (t.show && t.showLabel) {                        
-                        var shim;
-                        if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
-                            // will need to adjust auto positioning based on which axis this is.
-                            var temp = (this.name == 'yaxis') ? 1 : -1;
-                            switch (t.labelPosition) {
-                                case 'auto':
-                                    // position at end
-                                case 'end':
-                                    if (temp * t.angle < 0) {
-                                        shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
-                                    }
-                                    else {
-                                        shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'start':
-                                    if (t.angle > 0) {
-                                        shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
-                                    }
-                                    else {
-                                        shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'middle':
-                                    shim = -t.getHeight()/2;
-                                    break;
-                                default:
-                                    shim = -t.getHeight()/2;
-                                    break;
-                            }
-                        }
-                        else {
-                            shim = -t.getHeight()/2;
-                        }
-                        
-                        var val = this.u2p(t.value) + shim + 'px';
-                        t._elem.css('top', val);
-                        t.pack();
-                    }
-                }
-                if (lshow) {
-                    var h = this._label._elem.outerHeight(true);
-                    this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px');
-                    if (this.name == 'yaxis') {
-                        this._label._elem.css('left', '0px');
-                    }
-                    else {
-                        this._label._elem.css('right', '0px');
-                    }   
-                    this._label.pack();
-                }
-            }
-        }
-    };
-})(jQuery);
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoAxisRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoAxisRenderer.min.js
deleted file mode 100644
index 0505a15..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoAxisRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.MekkoAxisRenderer=function(){};a.jqplot.MekkoAxisRenderer.prototype.init=function(c){this.tickMode;this.barLabelRenderer=a.jqplot.AxisLabelRenderer;this.barLabels=this.barLabels||[];this.barLabelOptions={};this.tickOptions=a.extend(true,{showGridline:false},this.tickOptions);this._barLabels=[];a.extend(true,this,c);if(this.name=="yaxis"){this.tickOptions.formatString=this.tickOptions.formatString||"%d%"}var b=this._dataBounds;b.min=0;if(this.name=="yaxis"||this.name=="y2axis"){b.max=100;this.tickMode="even"}else{if(this.name=="xaxis"){this.tickMode=(this.tickMode==null)?"bar":this.tickMode;for(var d=0;d<this._series.length;d++){b.max+=this._series[d]._sumy}}else{if(this.name=="x2axis"){this.tickMode=(this.tickMode==null)?"even":this.tickMode;for(var d=0;d<this._series.length;d++){b.max+=this._series[d]._sumy}}}}};a.jqplot.MekkoAxisRenderer.prototype.draw=function(b,j){if(this.show){this.renderer.createTicks.call(this);var h=0;var c;var g=document.createElement("div");this._elem=a(g);this._elem.addClass("jqplot-axis jqplot-"+this.name);this._elem.css("position","absolute");g=null;if(this.name=="xaxis"||this.name=="x2axis"){this._elem.width(this._plotDimensions.width)}else{this._elem.height(this._plotDimensions.height)}this.labelOptions.axis=this.name;this._label=new this.labelRenderer(this.labelOptions);if(this._label.show){this._elem.append(this._label.draw(b))}var f,e,g;if(this.showTicks){f=this._ticks;for(var d=0;d<f.length;d++){e=f[d];if(e.showLabel&&(!e.isMinorTick||this.showMinorTicks)){this._elem.append(e.draw(b))}}}for(d=0;d<this.barLabels.length;d++){this.barLabelOptions.axis=this.name;this.barLabelOptions.label=this.barLabels[d];this._barLabels.push(new this.barLabelRenderer(this.barLabelOptions));if(this.tickMode!="bar"){this._barLabels[d].show=false}if(this._barLabels[d].show){var g=this._barLabels[d].draw(b,j);g.removeClass("jqplot-"+this.name+"-label");g.addClass("jqplot-"+this.name+"-tick");g.addClass("jqplot-mekko-barLabel");g.appendTo(this._elem);g=null}}}return this._elem};a.jqplot.MekkoAxisRenderer.prototype.reset=function(){this.min=this._min;this.max=this._max;this.tickInterval=this._tickInterval;this.numberTicks=this._numberTicks};a.jqplot.MekkoAxisRenderer.prototype.set=function(){var k=0;var d;var c=0;var j=0;var b=(this._label==null)?false:this._label.show;if(this.show&&this.showTicks){var g=this._ticks;for(var f=0;f<g.length;f++){var e=g[f];if(e.showLabel&&(!e.isMinorTick||this.showMinorTicks)){if(this.name=="xaxis"||this.name=="x2axis"){d=e._elem.outerHeight(true)}else{d=e._elem.outerWidth(true)}if(d>k){k=d}}}if(b){c=this._label._elem.outerWidth(true);j=this._label._elem.outerHeight(true)}if(this.name=="xaxis"){k=k+j;this._elem.css({height:k+"px",left:"0px",bottom:"0px"})}else{if(this.name=="x2axis"){k=k+j;this._elem.css({height:k+"px",left:"0px",top:"0px"})}else{if(this.name=="yaxis"){k=k+c;this._elem.css({width:k+"px",left:"0px",top:"0px"});if(b&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",c+"px")}}else{k=k+c;this._elem.css({width:k+"px",right:"0px",top:"0px"});if(b&&this._label.constructor==a.jqplot.AxisLabelRenderer){this._label._elem.css("width",c+"px")}}}}}};a.jqplot.MekkoAxisRenderer.prototype.createTicks=function(){var z=this._ticks;var w=this.ticks;var B=this.name;var y=this._dataBounds;var p,x;var n,r;var d,c;var h,b,s,q;if(w.length){for(s=0;s<w.length;s++){var e=w[s];var h=new this.tickRenderer(this.tickOptions);if(e.constructor==Array){h.value=e[0];h.label=e[1];if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(e[0],this.name);this._ticks.push(h)}else{h.value=e;if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(e,this.name);this._ticks.push(h)}}this.numberTicks=w.length;this.min=this._ticks[0].value;this.max=this._ticks[this.numberTicks-1].value;this.tickInterval=(this.max-this.min)/(this.numberTicks-1)}else{if(B=="xaxis"||B=="x2axis"){p=this._plotDimensions.width}else{p=this._plotDimensions.height}if(this.min!=null&&this.max!=null&&this.numberTicks!=null){this.tickInterval=null}n=(this.min!=null)?this.min:y.min;r=(this.max!=null)?this.max:y.max;if(n==r){var g=0.05;if(n>0){g=Math.max(Math.log(n)/Math.LN10,0.05)}n-=g;r+=g}var k=r-n;var m,o;var v,l,u;var f=[3,5,6,11,21];if(this.name=="yaxis"||this.name=="y2axis"){this.min=0;this.max=100;if(!this.numberTicks){if(this.tickInterval){this.numberTicks=3+Math.ceil(k/this.tickInterval)}else{v=2+Math.ceil((p-(this.tickSpacing-1))/this.tickSpacing);for(s=0;s<f.length;s++){u=v/f[s];if(u==1){this.numberTicks=f[s];break}else{if(u>1){l=u;continue}else{if(u<1){if(Math.abs(l-1)<Math.abs(u-1)){this.numberTicks=f[s-1];break}else{this.numberTicks=f[s];break}}else{if(s==f.length-1){this.numberTicks=f[s]}}}}}this.tickInterval=k/(this.numberTicks-1)}}else{this.tickInterval=k/(this.numberTicks-1)}for(var s=0;s<this.numberTicks;s++){b=this.min+s*this.tickInterval;h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(b,this.name);this._ticks.push(h)}}else{if(this.tickMode=="bar"){this.min=0;this.numberTicks=this._series.length+1;h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(0,this.name);this._ticks.push(h);v=0;for(s=1;s<this.numberTicks;s++){v+=this._series[s-1]._sumy;h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(v,this.name);this._ticks.push(h)}this.max=this.max||v;if(this.max>v){h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(this.max,this.name);this._ticks.push(h)}}else{if(this.tickMode=="even"){this.min=0;this.max=this.max||y.max;var A=2+Math.ceil((p-(this.tickSpacing-1))/this.tickSpacing);k=this.max-this.min;this.numberTicks=A;this.tickInterval=k/(this.numberTicks-1);for(s=0;s<this.numberTicks;s++){b=this.min+s*this.tickInterval;h=new this.tickRenderer(this.tickOptions);if(!this.showTicks){h.showLabel=false;h.showMark=false}else{if(!this.showTickMarks){h.showMark=false}}h.setTick(b,this.name);this._ticks.push(h)}}}}}};a.jqplot.MekkoAxisRenderer.prototype.pack=function(e,d){var C=this._ticks;var x=this.max;var v=this.min;var m=d.max;var j=d.min;var o=(this._label==null)?false:this._label.show;for(var s in e){this._elem.css(s,e[s])}this._offsets=d;var f=m-j;var g=x-v;this.p2u=function(b){return(b-j)*g/f+v};this.u2p=function(b){return(b-v)*f/g+j};if(this.name=="xaxis"||this.name=="x2axis"){this.series_u2p=function(b){return(b-v)*f/g};this.series_p2u=function(b){return b*g/f+v}}else{this.series_u2p=function(b){return(b-x)*f/g};this.series_p2u=function(b){return b*g/f+x}}if(this.show){if(this.name=="xaxis"||this.name=="x2axis"){for(var y=0;y<C.length;y++){var n=C[y];if(n.show&&n.showLabel){var c;if(n.constructor==a.jqplot.CanvasAxisTickRenderer&&n.angle){var A=(this.name=="xaxis")?1:-1;switch(n.labelPosition){case"auto":if(A*n.angle<0){c=-n.getWidth()+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2}else{c=-n._textRenderer.height*Math.sin(n._textRenderer.angle)/2}break;case"end":c=-n.getWidth()+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2;break;case"start":c=-n._textRenderer.height*Math.sin(n._textRenderer.angle)/2;break;case"middle":c=-n.getWidth()/2+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2;break;default:c=-n.getWidth()/2+n._textRenderer.height*Math.sin(-n._textRenderer.angle)/2;break}}else{c=-n.getWidth()/2}var D=this.u2p(n.value)+c+"px";n._elem.css("left",D);n.pack()}}var k;if(o){k=this._label._elem.outerWidth(true);this._label._elem.css("left",j+f/2-k/2+"px");if(this.name=="xaxis"){this._label._elem.css("bottom","0px")}else{this._label._elem.css("top","0px")}this._label.pack()}var B,u,q;for(var y=0;y<this.barLabels.length;y++){B=this._barLabels[y];if(B.show){k=B.getWidth();u=this._ticks[y].getLeft()+this._ticks[y].getWidth();q=this._ticks[y+1].getLeft();B._elem.css("left",(q+u-k)/2+"px");B._elem.css("top",this._ticks[y]._elem.css("top"));B.pack()}}}else{for(var y=0;y<C.length;y++){var n=C[y];if(n.show&&n.showLabel){var c;if(n.constructor==a.jqplot.CanvasAxisTickRenderer&&n.angle){var A=(this.name=="yaxis")?1:-1;switch(n.labelPosition){case"auto":case"end":if(A*n.angle<0){c=-n._textRenderer.height*Math.cos(-n._textRenderer.angle)/2}else{c=-n.getHeight()+n._textRenderer.height*Math.cos(n._textRenderer.angle)/2}break;case"start":if(n.angle>0){c=-n._textRenderer.height*Math.cos(-n._textRenderer.angle)/2}else{c=-n.getHeight()+n._textRenderer.height*Math.cos(n._textRenderer.angle)/2}break;case"middle":c=-n.getHeight()/2;break;default:c=-n.getHeight()/2;break}}else{c=-n.getHeight()/2}var D=this.u2p(n.value)+c+"px";n._elem.css("top",D);n.pack()}}if(o){var z=this._label._elem.outerHeight(true);this._label._elem.css("top",m-f/2-z/2+"px");if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{this._label._elem.css("right","0px")}this._label.pack()}}}}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoRenderer.js
deleted file mode 100644
index b02dd1a..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoRenderer.js
+++ /dev/null
@@ -1,436 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-     * Class: $.jqplot.MekkoRenderer
-     * Draws a Mekko style chart which shows 3 dimensional data on a 2 dimensional graph.
-     * the <$.jqplot.MekkoAxisRenderer> should be used with mekko charts.  The mekko renderer
-     * overrides the default legend renderer with it's own $.jqplot.MekkoLegendRenderer
-     * which allows more flexibility to specify number of rows and columns in the legend.
-     * 
-     * Data is specified per bar in the chart.  You can specify data as an array of y values, or as 
-     * an array of [label, value] pairs.  Note that labels are used only on the first series.  
-     * Labels on subsequent series are ignored:
-     * 
-     * > bar1 = [['shirts', 8],['hats', 14],['shoes', 6],['gloves', 16],['dolls', 12]];
-     * > bar2 = [15,6,9,13,6];
-     * > bar3 = [['grumpy',4],['sneezy',2],['happy',7],['sleepy',9],['doc',7]];
-     * 
-     * If you want to place labels for each bar under the axis, you use the barLabels option on 
-     * the axes.  The bar labels can be styled with the ".jqplot-mekko-barLabel" css class.
-     * 
-     * > barLabels = ['Mickey Mouse', 'Donald Duck', 'Goofy'];
-     * > axes:{xaxis:{barLabels:barLabels}}
-     * 
-     */
-    
-    
-    $.jqplot.MekkoRenderer = function(){
-        this.shapeRenderer = new $.jqplot.ShapeRenderer();
-        // prop: borderColor
-        // color of the borders between areas on the chart
-        this.borderColor = null;
-        // prop: showBorders
-        // True to draw borders lines between areas on the chart.
-        // False will draw borders lines with the same color as the area.
-        this.showBorders = true;
-    };
-    
-    // called with scope of series.
-    $.jqplot.MekkoRenderer.prototype.init = function(options, plot) {
-        this.fill = false;
-        this.fillRect = true;
-        this.strokeRect = true;
-        this.shadow = false;
-        // width of bar on x axis.
-        this._xwidth = 0;
-        this._xstart = 0;
-        $.extend(true, this.renderer, options);
-        // set the shape renderer options
-        var opts = {lineJoin:'miter', lineCap:'butt', isarc:false, fillRect:this.fillRect, strokeRect:this.strokeRect};
-        this.renderer.shapeRenderer.init(opts);
-        plot.axes.x2axis._series.push(this);
-        this._type = 'mekko';
-    };
-    
-    // Method: setGridData
-    // converts the user data values to grid coordinates and stores them
-    // in the gridData array.  Will convert user data into appropriate
-    // rectangles.
-    // Called with scope of a series.
-    $.jqplot.MekkoRenderer.prototype.setGridData = function(plot) {
-        // recalculate the grid data
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var data = this._plotData;
-        this.gridData = [];
-        // figure out width on x axis.
-        // this._xwidth = this._sumy / plot._sumy * this.canvas.getWidth();
-        this._xwidth = xp(this._sumy) - xp(0);
-        if (this.index>0) {
-            this._xstart = plot.series[this.index-1]._xstart + plot.series[this.index-1]._xwidth;
-        }
-        var totheight = this.canvas.getHeight();
-        var sumy = 0;
-        var cury;
-        var curheight;
-        for (var i=0; i<data.length; i++) {
-            if (data[i] != null) {
-                sumy += data[i][1];
-                cury = totheight - (sumy / this._sumy * totheight);
-                curheight = data[i][1] / this._sumy * totheight;
-                this.gridData.push([this._xstart, cury, this._xwidth, curheight]);
-            }
-        }
-    };
-    
-    // Method: makeGridData
-    // converts any arbitrary data values to grid coordinates and
-    // returns them.  This method exists so that plugins can use a series'
-    // linerenderer to generate grid data points without overwriting the
-    // grid data associated with that series.
-    // Called with scope of a series.
-    $.jqplot.MekkoRenderer.prototype.makeGridData = function(data, plot) {
-        // recalculate the grid data
-        // figure out width on x axis.
-        var xp = this._xaxis.series_u2p;
-        var totheight = this.canvas.getHeight();
-        var sumy = 0;
-        var cury;
-        var curheight;
-        var gd = [];
-        for (var i=0; i<data.length; i++) {
-            if (data[i] != null) {
-                sumy += data[i][1];
-                cury = totheight - (sumy / this._sumy * totheight);
-                curheight = data[i][1] / this._sumy * totheight;
-                gd.push([this._xstart, cury, this._xwidth, curheight]);
-            }
-        }
-        return gd;
-    };
-    
-
-    // called within scope of series.
-    $.jqplot.MekkoRenderer.prototype.draw = function(ctx, gd, options) {
-        var i;
-        var opts = (options != undefined) ? options : {};
-        var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
-        var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors);
-        ctx.save();
-        if (gd.length) {
-            if (showLine) {
-                for (i=0; i<gd.length; i++){
-                    opts.fillStyle = colorGenerator.next();
-                    if (this.renderer.showBorders) {
-                        opts.strokeStyle = this.renderer.borderColor;
-                    }
-                    else {
-                        opts.strokeStyle = opts.fillStyle;
-                    }
-                    this.renderer.shapeRenderer.draw(ctx, gd[i], opts);
-                }
-            }
-        }
-        
-        ctx.restore();
-    };  
-    
-    $.jqplot.MekkoRenderer.prototype.drawShadow = function(ctx, gd, options) {
-        // This is a no-op, no shadows on mekko charts.
-    };
-    
-    /**
-     * Class: $.jqplot.MekkoLegendRenderer
-     * Legend renderer used by mekko charts with options for 
-     * controlling number or rows and columns as well as placement
-     * outside of plot area.
-     * 
-     */
-    $.jqplot.MekkoLegendRenderer = function(){
-        //
-    };
-    
-    $.jqplot.MekkoLegendRenderer.prototype.init = function(options) {
-        // prop: numberRows
-        // Maximum number of rows in the legend.  0 or null for unlimited.
-        this.numberRows = null;
-        // prop: numberColumns
-        // Maximum number of columns in the legend.  0 or null for unlimited.
-        this.numberColumns = null;
-        // this will override the placement option on the Legend object
-        this.placement = "outside";
-        $.extend(true, this, options);
-    };
-    
-    // called with scope of legend
-    $.jqplot.MekkoLegendRenderer.prototype.draw = function() {
-        var legend = this;
-        if (this.show) {
-            var series = this._series;
-            var ss = 'position:absolute;';
-            ss += (this.background) ? 'background:'+this.background+';' : '';
-            ss += (this.border) ? 'border:'+this.border+';' : '';
-            ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
-            ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
-            ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
-            this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
-            // Mekko charts  legends don't go by number of series, but by number of data points
-            // in the series.  Refactor things here for that.
-            
-            var pad = false, 
-                reverse = true,    // mekko charts are always stacked, so reverse
-                nr, nc;
-            var s = series[0];
-            var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors);
-            
-            if (s.show) {
-                var pd = s.data;
-                if (this.numberRows) {
-                    nr = this.numberRows;
-                    if (!this.numberColumns){
-                        nc = Math.ceil(pd.length/nr);
-                    }
-                    else{
-                        nc = this.numberColumns;
-                    }
-                }
-                else if (this.numberColumns) {
-                    nc = this.numberColumns;
-                    nr = Math.ceil(pd.length/this.numberColumns);
-                }
-                else {
-                    nr = pd.length;
-                    nc = 1;
-                }
-                
-                var i, j, tr, td1, td2, lt, rs, color;
-                var idx = 0;    
-                
-                for (i=0; i<nr; i++) {
-                    if (reverse){
-                        tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem);
-                    }
-                    else{
-                        tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem);
-                    }
-                    for (j=0; j<nc; j++) {
-                        if (idx < pd.length) {
-                            lt = this.labels[idx] || pd[idx][0].toString();
-                            color = colorGenerator.next();
-                            if (!reverse){
-                                if (i>0){
-                                    pad = true;
-                                }
-                                else{
-                                    pad = false;
-                                }
-                            }
-                            else{
-                                if (i == nr -1){
-                                    pad = false;
-                                }
-                                else{
-                                    pad = true;
-                                }
-                            }
-                            rs = (pad) ? this.rowSpacing : '0';
-                
-                            td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
-                                '<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+
-                                '</div></td>');
-                            td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
-                            if (this.escapeHtml){
-                                td2.text(lt);
-                            }
-                            else {
-                                td2.html(lt);
-                            }
-                            if (reverse) {
-                                td2.prependTo(tr);
-                                td1.prependTo(tr);
-                            }
-                            else {
-                                td1.appendTo(tr);
-                                td2.appendTo(tr);
-                            }
-                            pad = true;
-                        }
-                        idx++;
-                    }   
-                }
-
-                tr = null;
-                td1 = null;
-                td2 = null;
-            }
-        }
-        return this._elem;
-    };
-    
-    $.jqplot.MekkoLegendRenderer.prototype.pack = function(offsets) {
-        if (this.show) {
-            // fake a grid for positioning
-            var grid = {_top:offsets.top, _left:offsets.left, _right:offsets.right, _bottom:this._plotDimensions.height - offsets.bottom};        
-            if (this.placement == 'insideGrid') {
-                switch (this.location) {
-                    case 'nw':
-                        var a = grid._left + this.xoffset;
-                        var b = grid._top + this.yoffset;
-                        this._elem.css('left', a);
-                        this._elem.css('top', b);
-                        break;
-                    case 'n':
-                        var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-                        var b = grid._top + this.yoffset;
-                        this._elem.css('left', a);
-                        this._elem.css('top', b);
-                        break;
-                    case 'ne':
-                        var a = offsets.right + this.xoffset;
-                        var b = grid._top + this.yoffset;
-                        this._elem.css({right:a, top:b});
-                        break;
-                    case 'e':
-                        var a = offsets.right + this.xoffset;
-                        var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-                        this._elem.css({right:a, top:b});
-                        break;
-                    case 'se':
-                        var a = offsets.right + this.xoffset;
-                        var b = offsets.bottom + this.yoffset;
-                        this._elem.css({right:a, bottom:b});
-                        break;
-                    case 's':
-                        var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-                        var b = offsets.bottom + this.yoffset;
-                        this._elem.css({left:a, bottom:b});
-                        break;
-                    case 'sw':
-                        var a = grid._left + this.xoffset;
-                        var b = offsets.bottom + this.yoffset;
-                        this._elem.css({left:a, bottom:b});
-                        break;
-                    case 'w':
-                        var a = grid._left + this.xoffset;
-                        var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-                        this._elem.css({left:a, top:b});
-                        break;
-                    default:  // same as 'se'
-                        var a = grid._right - this.xoffset;
-                        var b = grid._bottom + this.yoffset;
-                        this._elem.css({right:a, bottom:b});
-                        break;
-                }
-                
-            }
-            else {
-                switch (this.location) {
-                    case 'nw':
-                        var a = this._plotDimensions.width - grid._left + this.xoffset;
-                        var b = grid._top + this.yoffset;
-                        this._elem.css('right', a);
-                        this._elem.css('top', b);
-                        break;
-                    case 'n':
-                        var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-                        var b = this._plotDimensions.height - grid._top + this.yoffset;
-                        this._elem.css('left', a);
-                        this._elem.css('bottom', b);
-                        break;
-                    case 'ne':
-                        var a = this._plotDimensions.width - offsets.right + this.xoffset;
-                        var b = grid._top + this.yoffset;
-                        this._elem.css({left:a, top:b});
-                        break;
-                    case 'e':
-                        var a = this._plotDimensions.width - offsets.right + this.xoffset;
-                        var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-                        this._elem.css({left:a, top:b});
-                        break;
-                    case 'se':
-                        var a = this._plotDimensions.width - offsets.right + this.xoffset;
-                        var b = offsets.bottom + this.yoffset;
-                        this._elem.css({left:a, bottom:b});
-                        break;
-                    case 's':
-                        var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
-                        var b = this._plotDimensions.height - offsets.bottom + this.yoffset;
-                        this._elem.css({left:a, top:b});
-                        break;
-                    case 'sw':
-                        var a = this._plotDimensions.width - grid._left + this.xoffset;
-                        var b = offsets.bottom + this.yoffset;
-                        this._elem.css({right:a, bottom:b});
-                        break;
-                    case 'w':
-                        var a = this._plotDimensions.width - grid._left + this.xoffset;
-                        var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
-                        this._elem.css({right:a, top:b});
-                        break;
-                    default:  // same as 'se'
-                        var a = grid._right - this.xoffset;
-                        var b = grid._bottom + this.yoffset;
-                        this._elem.css({right:a, bottom:b});
-                        break;
-                }
-            }
-        } 
-    };
-    
-    // setup default renderers for axes and legend so user doesn't have to
-    // called with scope of plot
-    function preInit(target, data, options) {
-        options = options || {};
-        options.axesDefaults = options.axesDefaults || {};
-        options.legend = options.legend || {};
-        options.seriesDefaults = options.seriesDefaults || {};
-        var setopts = false;
-        if (options.seriesDefaults.renderer == $.jqplot.MekkoRenderer) {
-            setopts = true;
-        }
-        else if (options.series) {
-            for (var i=0; i < options.series.length; i++) {
-                if (options.series[i].renderer == $.jqplot.MekkoRenderer) {
-                    setopts = true;
-                }
-            }
-        }
-        
-        if (setopts) {
-            options.axesDefaults.renderer = $.jqplot.MekkoAxisRenderer;
-            options.legend.renderer = $.jqplot.MekkoLegendRenderer;
-            options.legend.preDraw = true;
-        }
-    }
-    
-    $.jqplot.preInitHooks.push(preInit);
-    
-})(jQuery);    
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoRenderer.min.js
deleted file mode 100644
index f88c00a..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.mekkoRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(b){b.jqplot.MekkoRenderer=function(){this.shapeRenderer=new b.jqplot.ShapeRenderer();this.borderColor=null;this.showBorders=true};b.jqplot.MekkoRenderer.prototype.init=function(c,e){this.fill=false;this.fillRect=true;this.strokeRect=true;this.shadow=false;this._xwidth=0;this._xstart=0;b.extend(true,this.renderer,c);var d={lineJoin:"miter",lineCap:"butt",isarc:false,fillRect:this.fillRect,strokeRect:this.strokeRect};this.renderer.shapeRenderer.init(d);e.axes.x2axis._series.push(this);this._type="mekko"};b.jqplot.MekkoRenderer.prototype.setGridData=function(h){var e=this._xaxis.series_u2p;var c=this._yaxis.series_u2p;var g=this._plotData;this.gridData=[];this._xwidth=e(this._sumy)-e(0);if(this.index>0){this._xstart=h.series[this.index-1]._xstart+h.series[this.index-1]._xwidth}var l=this.canvas.getHeight();var d=0;var k;var j;for(var f=0;f<g.length;f++){if(g[f]!=null){d+=g[f][1];k=l-(d/this._sumy*l);j=g[f][1]/this._sumy*l;this.gridData.push([this._xstart,k,this._xwidth,j])}}};b.jqplot.MekkoRenderer.prototype.makeGridData=function(f,g){var d=this._xaxis.series_u2p;var l=this.canvas.getHeight();var c=0;var j;var h;var k=[];for(var e=0;e<f.length;e++){if(f[e]!=null){c+=f[e][1];j=l-(c/this._sumy*l);h=f[e][1]/this._sumy*l;k.push([this._xstart,j,this._xwidth,h])}}return k};b.jqplot.MekkoRenderer.prototype.draw=function(c,h,d){var e;var g=(d!=undefined)?d:{};var f=(g.showLine!=undefined)?g.showLine:this.showLine;var j=new b.jqplot.ColorGenerator(this.seriesColors);c.save();if(h.length){if(f){for(e=0;e<h.length;e++){g.fillStyle=j.next();if(this.renderer.showBorders){g.strokeStyle=this.renderer.borderColor}else{g.strokeStyle=g.fillStyle}this.renderer.shapeRenderer.draw(c,h[e],g)}}}c.restore()};b.jqplot.MekkoRenderer.prototype.drawShadow=function(c,e,d){};b.jqplot.MekkoLegendRenderer=function(){};b.jqplot.MekkoLegendRenderer.prototype.init=function(c){this.numberRows=null;this.numberColumns=null;this.placement="outside";b.extend(true,this,c)};b.jqplot.MekkoLegendRenderer.prototype.draw=function(){var f=this;if(this.show){var o=this._series;var r="position:absolute;";r+=(this.background)?"background:"+this.background+";":"";r+=(this.border)?"border:"+this.border+";":"";r+=(this.fontSize)?"font-size:"+this.fontSize+";":"";r+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";r+=(this.textColor)?"color:"+this.textColor+";":"";this._elem=b('<table class="jqplot-table-legend" style="'+r+'"></table>');var w=false,n=true,c,l;var p=o[0];var d=new b.jqplot.ColorGenerator(p.seriesColors);if(p.show){var x=p.data;if(this.numberRows){c=this.numberRows;if(!this.numberColumns){l=Math.ceil(x.length/c)}else{l=this.numberColumns}}else{if(this.numberColumns){l=this.numberColumns;c=Math.ceil(x.length/this.numberColumns)}else{c=x.length;l=1}}var v,u,e,h,g,k,m,t;var q=0;for(v=0;v<c;v++){if(n){e=b('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{e=b('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(u=0;u<l;u++){if(q<x.length){k=this.labels[q]||x[q][0].toString();t=d.next();if(!n){if(v>0){w=true}else{w=false}}else{if(v==c-1){w=false}else{w=true}}m=(w)?this.rowSpacing:"0";h=b('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+m+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+t+';"></div></div></td>');g=b('<td class="jqplot-table-legend" style="padding-top:'+m+';"></td>');if(this.escapeHtml){g.text(k)}else{g.html(k)}if(n){g.prependTo(e);h.prependTo(e)}else{h.appendTo(e);g.appendTo(e)}w=true}q++}}e=null;h=null;g=null}}return this._elem};b.jqplot.MekkoLegendRenderer.prototype.pack=function(f){if(this.show){var e={_top:f.top,_left:f.left,_right:f.right,_bottom:this._plotDimensions.height-f.bottom};if(this.placement=="insideGrid"){switch(this.location){case"nw":var d=e._left+this.xoffset;var c=e._top+this.yoffset;this._elem.css("left",d);this._elem.css("top",c);break;case"n":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=e._top+this.yoffset;this._elem.css("left",d);this._elem.css("top",c);break;case"ne":var d=f.right+this.xoffset;var c=e._top+this.yoffset;this._elem.css({right:d,top:c});break;case"e":var d=f.right+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({right:d,top:c});break;case"se":var d=f.right+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({right:d,bottom:c});break;case"s":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"sw":var d=e._left+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"w":var d=e._left+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({left:d,top:c});break;default:var d=e._right-this.xoffset;var c=e._bottom+this.yoffset;this._elem.css({right:d,bottom:c});break}}else{switch(this.location){case"nw":var d=this._plotDimensions.width-e._left+this.xoffset;var c=e._top+this.yoffset;this._elem.css("right",d);this._elem.css("top",c);break;case"n":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=this._plotDimensions.height-e._top+this.yoffset;this._elem.css("left",d);this._elem.css("bottom",c);break;case"ne":var d=this._plotDimensions.width-f.right+this.xoffset;var c=e._top+this.yoffset;this._elem.css({left:d,top:c});break;case"e":var d=this._plotDimensions.width-f.right+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({left:d,top:c});break;case"se":var d=this._plotDimensions.width-f.right+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"s":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=this._plotDimensions.height-f.bottom+this.yoffset;this._elem.css({left:d,top:c});break;case"sw":var d=this._plotDimensions.width-e._left+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({right:d,bottom:c});break;case"w":var d=this._plotDimensions.width-e._left+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({right:d,top:c});break;default:var d=e._right-this.xoffset;var c=e._bottom+this.yoffset;this._elem.css({right:d,bottom:c});break}}}};function a(g,f,d){d=d||{};d.axesDefaults=d.axesDefaults||{};d.legend=d.legend||{};d.seriesDefaults=d.seriesDefaults||{};var c=false;if(d.seriesDefaults.renderer==b.jqplot.MekkoRenderer){c=true}else{if(d.series){for(var e=0;e<d.series.length;e++){if(d.series[e].renderer==b.jqplot.MekkoRenderer){c=true}}}}if(c){d.axesDefaults.renderer=b.jqplot.MekkoAxisRenderer;d.legend.renderer=b.jqplot.MekkoLegendRenderer;d.legend.preDraw=true}}b.jqplot.preInitHooks.push(a)})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.meterGaugeRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.meterGaugeRenderer.js
deleted file mode 100644
index fcaf4ce..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.meterGaugeRenderer.js
+++ /dev/null
@@ -1,1029 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-     * Class: $.jqplot.MeterGaugeRenderer
-     * Plugin renderer to draw a meter gauge chart.
-     * 
-     * Data consists of a single series with 1 data point to position the gauge needle.
-     * 
-     * To use this renderer, you need to include the 
-     * meter gauge renderer plugin, for example:
-     * 
-     * > <script type="text/javascript" src="plugins/jqplot.meterGaugeRenderer.js"></script>
-     * 
-     * Properties described here are passed into the $.jqplot function
-     * as options on the series renderer.  For example:
-     * 
-     * > plot0 = $.jqplot('chart0',[[18]],{
-     * >     title: 'Network Speed',
-     * >     seriesDefaults: {
-     * >         renderer: $.jqplot.MeterGaugeRenderer,
-     * >         rendererOptions: {
-     * >             label: 'MB/s'
-     * >         }
-     * >     }
-     * > });
-     * 
-     * A meterGauge plot does not support events.
-     */
-    $.jqplot.MeterGaugeRenderer = function(){
-        $.jqplot.LineRenderer.call(this);
-    };
-    
-    $.jqplot.MeterGaugeRenderer.prototype = new $.jqplot.LineRenderer();
-    $.jqplot.MeterGaugeRenderer.prototype.constructor = $.jqplot.MeterGaugeRenderer;
-    
-    // called with scope of a series
-    $.jqplot.MeterGaugeRenderer.prototype.init = function(options) {
-        // Group: Properties
-        //
-        // prop: diameter
-        // Outer diameter of the meterGauge, auto computed by default
-        this.diameter = null;
-        // prop: padding
-        // padding between the meterGauge and plot edges, auto
-        // calculated by default.
-        this.padding = null;
-        // prop: shadowOffset
-        // offset of the shadow from the gauge ring and offset of 
-        // each succesive stroke of the shadow from the last.
-        this.shadowOffset = 2;
-        // prop: shadowAlpha
-        // transparency of the shadow (0 = transparent, 1 = opaque)
-        this.shadowAlpha = 0.07;
-        // prop: shadowDepth
-        // number of strokes to apply to the shadow, 
-        // each stroke offset shadowOffset from the last.
-        this.shadowDepth = 4;
-        // prop: background
-        // background color of the inside of the gauge.
-        this.background = "#efefef";
-        // prop: ringColor
-        // color of the outer ring, hub, and needle of the gauge.
-        this.ringColor = "#BBC6D0";
-        // needle color not implemented yet.
-        this.needleColor = "#C3D3E5";
-        // prop: tickColor
-        // color of the tick marks around the gauge.
-        this.tickColor = "989898";
-        // prop: ringWidth
-        // width of the ring around the gauge.  Auto computed by default.
-        this.ringWidth = null;
-        // prop: min
-        // Minimum value on the gauge.  Auto computed by default
-        this.min;
-        // prop: max
-        // Maximum value on the gauge. Auto computed by default
-        this.max;
-        // prop: ticks
-        // Array of tick values. Auto computed by default.
-        this.ticks = [];
-        // prop: showTicks
-        // true to show ticks around gauge.
-        this.showTicks = true;
-        // prop: showTickLabels
-        // true to show tick labels next to ticks.
-        this.showTickLabels = true;
-        // prop: label
-        // A gauge label like 'kph' or 'Volts'
-        this.label = null;
-        // prop: labelHeightAdjust
-        // Number of Pixels to offset the label up (-) or down (+) from its default position.
-        this.labelHeightAdjust = 0;
-        // prop: labelPosition
-        // Where to position the label, either 'inside' or 'bottom'.
-        this.labelPosition = 'inside';
-        // prop: intervals
-        // Array of ranges to be drawn around the gauge.
-        // Array of form:
-        // > [value1, value2, ...]
-        // indicating the values for the first, second, ... intervals.
-        this.intervals = [];
-        // prop: intervalColors
-        // Array of colors to use for the intervals.
-        this.intervalColors = [ "#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"];
-        // prop: intervalInnerRadius
-        // Radius of the inner circle of the interval ring.
-        this.intervalInnerRadius =  null;
-        // prop: intervalOuterRadius
-        // Radius of the outer circle of the interval ring.
-        this.intervalOuterRadius = null;
-        this.tickRenderer = $.jqplot.MeterGaugeTickRenderer;
-        // ticks spaced every 1, 2, 2.5, 5, 10, 20, .1, .2, .25, .5, etc.
-        this.tickPositions = [1, 2, 2.5, 5, 10];
-        // prop: tickSpacing
-        // Degrees between ticks.  This is a target number, if 
-        // incompatible span and ticks are supplied, a suitable
-        // spacing close to this value will be computed.
-        this.tickSpacing = 30;
-        this.numberMinorTicks = null;
-        // prop: hubRadius
-        // Radius of the hub at the bottom center of gauge which the needle attaches to.
-        // Auto computed by default
-        this.hubRadius = null;
-        // prop: tickPadding
-        // padding of the tick marks to the outer ring and the tick labels to marks.
-        // Auto computed by default.
-        this.tickPadding = null;
-        // prop: needleThickness
-        // Maximum thickness the needle.  Auto computed by default.
-        this.needleThickness = null;
-        // prop: needlePad
-        // Padding between needle and inner edge of the ring when the needle is at the min or max gauge value.
-        this.needlePad = 6;
-        // prop: pegNeedle
-        // True will stop needle just below/above the  min/max values if data is below/above min/max,
-        // as if the meter is "pegged".
-        this.pegNeedle = true;
-        this._type = 'meterGauge';
-        
-        $.extend(true, this, options);
-        this.type = null;
-        this.numberTicks = null;
-        this.tickInterval = null;
-        // span, the sweep (in degrees) from min to max.  This gauge is 
-        // a semi-circle.
-        this.span = 180;
-        // get rid of this nonsense
-        // this.innerSpan = this.span;
-        if (this.type == 'circular') {
-            this.semiCircular = false;
-        }
-        else if (this.type != 'circular') {
-            this.semiCircular = true;
-        }
-        else {
-            this.semiCircular = (this.span <= 180) ? true : false;
-        }
-        this._tickPoints = [];
-        // reference to label element.
-        this._labelElem = null;
-        
-        // start the gauge at the beginning of the span
-        this.startAngle = (90 + (360 - this.span)/2) * Math.PI/180;
-        this.endAngle = (90 - (360 - this.span)/2) * Math.PI/180;
-        
-        this.setmin = !!(this.min == null);
-        this.setmax = !!(this.max == null);
-        
-        // if given intervals and is an array of values, create labels and colors.
-        if (this.intervals.length) {
-            if (this.intervals[0].length == null || this.intervals.length == 1) {
-                for (var i=0; i<this.intervals.length; i++) {
-                    this.intervals[i] = [this.intervals[i], this.intervals[i], this.intervalColors[i]];
-                }
-            }
-            else if (this.intervals[0].length == 2) {
-                for (i=0; i<this.intervals.length; i++) {
-                    this.intervals[i] = [this.intervals[i][0], this.intervals[i][1], this.intervalColors[i]];
-                }
-            }
-        }
-        
-        // compute min, max and ticks if not supplied:
-        if (this.ticks.length) {
-            if (this.ticks[0].length == null || this.ticks[0].length == 1) {
-                for (var i=0; i<this.ticks.length; i++) {
-                    this.ticks[i] = [this.ticks[i], this.ticks[i]];
-                }
-            }
-            this.min = (this.min == null) ? this.ticks[0][0] : this.min;
-            this.max = (this.max == null) ? this.ticks[this.ticks.length-1][0] : this.max;
-            this.setmin = false;
-            this.setmax = false;
-            this.numberTicks = this.ticks.length;
-            this.tickInterval = this.ticks[1][0] - this.ticks[0][0];
-            this.tickFactor = Math.floor(parseFloat((Math.log(this.tickInterval)/Math.log(10)).toFixed(11)));
-            // use the first interal to calculate minor ticks;
-            this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor);
-            if (!this.numberMinorTicks) {
-                this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1);
-            }
-            if (!this.numberMinorTicks) {
-                this.numberMinorTicks = 1;
-            }
-        }
-        
-        else if (this.intervals.length) {
-            this.min = (this.min == null) ? 0 : this.min;
-            this.setmin = false;
-            if (this.max == null) {
-                if (this.intervals[this.intervals.length-1][0] >= this.data[0][1]) {
-                    this.max = this.intervals[this.intervals.length-1][0];
-                    this.setmax = false;
-                }
-            }
-            else {
-                this.setmax = false;
-            }
-        }
-        
-        else {
-            // no ticks and no intervals supplied, put needle in middle
-            this.min = (this.min == null) ? 0 : this.min;
-            this.setmin = false;
-            if (this.max == null) {
-                this.max = this.data[0][1] * 1.25;
-                this.setmax = true;
-            }
-            else {
-                this.setmax = false;
-            }
-        }
-    };
-    
-    $.jqplot.MeterGaugeRenderer.prototype.setGridData = function(plot) {
-        // set gridData property.  This will hold angle in radians of each data point.
-        var stack = [];
-        var td = [];
-        var sa = this.startAngle;
-        for (var i=0; i<this.data.length; i++){
-            stack.push(this.data[i][1]);
-            td.push([this.data[i][0]]);
-            if (i>0) {
-                stack[i] += stack[i-1];
-            }
-        }
-        var fact = Math.PI*2/stack[stack.length - 1];
-        
-        for (var i=0; i<stack.length; i++) {
-            td[i][1] = stack[i] * fact;
-        }
-        this.gridData = td;
-    };
-    
-    $.jqplot.MeterGaugeRenderer.prototype.makeGridData = function(data, plot) {
-        var stack = [];
-        var td = [];
-        var sa = this.startAngle;
-        for (var i=0; i<data.length; i++){
-            stack.push(data[i][1]);
-            td.push([data[i][0]]);
-            if (i>0) {
-                stack[i] += stack[i-1];
-            }
-        }
-        var fact = Math.PI*2/stack[stack.length - 1];
-        
-        for (var i=0; i<stack.length; i++) {
-            td[i][1] = stack[i] * fact;
-        }
-        return td;
-    };
-
-        
-    function getnmt(pos, interval, fact) {
-        var temp;
-        for (var i=pos.length-1; i>=0; i--) {
-            temp = interval/(pos[i] * Math.pow(10, fact));
-            if (temp == 4 || temp == 5) {
-                return temp - 1;
-            }
-        }
-        return null;
-    }
-    
-    // called with scope of series
-    $.jqplot.MeterGaugeRenderer.prototype.draw = function (ctx, gd, options) {
-        var i;
-        var opts = (options != undefined) ? options : {};
-        // offset and direction of offset due to legend placement
-        var offx = 0;
-        var offy = 0;
-        var trans = 1;
-        if (options.legendInfo && options.legendInfo.placement == 'inside') {
-            var li = options.legendInfo;
-            switch (li.location) {
-                case 'nw':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'w':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'sw':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'ne':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'e':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'se':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'n':
-                    offy = li.height + li.yoffset;
-                    break;
-                case 's':
-                    offy = li.height + li.yoffset;
-                    trans = -1;
-                    break;
-                default:
-                    break;
-            }
-        }
-        
-        
-            
-        // pre-draw so can get it's dimensions.
-        if (this.label) {
-            this._labelElem = $('<div class="jqplot-meterGauge-label" style="position:absolute;">'+this.label+'</div>');
-            this.canvas._elem.after(this._labelElem);
-        }
-        
-        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
-        var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
-        var fill = (opts.fill != undefined) ? opts.fill : this.fill;
-        var cw = ctx.canvas.width;
-        var ch = ctx.canvas.height;
-        if (this.padding == null) {
-            this.padding = Math.round(Math.min(cw, ch)/30);
-        }
-        var w = cw - offx - 2 * this.padding;
-        var h = ch - offy - 2 * this.padding;
-        if (this.labelPosition == 'bottom' && this.label) {
-            h -= this._labelElem.outerHeight(true);
-        }
-        var mindim = Math.min(w,h);
-        var d = mindim;
-            
-        if (!this.diameter) {
-            if (this.semiCircular) {
-                if ( w >= 2*h) {
-                    if (!this.ringWidth) {
-                        this.ringWidth = 2*h/35;
-                    }
-                    this.needleThickness = this.needleThickness || 2+Math.pow(this.ringWidth, 0.8);
-                    this.innerPad = this.ringWidth/2 + this.needleThickness/2 + this.needlePad;
-                    this.diameter = 2 * (h - 2*this.innerPad);
-                }
-                else {
-                    if (!this.ringWidth) {
-                        this.ringWidth = w/35;
-                    }
-                    this.needleThickness = this.needleThickness || 2+Math.pow(this.ringWidth, 0.8);
-                    this.innerPad = this.ringWidth/2 + this.needleThickness/2 + this.needlePad;
-                    this.diameter = w - 2*this.innerPad - this.ringWidth - this.padding;
-                }
-                // center taking into account legend and over draw for gauge bottom below hub.
-                // this will be center of hub.
-                this._center = [(cw - trans * offx)/2 + trans * offx,  (ch + trans*offy - this.padding - this.ringWidth - this.innerPad)];
-            }
-            else {
-                if (!this.ringWidth) {
-                    this.ringWidth = d/35;
-                }
-                this.needleThickness = this.needleThickness || 2+Math.pow(this.ringWidth, 0.8);
-                this.innerPad = 0;
-                this.diameter = d - this.ringWidth;
-                // center in middle of canvas taking into account legend.
-                // will be center of hub.
-                this._center = [(cw-trans*offx)/2 + trans * offx, (ch-trans*offy)/2 + trans * offy];
-            }
-        }
-
-        
-        if (this._labelElem && this.labelPosition == 'bottom') {
-            this._center[1] -= this._labelElem.outerHeight(true);
-        }
-        
-        this._radius = this.diameter/2;
-        
-        this.tickSpacing = 6000/this.diameter;
-        
-        if (!this.hubRadius) {
-            this.hubRadius = this.diameter/18;
-        }
-        
-        this.shadowOffset = 0.5 + this.ringWidth/9;
-        this.shadowWidth = this.ringWidth*1;
-        
-        this.tickPadding = 3 + Math.pow(this.diameter/20, 0.7);
-        this.tickOuterRadius = this._radius - this.ringWidth/2 - this.tickPadding;
-        this.tickLength = (this.showTicks) ? this._radius/13 : 0;
-        
-        if (this.ticks.length == 0) {
-            // no ticks, lets make some.
-            var max = this.max,
-                min = this.min,
-                setmax = this.setmax,
-                setmin = this.setmin,
-                ti = (max - min) * this.tickSpacing / this.span;
-            var tf = Math.floor(parseFloat((Math.log(ti)/Math.log(10)).toFixed(11)));
-            var tp = (ti/Math.pow(10, tf));
-            (tp > 2 && tp <= 2.5) ? tp = 2.5 : tp = Math.ceil(tp);
-            var t = this.tickPositions;
-            var tpindex, nt;
-    
-            for (i=0; i<t.length; i++) {
-                if (tp == t[i] || i && t[i-1] < tp && tp < t[i]) { 
-                    ti = t[i]*Math.pow(10, tf);
-                    tpindex = i;
-                }
-            }
-        
-            for (i=0; i<t.length; i++) {
-                if (tp == t[i] || i && t[i-1] < tp && tp < t[i]) { 
-                    ti = t[i]*Math.pow(10, tf);
-                    nt = Math.ceil((max - min) / ti);
-                }
-            }
-        
-            // both max and min are free
-            if (setmax && setmin) {
-                var tmin = (min > 0) ? min - min % ti : min - min % ti - ti;
-                if (!this.forceZero) {
-                    var diff = Math.min(min - tmin, 0.8*ti);
-                    var ntp = Math.floor(diff/t[tpindex]);
-                    if (ntp > 1) {
-                        tmin = tmin + t[tpindex] * (ntp-1);
-                        if (parseInt(tmin, 10) != tmin && parseInt(tmin-t[tpindex], 10) == tmin-t[tpindex]) {
-                            tmin = tmin - t[tpindex];
-                        }
-                    }
-                }
-                if (min == tmin) {
-                    min -= ti;
-                }
-                else {
-                    // tmin should always be lower than dataMin
-                    if (min - tmin > 0.23*ti) {
-                        min = tmin;
-                    }
-                    else {
-                        min = tmin -ti;
-                        nt += 1;
-                    }
-                }
-                nt += 1;
-                var tmax = min + (nt - 1) * ti;
-                if (max >= tmax) { 
-                    tmax += ti;
-                    nt += 1;
-                }
-                // now tmax should always be mroe than dataMax
-                if (tmax - max < 0.23*ti) { 
-                    tmax += ti;
-                    nt += 1;
-                }
-                this.max = max = tmax;
-                this.min = min;    
-
-                this.tickInterval = ti;
-                this.numberTicks = nt;
-                var it;
-                for (i=0; i<nt; i++) {
-                    it = parseFloat((min+i*ti).toFixed(11));
-                    this.ticks.push([it, it]);
-                }
-                this.max = this.ticks[nt-1][1];
-            
-                this.tickFactor = tf;      
-                // determine number of minor ticks
-
-                this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor);     
-        
-                if (!this.numberMinorTicks) {
-                    this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1);
-                }
-            }
-            // max is free, min is fixed
-            else if (setmax) {
-                var tmax = min + (nt - 1) * ti;
-                if (max >= tmax) {
-                    max = tmax + ti;
-                    nt += 1;
-                }
-                else {
-                    max = tmax;
-                }
-
-                this.tickInterval = this.tickInterval || ti;
-                this.numberTicks = this.numberTicks || nt;
-                var it;
-                for (i=0; i<this.numberTicks; i++) {
-                    it = parseFloat((min+i*this.tickInterval).toFixed(11));
-                    this.ticks.push([it, it]);
-                }
-                this.max = this.ticks[this.numberTicks-1][1];
-            
-                this.tickFactor = tf;
-                // determine number of minor ticks
-                this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor);
-        
-                if (!this.numberMinorTicks) {
-                    this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1);
-                }
-            }
-            
-            // not setting max or min
-            if (!setmax && !setmin) {
-                var range = this.max - this.min;
-                tf = Math.floor(parseFloat((Math.log(range)/Math.log(10)).toFixed(11))) - 1;
-                var nticks = [5,6,4,7,3,8,9,10,2], res, numticks, nonSigDigits=0, sigRange;
-                // check to see how many zeros are at the end of the range
-                if (range > 1) {
-                    var rstr = String(range);
-                    if (rstr.search(/\./) == -1) {
-                         var pos = rstr.search(/0+$/);
-                         nonSigDigits = (pos > 0) ? rstr.length - pos - 1 : 0;
-                    }
-                }
-                sigRange = range/Math.pow(10, nonSigDigits);
-                for (i=0; i<nticks.length; i++) {
-                    res = sigRange/(nticks[i]-1);
-                    if (res == parseInt(res, 10)) {
-                        this.numberTicks = nticks[i];
-                        this.tickInterval = range/(this.numberTicks-1);
-                        this.tickFactor = tf+1;
-                        break;
-                    }
-                }
-                var it;
-                for (i=0; i<this.numberTicks; i++) {
-                    it = parseFloat((this.min+i*this.tickInterval).toFixed(11));
-                    this.ticks.push([it, it]);
-                }
-                // determine number of minor ticks
-                this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor);
-        
-                if (!this.numberMinorTicks) {
-                    this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1);
-                }
-                
-                if (!this.numberMinorTicks) {
-                    this.numberMinorTicks = 1;
-                    var nums = [4, 5, 3, 6, 2];
-                    for (i=0; i<5; i++) {
-                        var temp = this.tickInterval/nums[i];
-                        if (temp == parseInt(temp, 10)) {
-                            this.numberMinorTicks = nums[i]-1;
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-        
-
-        var r = this._radius,
-            sa = this.startAngle,
-            ea = this.endAngle,       
-            pi = Math.PI,
-            hpi = Math.PI/2;
-            
-        if (this.semiCircular) {
-            var overAngle = Math.atan(this.innerPad/r),
-                outersa = this.outerStartAngle = sa - overAngle,
-                outerea = this.outerEndAngle = ea + overAngle,
-                hubsa = this.hubStartAngle = sa - Math.atan(this.innerPad/this.hubRadius*2),
-                hubea = this.hubEndAngle = ea + Math.atan(this.innerPad/this.hubRadius*2);
-
-            ctx.save();            
-            
-            ctx.translate(this._center[0], this._center[1]);
-            ctx.lineJoin = "round";
-            ctx.lineCap = "round";
-            
-            // draw the innerbackground
-            ctx.save();
-            ctx.beginPath();  
-            ctx.fillStyle = this.background;
-            ctx.arc(0, 0, r, outersa, outerea, false);
-            ctx.closePath();
-            ctx.fill();
-            ctx.restore();
-            
-            // draw the shadow
-            // the outer ring.
-            var shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')';
-            ctx.save();
-            for (var i=0; i<this.shadowDepth; i++) {
-                ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
-                ctx.beginPath();  
-                ctx.strokeStyle = shadowColor;
-                ctx.lineWidth = this.shadowWidth;
-                ctx.arc(0 ,0, r, outersa, outerea, false);
-                ctx.closePath();
-                ctx.stroke();
-            }
-            ctx.restore();
-            
-            // the inner hub.
-            ctx.save();
-            var tempd = parseInt((this.shadowDepth+1)/2, 10);
-            for (var i=0; i<tempd; i++) {
-                ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
-                ctx.beginPath();  
-                ctx.fillStyle = shadowColor;
-                ctx.arc(0 ,0, this.hubRadius, hubsa, hubea, false);
-                ctx.closePath();
-                ctx.fill();
-            }
-            ctx.restore();
-            
-            // draw the outer ring.
-            ctx.save();
-            ctx.beginPath();  
-            ctx.strokeStyle = this.ringColor;
-            ctx.lineWidth = this.ringWidth;
-            ctx.arc(0 ,0, r, outersa, outerea, false);
-            ctx.closePath();
-            ctx.stroke();
-            ctx.restore();
-            
-            // draw the hub
-            
-            ctx.save();
-            ctx.beginPath();  
-            ctx.fillStyle = this.ringColor;
-            ctx.arc(0 ,0, this.hubRadius,hubsa, hubea, false);
-            ctx.closePath();
-            ctx.fill();
-            ctx.restore();
-            
-            // draw the ticks
-            if (this.showTicks) {
-                ctx.save();
-                var orad = this.tickOuterRadius,
-                    tl = this.tickLength,
-                    mtl = tl/2,
-                    nmt = this.numberMinorTicks,
-                    ts = this.span * Math.PI / 180 / (this.ticks.length-1),
-                    mts = ts/(nmt + 1);
-                
-                for (i = 0; i<this.ticks.length; i++) {
-                    ctx.beginPath();
-                    ctx.lineWidth = 1.5 + this.diameter/360;
-                    ctx.strokeStyle = this.ringColor;
-                    var wps = ts*i+sa;
-                    ctx.moveTo(-orad * Math.cos(ts*i+sa), orad * Math.sin(ts*i+sa));
-                    ctx.lineTo(-(orad-tl) * Math.cos(ts*i+sa), (orad - tl) * Math.sin(ts*i+sa));
-                    this._tickPoints.push([(orad-tl) * Math.cos(ts*i+sa) + this._center[0] + this.canvas._offsets.left, (orad - tl) * Math.sin(ts*i+sa) + this._center[1] + this.canvas._offsets.top, ts*i+sa]);
-                    ctx.stroke();
-                    ctx.lineWidth = 1.0 + this.diameter/440;
-                    if (i<this.ticks.length-1) {
-                        for (var j=1; j<=nmt; j++) {
-                            ctx.beginPath();
-                            ctx.moveTo(-orad * Math.cos(ts*i+mts*j+sa), orad * Math.sin(ts*i+mts*j+sa));
-                            ctx.lineTo(-(orad-mtl) * Math.cos(ts*i+mts*j+sa), (orad-mtl) * Math.sin(ts*i+mts*j+sa));
-                            ctx.stroke();
-                        }   
-                    }
-                }
-                ctx.restore();
-            }
-            
-            // draw the tick labels
-            if (this.showTickLabels) {
-                var elem, l, t, ew, eh, dim, maxdim=0;
-                var tp = this.tickPadding * (1 - 1/(this.diameter/80+1));
-                for (i=0; i<this.ticks.length; i++) {
-                    elem = $('<div class="jqplot-meterGauge-tick" style="position:absolute;">'+this.ticks[i][1]+'</div>');
-                    this.canvas._elem.after(elem);
-                    ew = elem.outerWidth(true);
-                    eh = elem.outerHeight(true);
-                    l = this._tickPoints[i][0] - ew * (this._tickPoints[i][2]-Math.PI)/Math.PI - tp * Math.cos(this._tickPoints[i][2]);
-                    t = this._tickPoints[i][1] - eh/2 + eh/2 * Math.pow(Math.abs((Math.sin(this._tickPoints[i][2]))), 0.5) + tp/3 * Math.pow(Math.abs((Math.sin(this._tickPoints[i][2]))), 0.5) ;
-                    // t = this._tickPoints[i][1] - eh/2 - eh/2 * Math.sin(this._tickPoints[i][2]) - tp/2 * Math.sin(this._tickPoints[i][2]);
-                    elem.css({left:l, top:t});
-                    dim  = ew*Math.cos(this._tickPoints[i][2]) + eh*Math.sin(Math.PI/2+this._tickPoints[i][2]/2);
-                    maxdim = (dim > maxdim) ? dim : maxdim;
-                }
-            }
-            
-            // draw the gauge label
-            if (this.label && this.labelPosition == 'inside') {
-                var l = this._center[0] + this.canvas._offsets.left;
-                var tp = this.tickPadding * (1 - 1/(this.diameter/80+1));
-                var t = 0.5*(this._center[1] + this.canvas._offsets.top - this.hubRadius) + 0.5*(this._center[1] + this.canvas._offsets.top - this.tickOuterRadius + this.tickLength + tp) + this.labelHeightAdjust;
-                // this._labelElem = $('<div class="jqplot-meterGauge-label" style="position:absolute;">'+this.label+'</div>');
-                // this.canvas._elem.after(this._labelElem);
-                l -= this._labelElem.outerWidth(true)/2;
-                t -= this._labelElem.outerHeight(true)/2;
-                this._labelElem.css({left:l, top:t});
-            }
-            
-            else if (this.label && this.labelPosition == 'bottom') {
-                var l = this._center[0] + this.canvas._offsets.left - this._labelElem.outerWidth(true)/2;
-                var t = this._center[1] + this.canvas._offsets.top + this.innerPad + + this.ringWidth + this.padding + this.labelHeightAdjust;
-                this._labelElem.css({left:l, top:t});
-                
-            }
-            
-            // draw the intervals
-            
-            ctx.save();
-            var inner = this.intervalInnerRadius || this.hubRadius * 1.5;
-            if (this.intervalOuterRadius == null) {
-                if (this.showTickLabels) {
-                    var outer = (this.tickOuterRadius - this.tickLength - this.tickPadding - this.diameter/8);
-                }
-                else {
-                    var outer = (this.tickOuterRadius - this.tickLength - this.diameter/16);
-                }
-            }
-            else {
-                var outer = this.intervalOuterRadius;
-            }
-            var range = this.max - this.min;
-            var intrange = this.intervals[this.intervals.length-1] - this.min;
-            var start, end, span = this.span*Math.PI/180;
-            for (i=0; i<this.intervals.length; i++) {
-                start = (i == 0) ? sa : sa + (this.intervals[i-1][0] - this.min)*span/range;
-                if (start < 0) {
-                    start = 0;
-                }
-                end = sa + (this.intervals[i][0] - this.min)*span/range;
-                if (end < 0) {
-                    end = 0;
-                }
-                ctx.beginPath();
-                ctx.fillStyle = this.intervals[i][2];
-                ctx.arc(0, 0, inner, start, end, false);
-                ctx.lineTo(outer*Math.cos(end), outer*Math.sin(end));
-                ctx.arc(0, 0, outer, end, start, true);
-                ctx.lineTo(inner*Math.cos(start), inner*Math.sin(start));
-                ctx.closePath();
-                ctx.fill();
-            }
-            ctx.restore();
-            
-            // draw the needle
-            var datapoint = this.data[0][1];
-            var dataspan = this.max - this.min;
-            if (this.pegNeedle) {
-                if (this.data[0][1] > this.max + dataspan*3/this.span) {
-                    datapoint = this.max + dataspan*3/this.span;
-                }
-                if (this.data[0][1] < this.min - dataspan*3/this.span) {
-                    datapoint = this.min - dataspan*3/this.span;
-                }
-            }
-            var dataang = (datapoint - this.min)/dataspan * this.span * Math.PI/180 + this.startAngle;
-            
-            
-            ctx.save();
-            ctx.beginPath();
-            ctx.fillStyle = this.ringColor;
-            ctx.strokeStyle = this.ringColor;
-            this.needleLength = (this.tickOuterRadius - this.tickLength) * 0.85;
-            this.needleThickness = (this.needleThickness < 2) ? 2 : this.needleThickness;
-            var endwidth = this.needleThickness * 0.4;
-
-            
-            var dl = this.needleLength/10;
-            var dt = (this.needleThickness - endwidth)/10;
-            var templ;
-            for (var i=0; i<10; i++) {
-                templ = this.needleThickness - i*dt;
-                ctx.moveTo(dl*i*Math.cos(dataang), dl*i*Math.sin(dataang));
-                ctx.lineWidth = templ;
-                ctx.lineTo(dl*(i+1)*Math.cos(dataang), dl*(i+1)*Math.sin(dataang));
-                ctx.stroke();
-            }
-            
-            ctx.restore();
-        }
-        else {
-            this._center = [(cw - trans * offx)/2 + trans * offx, (ch - trans*offy)/2 + trans * offy];
-        }               
-    };
-    
-    $.jqplot.MeterGaugeAxisRenderer = function() {
-        $.jqplot.LinearAxisRenderer.call(this);
-    };
-    
-    $.jqplot.MeterGaugeAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
-    $.jqplot.MeterGaugeAxisRenderer.prototype.constructor = $.jqplot.MeterGaugeAxisRenderer;
-        
-    
-    // There are no traditional axes on a gauge chart.  We just need to provide
-    // dummy objects with properties so the plot will render.
-    // called with scope of axis object.
-    $.jqplot.MeterGaugeAxisRenderer.prototype.init = function(options){
-        //
-        this.tickRenderer = $.jqplot.MeterGaugeTickRenderer;
-        $.extend(true, this, options);
-        // I don't think I'm going to need _dataBounds here.
-        // have to go Axis scaling in a way to fit chart onto plot area
-        // and provide u2p and p2u functionality for mouse cursor, etc.
-        // for convienence set _dataBounds to 0 and 100 and
-        // set min/max to 0 and 100.
-        this._dataBounds = {min:0, max:100};
-        this.min = 0;
-        this.max = 100;
-        this.showTicks = false;
-        this.ticks = [];
-        this.showMark = false;
-        this.show = false; 
-    };
-    
-    $.jqplot.MeterGaugeLegendRenderer = function(){
-        $.jqplot.TableLegendRenderer.call(this);
-    };
-    
-    $.jqplot.MeterGaugeLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
-    $.jqplot.MeterGaugeLegendRenderer.prototype.constructor = $.jqplot.MeterGaugeLegendRenderer;
-    
-    /**
-     * Class: $.jqplot.MeterGaugeLegendRenderer
-     *Meter gauges don't typically have a legend, this overrides the default legend renderer.
-     */
-    $.jqplot.MeterGaugeLegendRenderer.prototype.init = function(options) {
-        // Maximum number of rows in the legend.  0 or null for unlimited.
-        this.numberRows = null;
-        // Maximum number of columns in the legend.  0 or null for unlimited.
-        this.numberColumns = null;
-        $.extend(true, this, options);
-    };
-    
-    // called with context of legend
-    $.jqplot.MeterGaugeLegendRenderer.prototype.draw = function() {
-        if (this.show) {
-            var series = this._series;
-            var ss = 'position:absolute;';
-            ss += (this.background) ? 'background:'+this.background+';' : '';
-            ss += (this.border) ? 'border:'+this.border+';' : '';
-            ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
-            ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
-            ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
-            ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : '';
-            ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : '';
-            ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : '';
-            ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : '';
-            this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
-            // MeterGauge charts legends don't go by number of series, but by number of data points
-            // in the series.  Refactor things here for that.
-            
-            var pad = false, 
-                reverse = false,
-                nr, nc;
-            var s = series[0];
-            
-            if (s.show) {
-                var pd = s.data;
-                if (this.numberRows) {
-                    nr = this.numberRows;
-                    if (!this.numberColumns){
-                        nc = Math.ceil(pd.length/nr);
-                    }
-                    else{
-                        nc = this.numberColumns;
-                    }
-                }
-                else if (this.numberColumns) {
-                    nc = this.numberColumns;
-                    nr = Math.ceil(pd.length/this.numberColumns);
-                }
-                else {
-                    nr = pd.length;
-                    nc = 1;
-                }
-                
-                var i, j, tr, td1, td2, lt, rs, color;
-                var idx = 0;    
-                
-                for (i=0; i<nr; i++) {
-                    if (reverse){
-                        tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem);
-                    }
-                    else{
-                        tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem);
-                    }
-                    for (j=0; j<nc; j++) {
-                        if (idx < pd.length){
-                            // debugger
-                            lt = this.labels[idx] || pd[idx][0].toString();
-                            color = s.color;
-                            if (!reverse){
-                                if (i>0){
-                                    pad = true;
-                                }
-                                else{
-                                    pad = false;
-                                }
-                            }
-                            else{
-                                if (i == nr -1){
-                                    pad = false;
-                                }
-                                else{
-                                    pad = true;
-                                }
-                            }
-                            rs = (pad) ? this.rowSpacing : '0';
-                
-                            td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
-                                '<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+
-                                '</div></td>');
-                            td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
-                            if (this.escapeHtml){
-                                td2.text(lt);
-                            }
-                            else {
-                                td2.html(lt);
-                            }
-                            if (reverse) {
-                                td2.prependTo(tr);
-                                td1.prependTo(tr);
-                            }
-                            else {
-                                td1.appendTo(tr);
-                                td2.appendTo(tr);
-                            }
-                            pad = true;
-                        }
-                        idx++;
-                    }   
-                }
-            }
-        }
-        return this._elem;                
-    };
-    
-    
-    // setup default renderers for axes and legend so user doesn't have to
-    // called with scope of plot
-    function preInit(target, data, options) {
-        // debugger
-        options = options || {};
-        options.axesDefaults = options.axesDefaults || {};
-        options.legend = options.legend || {};
-        options.seriesDefaults = options.seriesDefaults || {};
-        options.grid = options.grid || {};
-           
-        // only set these if there is a gauge series
-        var setopts = false;
-        if (options.seriesDefaults.renderer == $.jqplot.MeterGaugeRenderer) {
-            setopts = true;
-        }
-        else if (options.series) {
-            for (var i=0; i < options.series.length; i++) {
-                if (options.series[i].renderer == $.jqplot.MeterGaugeRenderer) {
-                    setopts = true;
-                }
-            }
-        }
-        
-        if (setopts) {
-            options.axesDefaults.renderer = $.jqplot.MeterGaugeAxisRenderer;
-            options.legend.renderer = $.jqplot.MeterGaugeLegendRenderer;
-            options.legend.preDraw = true;
-            options.grid.background = options.grid.background || 'white';
-            options.grid.drawGridlines = false;
-            options.grid.borderWidth = (options.grid.borderWidth != null) ? options.grid.borderWidth : 0;
-            options.grid.shadow = (options.grid.shadow != null) ? options.grid.shadow : false;
-        }
-    }
-    
-    // called with scope of plot
-    function postParseOptions(options) {
-        //
-    }
-    
-    $.jqplot.preInitHooks.push(preInit);
-    $.jqplot.postParseOptionsHooks.push(postParseOptions);
-    
-    $.jqplot.MeterGaugeTickRenderer = function() {
-        $.jqplot.AxisTickRenderer.call(this);
-    };
-    
-    $.jqplot.MeterGaugeTickRenderer.prototype = new $.jqplot.AxisTickRenderer();
-    $.jqplot.MeterGaugeTickRenderer.prototype.constructor = $.jqplot.MeterGaugeTickRenderer;
-    
-})(jQuery);
-    
-    
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.meterGaugeRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.meterGaugeRenderer.min.js
deleted file mode 100644
index 49d8dab..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.meterGaugeRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(c){c.jqplot.MeterGaugeRenderer=function(){c.jqplot.LineRenderer.call(this)};c.jqplot.MeterGaugeRenderer.prototype=new c.jqplot.LineRenderer();c.jqplot.MeterGaugeRenderer.prototype.constructor=c.jqplot.MeterGaugeRenderer;c.jqplot.MeterGaugeRenderer.prototype.init=function(e){this.diameter=null;this.padding=null;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=4;this.background="#efefef";this.ringColor="#BBC6D0";this.needleColor="#C3D3E5";this.tickColor="989898";this.ringWidth=null;this.min;this.max;this.ticks=[];this.showTicks=true;this.showTickLabels=true;this.label=null;this.labelHeightAdjust=0;this.labelPosition="inside";this.intervals=[];this.intervalColors=["#4bb2c5","#EAA228","#c5b47f","#579575","#839557","#958c12","#953579","#4b5de4","#d8b83f","#ff5800","#0085cc","#c747a3","#cddf54","#FBD178","#26B4E3","#bd70c7"];this.intervalInnerRadius=null;this.intervalOuterRadius=null;this.tickRenderer=c.jqplot.MeterGaugeTickRenderer;this.tickPositions=[1,2,2.5,5,10];this.tickSpacing=30;this.numberMinorTicks=null;this.hubRadius=null;this.tickPadding=null;this.needleThickness=null;this.needlePad=6;this.pegNeedle=true;this._type="meterGauge";c.extend(true,this,e);this.type=null;this.numberTicks=null;this.tickInterval=null;this.span=180;if(this.type=="circular"){this.semiCircular=false}else{if(this.type!="circular"){this.semiCircular=true}else{this.semiCircular=(this.span<=180)?true:false}}this._tickPoints=[];this._labelElem=null;this.startAngle=(90+(360-this.span)/2)*Math.PI/180;this.endAngle=(90-(360-this.span)/2)*Math.PI/180;this.setmin=!!(this.min==null);this.setmax=!!(this.max==null);if(this.intervals.length){if(this.intervals[0].length==null||this.intervals.length==1){for(var f=0;f<this.intervals.length;f++){this.intervals[f]=[this.intervals[f],this.intervals[f],this.intervalColors[f]]}}else{if(this.intervals[0].length==2){for(f=0;f<this.intervals.length;f++){this.intervals[f]=[this.intervals[f][0],this.intervals[f][1],this.intervalColors[f]]}}}}if(this.ticks.length){if(this.ticks[0].length==null||this.ticks[0].length==1){for(var f=0;f<this.ticks.length;f++){this.ticks[f]=[this.ticks[f],this.ticks[f]]}}this.min=(this.min==null)?this.ticks[0][0]:this.min;this.max=(this.max==null)?this.ticks[this.ticks.length-1][0]:this.max;this.setmin=false;this.setmax=false;this.numberTicks=this.ticks.length;this.tickInterval=this.ticks[1][0]-this.ticks[0][0];this.tickFactor=Math.floor(parseFloat((Math.log(this.tickInterval)/Math.log(10)).toFixed(11)));this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor);if(!this.numberMinorTicks){this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor-1)}if(!this.numberMinorTicks){this.numberMinorTicks=1}}else{if(this.intervals.length){this.min=(this.min==null)?0:this.min;this.setmin=false;if(this.max==null){if(this.intervals[this.intervals.length-1][0]>=this.data[0][1]){this.max=this.intervals[this.intervals.length-1][0];this.setmax=false}}else{this.setmax=false}}else{this.min=(this.min==null)?0:this.min;this.setmin=false;if(this.max==null){this.max=this.data[0][1]*1.25;this.setmax=true}else{this.setmax=false}}}};c.jqplot.MeterGaugeRenderer.prototype.setGridData=function(j){var f=[];var k=[];var e=this.startAngle;for(var h=0;h<this.data.length;h++){f.push(this.data[h][1]);k.push([this.data[h][0]]);if(h>0){f[h]+=f[h-1]}}var g=Math.PI*2/f[f.length-1];for(var h=0;h<f.length;h++){k[h][1]=f[h]*g}this.gridData=k};c.jqplot.MeterGaugeRenderer.prototype.makeGridData=function(j,k){var f=[];var l=[];var e=this.startAngle;for(var h=0;h<j.length;h++){f.push(j[h][1]);l.push([j[h][0]]);if(h>0){f[h]+=f[h-1]}}var g=Math.PI*2/f[f.length-1];for(var h=0;h<f.length;h++){l[h][1]=f[h]*g}return l};function b(j,f,g){var e;for(var h=j.length-1;h>=0;h--){e=f/(j[h]*Math.pow(10,g));if(e==4||e==5){return e-1}}return null}c.jqplot.MeterGaugeRenderer.prototype.draw=function(X,aC,ap){var aa;var aM=(ap!=undefined)?ap:{};var ai=0;var ah=0;var at=1;if(ap.legendInfo&&ap.legendInfo.placement=="inside"){var aI=ap.legendInfo;switch(aI.location){case"nw":ai=aI.width+aI.xoffset;break;case"w":ai=aI.width+aI.xoffset;break;case"sw":ai=aI.width+aI.xoffset;break;case"ne":ai=aI.width+aI.xoffset;at=-1;break;case"e":ai=aI.width+aI.xoffset;at=-1;break;case"se":ai=aI.width+aI.xoffset;at=-1;break;case"n":ah=aI.height+aI.yoffset;break;case"s":ah=aI.height+aI.yoffset;at=-1;break;default:break}}if(this.label){this._labelElem=c('<div class="jqplot-meterGauge-label" style="position:absolute;">'+this.label+"</div>");this.canvas._elem.after(this._labelElem)}var m=(aM.shadow!=undefined)?aM.shadow:this.shadow;var N=(aM.showLine!=undefined)?aM.showLine:this.showLine;var I=(aM.fill!=undefined)?aM.fill:this.fill;var K=X.canvas.width;var S=X.canvas.height;if(this.padding==null){this.padding=Math.round(Math.min(K,S)/30)}var Q=K-ai-2*this.padding;var ab=S-ah-2*this.padding;if(this.labelPosition=="bottom"&&this.label){ab-=this._labelElem.outerHeight(true)}var L=Math.min(Q,ab);var ad=L;if(!this.diameter){if(this.semiCircular){if(Q>=2*ab){if(!this.ringWidth){this.ringWidth=2*ab/35}this.needleThickness=this.needleThickness||2+Math.pow(this.ringWidth,0.8);this.innerPad=this.ringWidth/2+this.needleThickness/2+this.needlePad;this.diameter=2*(ab-2*this.innerPad)}else{if(!this.ringWidth){this.ringWidth=Q/35}this.needleThickness=this.needleThickness||2+Math.pow(this.ringWidth,0.8);this.innerPad=this.ringWidth/2+this.needleThickness/2+this.needlePad;this.diameter=Q-2*this.innerPad-this.ringWidth-this.padding}this._center=[(K-at*ai)/2+at*ai,(S+at*ah-this.padding-this.ringWidth-this.innerPad)]}else{if(!this.ringWidth){this.ringWidth=ad/35}this.needleThickness=this.needleThickness||2+Math.pow(this.ringWidth,0.8);this.innerPad=0;this.diameter=ad-this.ringWidth;this._center=[(K-at*ai)/2+at*ai,(S-at*ah)/2+at*ah]}}if(this._labelElem&&this.labelPosition=="bottom"){this._center[1]-=this._labelElem.outerHeight(true)}this._radius=this.diameter/2;this.tickSpacing=6000/this.diameter;if(!this.hubRadius){this.hubRadius=this.diameter/18}this.shadowOffset=0.5+this.ringWidth/9;this.shadowWidth=this.ringWidth*1;this.tickPadding=3+Math.pow(this.diameter/20,0.7);this.tickOuterRadius=this._radius-this.ringWidth/2-this.tickPadding;this.tickLength=(this.showTicks)?this._radius/13:0;if(this.ticks.length==0){var A=this.max,aL=this.min,q=this.setmax,aG=this.setmin,au=(A-aL)*this.tickSpacing/this.span;var aw=Math.floor(parseFloat((Math.log(au)/Math.log(10)).toFixed(11)));var an=(au/Math.pow(10,aw));(an>2&&an<=2.5)?an=2.5:an=Math.ceil(an);var T=this.tickPositions;var aA,ak;for(aa=0;aa<T.length;aa++){if(an==T[aa]||aa&&T[aa-1]<an&&an<T[aa]){au=T[aa]*Math.pow(10,aw);aA=aa}}for(aa=0;aa<T.length;aa++){if(an==T[aa]||aa&&T[aa-1]<an&&an<T[aa]){au=T[aa]*Math.pow(10,aw);ak=Math.ceil((A-aL)/au)}}if(q&&aG){var aP=(aL>0)?aL-aL%au:aL-aL%au-au;if(!this.forceZero){var D=Math.min(aL-aP,0.8*au);var o=Math.floor(D/T[aA]);if(o>1){aP=aP+T[aA]*(o-1);if(parseInt(aP,10)!=aP&&parseInt(aP-T[aA],10)==aP-T[aA]){aP=aP-T[aA]}}}if(aL==aP){aL-=au}else{if(aL-aP>0.23*au){aL=aP}else{aL=aP-au;ak+=1}}ak+=1;var E=aL+(ak-1)*au;if(A>=E){E+=au;ak+=1}if(E-A<0.23*au){E+=au;ak+=1}this.max=A=E;this.min=aL;this.tickInterval=au;this.numberTicks=ak;var O;for(aa=0;aa<ak;aa++){O=parseFloat((aL+aa*au).toFixed(11));this.ticks.push([O,O])}this.max=this.ticks[ak-1][1];this.tickFactor=aw;this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor);if(!this.numberMinorTicks){this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor-1)}}else{if(q){var E=aL+(ak-1)*au;if(A>=E){A=E+au;ak+=1}else{A=E}this.tickInterval=this.tickInterval||au;this.numberTicks=this.numberTicks||ak;var O;for(aa=0;aa<this.numberTicks;aa++){O=parseFloat((aL+aa*this.tickInterval).toFixed(11));this.ticks.push([O,O])}this.max=this.ticks[this.numberTicks-1][1];this.tickFactor=aw;this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor);if(!this.numberMinorTicks){this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor-1)}}}if(!q&&!aG){var P=this.max-this.min;aw=Math.floor(parseFloat((Math.log(P)/Math.log(10)).toFixed(11)))-1;var aN=[5,6,4,7,3,8,9,10,2],V,C,av=0,M;if(P>1){var aJ=String(P);if(aJ.search(/\./)==-1){var aF=aJ.search(/0+$/);av=(aF>0)?aJ.length-aF-1:0}}M=P/Math.pow(10,av);for(aa=0;aa<aN.length;aa++){V=M/(aN[aa]-1);if(V==parseInt(V,10)){this.numberTicks=aN[aa];this.tickInterval=P/(this.numberTicks-1);this.tickFactor=aw+1;break}}var O;for(aa=0;aa<this.numberTicks;aa++){O=parseFloat((this.min+aa*this.tickInterval).toFixed(11));this.ticks.push([O,O])}this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor);if(!this.numberMinorTicks){this.numberMinorTicks=b(this.tickPositions,this.tickInterval,this.tickFactor-1)}if(!this.numberMinorTicks){this.numberMinorTicks=1;var aH=[4,5,3,6,2];for(aa=0;aa<5;aa++){var ao=this.tickInterval/aH[aa];if(ao==parseInt(ao,10)){this.numberMinorTicks=aH[aa]-1;break}}}}}var U=this._radius,aE=this.startAngle,k=this.endAngle,H=Math.PI,e=Math.PI/2;if(this.semiCircular){var z=Math.atan(this.innerPad/U),ac=this.outerStartAngle=aE-z,aB=this.outerEndAngle=k+z,B=this.hubStartAngle=aE-Math.atan(this.innerPad/this.hubRadius*2),af=this.hubEndAngle=k+Math.atan(this.innerPad/this.hubRadius*2);X.save();X.translate(this._center[0],this._center[1]);X.lineJoin="round";X.lineCap="round";X.save();X.beginPath();X.fillStyle=this.background;X.arc(0,0,U,ac,aB,false);X.closePath();X.fill();X.restore();var aj="rgba(0,0,0,"+this.shadowAlpha+")";X.save();for(var aa=0;aa<this.shadowDepth;aa++){X.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));X.beginPath();X.strokeStyle=aj;X.lineWidth=this.shadowWidth;X.arc(0,0,U,ac,aB,false);X.closePath();X.stroke()}X.restore();X.save();var az=parseInt((this.shadowDepth+1)/2,10);for(var aa=0;aa<az;aa++){X.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));X.beginPath();X.fillStyle=aj;X.arc(0,0,this.hubRadius,B,af,false);X.closePath();X.fill()}X.restore();X.save();X.beginPath();X.strokeStyle=this.ringColor;X.lineWidth=this.ringWidth;X.arc(0,0,U,ac,aB,false);X.closePath();X.stroke();X.restore();X.save();X.beginPath();X.fillStyle=this.ringColor;X.arc(0,0,this.hubRadius,B,af,false);X.closePath();X.fill();X.restore();if(this.showTicks){X.save();var f=this.tickOuterRadius,aq=this.tickLength,v=aq/2,F=this.numberMinorTicks,am=this.span*Math.PI/180/(this.ticks.length-1),p=am/(F+1);for(aa=0;aa<this.ticks.length;aa++){X.beginPath();X.lineWidth=1.5+this.diameter/360;X.strokeStyle=this.ringColor;var ae=am*aa+aE;X.moveTo(-f*Math.cos(am*aa+aE),f*Math.sin(am*aa+aE));X.lineTo(-(f-aq)*Math.cos(am*aa+aE),(f-aq)*Math.sin(am*aa+aE));this._tickPoints.push([(f-aq)*Math.cos(am*aa+aE)+this._center[0]+this.canvas._offsets.left,(f-aq)*Math.sin(am*aa+aE)+this._center[1]+this.canvas._offsets.top,am*aa+aE]);X.stroke();X.lineWidth=1+this.diameter/440;if(aa<this.ticks.length-1){for(var Y=1;Y<=F;Y++){X.beginPath();X.moveTo(-f*Math.cos(am*aa+p*Y+aE),f*Math.sin(am*aa+p*Y+aE));X.lineTo(-(f-v)*Math.cos(am*aa+p*Y+aE),(f-v)*Math.sin(am*aa+p*Y+aE));X.stroke()}}}X.restore()}if(this.showTickLabels){var J,W,T,aO,g,G,n=0;var an=this.tickPadding*(1-1/(this.diameter/80+1));for(aa=0;aa<this.ticks.length;aa++){J=c('<div class="jqplot-meterGauge-tick" style="position:absolute;">'+this.ticks[aa][1]+"</div>");this.canvas._elem.after(J);aO=J.outerWidth(true);g=J.outerHeight(true);W=this._tickPoints[aa][0]-aO*(this._tickPoints[aa][2]-Math.PI)/Math.PI-an*Math.cos(this._tickPoints[aa][2]);T=this._tickPoints[aa][1]-g/2+g/2*Math.pow(Math.abs((Math.sin(this._tickPoints[aa][2]))),0.5)+an/3*Math.pow(Math.abs((Math.sin(this._tickPoints[aa][2]))),0.5);J.css({left:W,top:T});G=aO*Math.cos(this._tickPoints[aa][2])+g*Math.sin(Math.PI/2+this._tickPoints[aa][2]/2);n=(G>n)?G:n}}if(this.label&&this.labelPosition=="inside"){var W=this._center[0]+this.canvas._offsets.left;var an=this.tickPadding*(1-1/(this.diameter/80+1));var T=0.5*(this._center[1]+this.canvas._offsets.top-this.hubRadius)+0.5*(this._center[1]+this.canvas._offsets.top-this.tickOuterRadius+this.tickLength+an)+this.labelHeightAdjust;W-=this._labelElem.outerWidth(true)/2;T-=this._labelElem.outerHeight(true)/2;this._labelElem.css({left:W,top:T})}else{if(this.label&&this.labelPosition=="bottom"){var W=this._center[0]+this.canvas._offsets.left-this._labelElem.outerWidth(true)/2;var T=this._center[1]+this.canvas._offsets.top+this.innerPad+ +this.ringWidth+this.padding+this.labelHeightAdjust;this._labelElem.css({left:W,top:T})}}X.save();var ax=this.intervalInnerRadius||this.hubRadius*1.5;if(this.intervalOuterRadius==null){if(this.showTickLabels){var ag=(this.tickOuterRadius-this.tickLength-this.tickPadding-this.diameter/8)}else{var ag=(this.tickOuterRadius-this.tickLength-this.diameter/16)}}else{var ag=this.intervalOuterRadius}var P=this.max-this.min;var aD=this.intervals[this.intervals.length-1]-this.min;var y,Z,u=this.span*Math.PI/180;for(aa=0;aa<this.intervals.length;aa++){y=(aa==0)?aE:aE+(this.intervals[aa-1][0]-this.min)*u/P;if(y<0){y=0}Z=aE+(this.intervals[aa][0]-this.min)*u/P;if(Z<0){Z=0}X.beginPath();X.fillStyle=this.intervals[aa][2];X.arc(0,0,ax,y,Z,false);X.lineTo(ag*Math.cos(Z),ag*Math.sin(Z));X.arc(0,0,ag,Z,y,true);X.lineTo(ax*Math.cos(y),ax*Math.sin(y));X.closePath();X.fill()}X.restore();var ay=this.data[0][1];var R=this.max-this.min;if(this.pegNeedle){if(this.data[0][1]>this.max+R*3/this.span){ay=this.max+R*3/this.span}if(this.data[0][1]<this.min-R*3/this.span){ay=this.min-R*3/this.span}}var al=(ay-this.min)/R*this.span*Math.PI/180+this.startAngle;X.save();X.beginPath();X.fillStyle=this.ringColor;X.strokeStyle=this.ringColor;this.needleLength=(this.tickOuterRadius-this.tickLength)*0.85;this.needleThickness=(this.needleThickness<2)?2:this.needleThickness;var aK=this.needleThickness*0.4;var x=this.needleLength/10;var s=(this.needleThickness-aK)/10;var ar;for(var aa=0;aa<10;aa++){ar=this.needleThickness-aa*s;X.moveTo(x*aa*Math.cos(al),x*aa*Math.sin(al));X.lineWidth=ar;X.lineTo(x*(aa+1)*Math.cos(al),x*(aa+1)*Math.sin(al));X.stroke()}X.restore()}else{this._center=[(K-at*ai)/2+at*ai,(S-at*ah)/2+at*ah]}};c.jqplot.MeterGaugeAxisRenderer=function(){c.jqplot.LinearAxisRenderer.call(this)};c.jqplot.MeterGaugeAxisRenderer.prototype=new c.jqplot.LinearAxisRenderer();c.jqplot.MeterGaugeAxisRenderer.prototype.constructor=c.jqplot.MeterGaugeAxisRenderer;c.jqplot.MeterGaugeAxisRenderer.prototype.init=function(e){this.tickRenderer=c.jqplot.MeterGaugeTickRenderer;c.extend(true,this,e);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};c.jqplot.MeterGaugeLegendRenderer=function(){c.jqplot.TableLegendRenderer.call(this)};c.jqplot.MeterGaugeLegendRenderer.prototype=new c.jqplot.TableLegendRenderer();c.jqplot.MeterGaugeLegendRenderer.prototype.constructor=c.jqplot.MeterGaugeLegendRenderer;c.jqplot.MeterGaugeLegendRenderer.prototype.init=function(e){this.numberRows=null;this.numberColumns=null;c.extend(true,this,e)};c.jqplot.MeterGaugeLegendRenderer.prototype.draw=function(){if(this.show){var p=this._series;var x="position:absolute;";x+=(this.background)?"background:"+this.background+";":"";x+=(this.border)?"border:"+this.border+";":"";x+=(this.fontSize)?"font-size:"+this.fontSize+";":"";x+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";x+=(this.textColor)?"color:"+this.textColor+";":"";x+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";x+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";x+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";x+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=c('<table class="jqplot-table-legend" style="'+x+'"></table>');var f=false,q=false,u,o;var w=p[0];if(w.show){var t=w.data;if(this.numberRows){u=this.numberRows;if(!this.numberColumns){o=Math.ceil(t.length/u)}else{o=this.numberColumns}}else{if(this.numberColumns){o=this.numberColumns;u=Math.ceil(t.length/this.numberColumns)}else{u=t.length;o=1}}var n,m,r,g,e,l,k,h;var v=0;for(n=0;n<u;n++){if(q){r=c('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{r=c('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(m=0;m<o;m++){if(v<t.length){l=this.labels[v]||t[v][0].toString();h=w.color;if(!q){if(n>0){f=true}else{f=false}}else{if(n==u-1){f=false}else{f=true}}k=(f)?this.rowSpacing:"0";g=c('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+k+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+h+';"></div></div></td>');e=c('<td class="jqplot-table-legend" style="padding-top:'+k+';"></td>');if(this.escapeHtml){e.text(l)}else{e.html(l)}if(q){e.prependTo(r);g.prependTo(r)}else{g.appendTo(r);e.appendTo(r)}f=true}v++}}}}return this._elem};function a(j,h,f){f=f||{};f.axesDefaults=f.axesDefaults||{};f.legend=f.legend||{};f.seriesDefaults=f.seriesDefaults||{};f.grid=f.grid||{};var e=false;if(f.seriesDefaults.renderer==c.jqplot.MeterGaugeRenderer){e=true}else{if(f.series){for(var g=0;g<f.series.length;g++){if(f.series[g].renderer==c.jqplot.MeterGaugeRenderer){e=true}}}}if(e){f.axesDefaults.renderer=c.jqplot.MeterGaugeAxisRenderer;f.legend.renderer=c.jqplot.MeterGaugeLegendRenderer;f.legend.preDraw=true;f.grid.background=f.grid.background||"white";f.grid.drawGridlines=false;f.grid.borderWidth=(f.grid.borderWidth!=null)?f.grid.borderWidth:0;f.grid.shadow=(f.grid.shadow!=null)?f.grid.shadow:false}}function d(e){}c.jqplot.preInitHooks.push(a);c.jqplot.postParseOptionsHooks.push(d);c.jqplot.MeterGaugeTickRenderer=function(){c.jqplot.AxisTickRenderer.call(this)};c.jqplot.MeterGaugeTickRenderer.prototype=new c.jqplot.AxisTickRenderer();c.jqplot.MeterGaugeTickRenderer.prototype.constructor=c.jqplot.MeterGaugeTickRenderer})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ohlcRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ohlcRenderer.js
deleted file mode 100644
index e84db13..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ohlcRenderer.js
+++ /dev/null
@@ -1,372 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-     * Class: $.jqplot.OHLCRenderer
-     * jqPlot Plugin to draw Open Hi Low Close, Candlestick and Hi Low Close charts.
-     * 
-     * To use this plugin, include the renderer js file in 
-     * your source:
-     * 
-     * > <script type="text/javascript" src="plugins/jqplot.ohlcRenderer.js"></script>
-     * 
-     * You will most likely want to use a date axis renderer
-     * for the x axis also, so include the date axis render js file also:
-     * 
-     * > <script type="text/javascript" src="plugins/jqplot.dateAxisRenderer.js"></script>
-     * 
-     * Then you set the renderer in the series options on your plot:
-     * 
-     * > series: [{renderer:$.jqplot.OHLCRenderer}]
-     * 
-     * For OHLC and candlestick charts, data should be specified
-     * like so:
-     * 
-     * > dat = [['07/06/2009',138.7,139.68,135.18,135.4], ['06/29/2009',143.46,144.66,139.79,140.02], ...]
-     * 
-     * If the data array has only 4 values per point instead of 5,
-     * the renderer will create a Hi Low Close chart instead.  In that case,
-     * data should be supplied like:
-     * 
-     * > dat = [['07/06/2009',139.68,135.18,135.4], ['06/29/2009',144.66,139.79,140.02], ...]
-     * 
-     * To generate a candlestick chart instead of an OHLC chart,
-     * set the "candlestick" option to true:
-     * 
-     * > series: [{renderer:$.jqplot.OHLCRenderer, rendererOptions:{candleStick:true}}],
-     * 
-     */
-    $.jqplot.OHLCRenderer = function(){
-        // subclass line renderer to make use of some of it's methods.
-        $.jqplot.LineRenderer.call(this);
-        // prop: candleStick
-        // true to render chart as candleStick.
-        // Must have an open price, cannot be a hlc chart.
-        this.candleStick = false;
-        // prop: tickLength
-        // length of the line in pixels indicating open and close price.
-        // Default will auto calculate based on plot width and 
-        // number of points displayed.
-        this.tickLength = 'auto';
-        // prop: bodyWidth
-        // width of the candlestick body in pixels.  Default will auto calculate
-        // based on plot width and number of candlesticks displayed.
-        this.bodyWidth = 'auto';
-        // prop: openColor
-        // color of the open price tick mark.  Default is series color.
-        this.openColor = null;
-        // prop: closeColor
-        // color of the close price tick mark.  Default is series color.
-        this.closeColor = null;
-        // prop: wickColor
-        // color of the hi-lo line thorugh the candlestick body.
-        // Default is the series color.
-        this.wickColor = null;
-        // prop: fillUpBody
-        // true to render an "up" day (close price greater than open price)
-        // with a filled candlestick body.
-        this.fillUpBody = false;
-        // prop: fillDownBody
-        // true to render a "down" day (close price lower than open price)
-        // with a filled candlestick body.
-        this.fillDownBody = true;
-        // prop: upBodyColor
-        // Color of candlestick body of an "up" day.  Default is series color.
-        this.upBodyColor = null;
-        // prop: downBodyColor
-        // Color of candlestick body on a "down" day.  Default is series color.
-        this.downBodyColor = null;
-        // prop: hlc
-        // true if is a hi-low-close chart (no open price).
-        // This is determined automatically from the series data.
-        this.hlc = false;
-        // prop: lineWidth
-        // Width of the hi-low line and open/close ticks.
-        // Must be set in the rendererOptions for the series.
-        this.lineWidth = 1.5;
-        this._tickLength;
-        this._bodyWidth;
-    };
-    
-    $.jqplot.OHLCRenderer.prototype = new $.jqplot.LineRenderer();
-    $.jqplot.OHLCRenderer.prototype.constructor = $.jqplot.OHLCRenderer;
-    
-    // called with scope of series.
-    $.jqplot.OHLCRenderer.prototype.init = function(options) {
-        options = options || {};
-        // lineWidth has to be set on the series, changes in renderer
-        // constructor have no effect.  set the default here
-        // if no renderer option for lineWidth is specified.
-        this.lineWidth = options.lineWidth || 1.5;
-        $.jqplot.LineRenderer.prototype.init.call(this, options);
-        this._type = 'ohlc';
-        // set the yaxis data bounds here to account for hi and low values
-        var db = this._yaxis._dataBounds;
-        var d = this._plotData;
-        // if data points have less than 5 values, force a hlc chart.
-        if (d[0].length < 5) {
-            this.renderer.hlc = true;
-
-            for (var j=0; j<d.length; j++) { 
-                if (d[j][2] < db.min || db.min == null) {
-                    db.min = d[j][2];
-                }
-                if (d[j][1] > db.max || db.max == null) {
-                    db.max = d[j][1];
-                }             
-            }
-        }
-        else {
-            for (var j=0; j<d.length; j++) { 
-                if (d[j][3] < db.min || db.min == null) {
-                    db.min = d[j][3];
-                }
-                if (d[j][2] > db.max || db.max == null) {
-                    db.max = d[j][2];
-                }             
-            }
-        }
-        
-    };
-    
-    // called within scope of series.
-    $.jqplot.OHLCRenderer.prototype.draw = function(ctx, gd, options) {
-        var d = this.data;
-        var xmin = this._xaxis.min;
-        var xmax = this._xaxis.max;
-        // index of last value below range of plot.
-        var xminidx = 0;
-        // index of first value above range of plot.
-        var xmaxidx = d.length;
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var i, prevColor, ops, b, h, w, a, points;
-        var o;
-        var r = this.renderer;
-        var opts = (options != undefined) ? options : {};
-        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
-        var fill = (opts.fill != undefined) ? opts.fill : this.fill;
-        var fillAndStroke = (opts.fillAndStroke != undefined) ? opts.fillAndStroke : this.fillAndStroke;
-        r.bodyWidth = (opts.bodyWidth != undefined) ? opts.bodyWidth : r.bodyWidth;
-        r.tickLength = (opts.tickLength != undefined) ? opts.tickLength : r.tickLength;
-        ctx.save();
-        if (this.show) {
-            var x, open, hi, low, close;
-            // need to get widths based on number of points shown,
-            // not on total number of points.  Use the results 
-            // to speed up drawing in next step.
-            for (var i=0; i<d.length; i++) {
-                if (d[i][0] < xmin) {
-                    xminidx = i;
-                }
-                else if (d[i][0] < xmax) {
-                    xmaxidx = i+1;
-                }
-            }
-
-            var dwidth = this.gridData[xmaxidx-1][0] - this.gridData[xminidx][0];
-            var nvisiblePoints = xmaxidx - xminidx;
-            try {
-                var dinterval = Math.abs(this._xaxis.series_u2p(parseInt(this._xaxis._intervalStats[0].sortedIntervals[0].interval)) - this._xaxis.series_u2p(0)); 
-            }
-
-            catch (e) {
-                var dinterval = dwidth / nvisiblePoints;
-            }
-            
-            if (r.candleStick) {
-                if (typeof(r.bodyWidth) == 'number') {
-                    r._bodyWidth = r.bodyWidth;
-                }
-                else {
-                    r._bodyWidth = Math.min(20, dinterval/1.75);
-                }
-            }
-            else {
-                if (typeof(r.tickLength) == 'number') {
-                    r._tickLength = r.tickLength;
-                }
-                else {
-                    r._tickLength = Math.min(10, dinterval/3.5);
-                }
-            }
-            
-            for (var i=xminidx; i<xmaxidx; i++) {
-                x = xp(d[i][0]);
-                if (r.hlc) {
-                    open = null;
-                    hi = yp(d[i][1]);
-                    low = yp(d[i][2]);
-                    close = yp(d[i][3]);
-                }
-                else {
-                    open = yp(d[i][1]);
-                    hi = yp(d[i][2]);
-                    low = yp(d[i][3]);
-                    close = yp(d[i][4]);
-                }
-                o = {};
-                if (r.candleStick && !r.hlc) {
-                    w = r._bodyWidth;
-                    a = x - w/2;
-                    // draw candle
-                    // determine if candle up or down
-                    // up, remember grid coordinates increase downward
-                    if (close < open) {
-                        // draw wick
-                        if (r.wickColor) {
-                            o.color = r.wickColor;
-                        }
-                        else if (r.downBodyColor) {
-                            o.color = r.upBodyColor;
-                        }
-                        ops = $.extend(true, {}, opts, o);
-                        r.shapeRenderer.draw(ctx, [[x, hi], [x, close]], ops); 
-                        r.shapeRenderer.draw(ctx, [[x, open], [x, low]], ops); 
-                        o = {};
-                        b = close;
-                        h = open - close;
-                        // if color specified, use it
-                        if (r.fillUpBody) {
-                            o.fillRect = true;
-                        }
-                        else {
-                            o.strokeRect = true;
-                            w = w - this.lineWidth;
-                            a = x - w/2;
-                        }
-                        if (r.upBodyColor) {
-                            o.color = r.upBodyColor;
-                            o.fillStyle = r.upBodyColor;
-                        }
-                        points = [a, b, w, h];
-                    }
-                    // down
-                    else if (close >  open) {
-                        // draw wick
-                        if (r.wickColor) {
-                            o.color = r.wickColor;
-                        }
-                        else if (r.downBodyColor) {
-                            o.color = r.downBodyColor;
-                        }
-                        ops = $.extend(true, {}, opts, o);
-                        r.shapeRenderer.draw(ctx, [[x, hi], [x, open]], ops); 
-                        r.shapeRenderer.draw(ctx, [[x, close], [x, low]], ops);
-                         
-                        o = {};
-                        
-                        b = open;
-                        h = close - open;
-                        // if color specified, use it
-                        if (r.fillDownBody) {
-                            o.fillRect = true;
-                        }
-                        else {
-                            o.strokeRect = true;
-                            w = w - this.lineWidth;
-                            a = x - w/2;
-                        }
-                        if (r.downBodyColor) {
-                            o.color = r.downBodyColor;
-                            o.fillStyle = r.downBodyColor;
-                        }
-                        points = [a, b, w, h];
-                    }
-                    // even, open = close
-                    else  {
-                        // draw wick
-                        if (r.wickColor) {
-                            o.color = r.wickColor;
-                        }
-                        ops = $.extend(true, {}, opts, o);
-                        r.shapeRenderer.draw(ctx, [[x, hi], [x, low]], ops); 
-                        o = {};
-                        o.fillRect = false;
-                        o.strokeRect = false;
-                        a = [x - w/2, open];
-                        b = [x + w/2, close];
-                        w = null;
-                        h = null;
-                        points = [a, b];
-                    }
-                    ops = $.extend(true, {}, opts, o);
-                    r.shapeRenderer.draw(ctx, points, ops);
-                }
-                else {
-                    prevColor = opts.color;
-                    if (r.openColor) {
-                        opts.color = r.openColor;
-                    }
-                    // draw open tick
-                    if (!r.hlc) {
-                        r.shapeRenderer.draw(ctx, [[x-r._tickLength, open], [x, open]], opts);    
-                    }
-                    opts.color = prevColor;
-                    // draw wick
-                    if (r.wickColor) {
-                        opts.color = r.wickColor;
-                    }
-                    r.shapeRenderer.draw(ctx, [[x, hi], [x, low]], opts); 
-                    opts.color  = prevColor;
-                    // draw close tick
-                    if (r.closeColor) {
-                        opts.color = r.closeColor;
-                    }
-                    r.shapeRenderer.draw(ctx, [[x, close], [x+r._tickLength, close]], opts); 
-                    opts.color = prevColor;
-                }
-            }
-        }
-        
-        ctx.restore();
-    };  
-    
-    $.jqplot.OHLCRenderer.prototype.drawShadow = function(ctx, gd, options) {
-        // This is a no-op, shadows drawn with lines.
-    };
-    
-    // called with scope of plot.
-    $.jqplot.OHLCRenderer.checkOptions = function(target, data, options) {
-        // provide some sensible highlighter options by default
-        // These aren't good for hlc, only for ohlc or candlestick
-        if (!options.highlighter) {
-            options.highlighter = {
-                showMarker:false,
-                tooltipAxes: 'y',
-                yvalues: 4,
-                formatString:'<table class="jqplot-highlighter"><tr><td>date:</td><td>%s</td></tr><tr><td>open:</td><td>%s</td></tr><tr><td>hi:</td><td>%s</td></tr><tr><td>low:</td><td>%s</td></tr><tr><td>close:</td><td>%s</td></tr></table>'
-            };
-        }
-    };
-    
-    //$.jqplot.preInitHooks.push($.jqplot.OHLCRenderer.checkOptions);
-    
-})(jQuery);    
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ohlcRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ohlcRenderer.min.js
deleted file mode 100644
index 75e54cd..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.ohlcRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.OHLCRenderer=function(){a.jqplot.LineRenderer.call(this);this.candleStick=false;this.tickLength="auto";this.bodyWidth="auto";this.openColor=null;this.closeColor=null;this.wickColor=null;this.fillUpBody=false;this.fillDownBody=true;this.upBodyColor=null;this.downBodyColor=null;this.hlc=false;this.lineWidth=1.5;this._tickLength;this._bodyWidth};a.jqplot.OHLCRenderer.prototype=new a.jqplot.LineRenderer();a.jqplot.OHLCRenderer.prototype.constructor=a.jqplot.OHLCRenderer;a.jqplot.OHLCRenderer.prototype.init=function(e){e=e||{};this.lineWidth=e.lineWidth||1.5;a.jqplot.LineRenderer.prototype.init.call(this,e);this._type="ohlc";var b=this._yaxis._dataBounds;var f=this._plotData;if(f[0].length<5){this.renderer.hlc=true;for(var c=0;c<f.length;c++){if(f[c][2]<b.min||b.min==null){b.min=f[c][2]}if(f[c][1]>b.max||b.max==null){b.max=f[c][1]}}}else{for(var c=0;c<f.length;c++){if(f[c][3]<b.min||b.min==null){b.min=f[c][3]}if(f[c][2]>b.max||b.max==null){b.max=f[c][2]}}}};a.jqplot.OHLCRenderer.prototype.draw=function(A,N,j){var J=this.data;var v=this._xaxis.min;var z=this._xaxis.max;var l=0;var K=J.length;var p=this._xaxis.series_u2p;var G=this._yaxis.series_u2p;var D,E,f,M,F,n,O,C;var y;var u=this.renderer;var s=(j!=undefined)?j:{};var k=(s.shadow!=undefined)?s.shadow:this.shadow;var B=(s.fill!=undefined)?s.fill:this.fill;var c=(s.fillAndStroke!=undefined)?s.fillAndStroke:this.fillAndStroke;u.bodyWidth=(s.bodyWidth!=undefined)?s.bodyWidth:u.bodyWidth;u.tickLength=(s.tickLength!=undefined)?s.tickLength:u.tickLength;A.save();if(this.show){var m,q,g,Q,t;for(var D=0;D<J.length;D++){if(J[D][0]<v){l=D}else{if(J[D][0]<z){K=D+1}}}var I=this.gridData[K-1][0]-this.gridData[l][0];var L=K-l;try{var P=Math.abs(this._xaxis.series_u2p(parseInt(this._xaxis._intervalStats[0].sortedIntervals[0].interval))-this._xaxis.series_u2p(0))}catch(H){var P=I/L}if(u.candleStick){if(typeof(u.bodyWidth)=="number"){u._bodyWidth=u.bodyWidth}else{u._bodyWidth=Math.min(20,P/1.75)}}else{if(typeof(u.tickLength)=="number"){u._tickLength=u.tickLength}else{u._tickLength=Math.min(10,P/3.5)}}for(var D=l;D<K;D++){m=p(J[D][0]);if(u.hlc){q=null;g=G(J[D][1]);Q=G(J[D][2]);t=G(J[D][3])}else{q=G(J[D][1]);g=G(J[D][2]);Q=G(J[D][3]);t=G(J[D][4])}y={};if(u.candleStick&&!u.hlc){n=u._bodyWidth;O=m-n/2;if(t<q){if(u.wickColor){y.color=u.wickColor}else{if(u.downBodyColor){y.color=u.upBodyColor}}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,[[m,g],[m,t]],f);u.shapeRenderer.draw(A,[[m,q],[m,Q]],f);y={};M=t;F=q-t;if(u.fillUpBody){y.fillRect=true}else{y.strokeRect=true;n=n-this.lineWidth;O=m-n/2}if(u.upBodyColor){y.color=u.upBodyColor;y.fillStyle=u.upBodyColor}C=[O,M,n,F]}else{if(t>q){if(u.wickColor){y.color=u.wickColor}else{if(u.downBodyColor){y.color=u.downBodyColor}}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,[[m,g],[m,q]],f);u.shapeRenderer.draw(A,[[m,t],[m,Q]],f);y={};M=q;F=t-q;if(u.fillDownBody){y.fillRect=true}else{y.strokeRect=true;n=n-this.lineWidth;O=m-n/2}if(u.downBodyColor){y.color=u.downBodyColor;y.fillStyle=u.downBodyColor}C=[O,M,n,F]}else{if(u.wickColor){y.color=u.wickColor}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,[[m,g],[m,Q]],f);y={};y.fillRect=false;y.strokeRect=false;O=[m-n/2,q];M=[m+n/2,t];n=null;F=null;C=[O,M]}}f=a.extend(true,{},s,y);u.shapeRenderer.draw(A,C,f)}else{E=s.color;if(u.openColor){s.color=u.openColor}if(!u.hlc){u.shapeRenderer.draw(A,[[m-u._tickLength,q],[m,q]],s)}s.color=E;if(u.wickColor){s.color=u.wickColor}u.shapeRenderer.draw(A,[[m,g],[m,Q]],s);s.color=E;if(u.closeColor){s.color=u.closeColor}u.shapeRenderer.draw(A,[[m,t],[m+u._tickLength,t]],s);s.color=E}}}A.restore()};a.jqplot.OHLCRenderer.prototype.drawShadow=function(b,d,c){};a.jqplot.OHLCRenderer.checkOptions=function(d,c,b){if(!b.highlighter){b.highlighter={showMarker:false,tooltipAxes:"y",yvalues:4,formatString:'<table class="jqplot-highlighter"><tr><td>date:</td><td>%s</td></tr><tr><td>open:</td><td>%s</td></tr><tr><td>hi:</td><td>%s</td></tr><tr><td>low:</td><td>%s</td></tr><tr><td>close:</td><td>%s</td></tr></table>'}}}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pieRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pieRenderer.js
deleted file mode 100644
index 3a2c823..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pieRenderer.js
+++ /dev/null
@@ -1,899 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    /**
-     * Class: $.jqplot.PieRenderer
-     * Plugin renderer to draw a pie chart.
-     * x values, if present, will be used as slice labels.
-     * y values give slice size.
-     * 
-     * To use this renderer, you need to include the 
-     * pie renderer plugin, for example:
-     * 
-     * > <script type="text/javascript" src="plugins/jqplot.pieRenderer.js"></script>
-     * 
-     * Properties described here are passed into the $.jqplot function
-     * as options on the series renderer.  For example:
-     * 
-     * > plot2 = $.jqplot('chart2', [s1, s2], {
-     * >     seriesDefaults: {
-     * >         renderer:$.jqplot.PieRenderer,
-     * >         rendererOptions:{
-     * >              sliceMargin: 2,
-     * >              startAngle: -90
-     * >          }
-     * >      }
-     * > });
-     * 
-     * A pie plot will trigger events on the plot target
-     * according to user interaction.  All events return the event object,
-     * the series index, the point (slice) index, and the point data for 
-     * the appropriate slice.
-     * 
-     * 'jqplotDataMouseOver' - triggered when user mouseing over a slice.
-     * 'jqplotDataHighlight' - triggered the first time user mouses over a slice,
-     * if highlighting is enabled.
-     * 'jqplotDataUnhighlight' - triggered when a user moves the mouse out of
-     * a highlighted slice.
-     * 'jqplotDataClick' - triggered when the user clicks on a slice.
-     * 'jqplotDataRightClick' - tiggered when the user right clicks on a slice if
-     * the "captureRightClick" option is set to true on the plot.
-     */
-    $.jqplot.PieRenderer = function(){
-        $.jqplot.LineRenderer.call(this);
-    };
-    
-    $.jqplot.PieRenderer.prototype = new $.jqplot.LineRenderer();
-    $.jqplot.PieRenderer.prototype.constructor = $.jqplot.PieRenderer;
-    
-    // called with scope of a series
-    $.jqplot.PieRenderer.prototype.init = function(options, plot) {
-        // Group: Properties
-        //
-        // prop: diameter
-        // Outer diameter of the pie, auto computed by default
-        this.diameter = null;
-        // prop: padding
-        // padding between the pie and plot edges, legend, etc.
-        this.padding = 20;
-        // prop: sliceMargin
-        // angular spacing between pie slices in degrees.
-        this.sliceMargin = 0;
-        // prop: fill
-        // true or false, wether to fil the slices.
-        this.fill = true;
-        // prop: shadowOffset
-        // offset of the shadow from the slice and offset of 
-        // each succesive stroke of the shadow from the last.
-        this.shadowOffset = 2;
-        // prop: shadowAlpha
-        // transparency of the shadow (0 = transparent, 1 = opaque)
-        this.shadowAlpha = 0.07;
-        // prop: shadowDepth
-        // number of strokes to apply to the shadow, 
-        // each stroke offset shadowOffset from the last.
-        this.shadowDepth = 5;
-        // prop: highlightMouseOver
-        // True to highlight slice when moused over.
-        // This must be false to enable highlightMouseDown to highlight when clicking on a slice.
-        this.highlightMouseOver = true;
-        // prop: highlightMouseDown
-        // True to highlight when a mouse button is pressed over a slice.
-        // This will be disabled if highlightMouseOver is true.
-        this.highlightMouseDown = false;
-        // prop: highlightColors
-        // an array of colors to use when highlighting a slice.
-        this.highlightColors = [];
-        // prop: dataLabels
-        // Either 'label', 'value', 'percent' or an array of labels to place on the pie slices.
-        // Defaults to percentage of each pie slice.
-        this.dataLabels = 'percent';
-        // prop: showDataLabels
-        // true to show data labels on slices.
-        this.showDataLabels = false;
-        // prop: dataLabelFormatString
-        // Format string for data labels.  If none, '%s' is used for "label" and for arrays, '%d' for value and '%d%%' for percentage.
-        this.dataLabelFormatString = null;
-        // prop: dataLabelThreshold
-        // Threshhold in percentage (0-100) of pie area, below which no label will be displayed.
-        // This applies to all label types, not just to percentage labels.
-        this.dataLabelThreshold = 3;
-        // prop: dataLabelPositionFactor
-        // A Multiplier (0-1) of the pie radius which controls position of label on slice.
-        // Increasing will slide label toward edge of pie, decreasing will slide label toward center of pie.
-        this.dataLabelPositionFactor = 0.52;
-        // prop: dataLabelNudge
-        // Number of pixels to slide the label away from (+) or toward (-) the center of the pie.
-        this.dataLabelNudge = 2;
-        // prop: dataLabelCenterOn
-        // True to center the data label at its position.
-        // False to set the inside facing edge of the label at its position.
-        this.dataLabelCenterOn = true;
-        // prop: startAngle
-        // Angle to start drawing pie in degrees.  
-        // According to orientation of canvas coordinate system:
-        // 0 = on the positive x axis
-        // -90 = on the positive y axis.
-        // 90 = on the negaive y axis.
-        // 180 or - 180 = on the negative x axis.
-        this.startAngle = 0;
-        this.tickRenderer = $.jqplot.PieTickRenderer;
-        // Used as check for conditions where pie shouldn't be drawn.
-        this._drawData = true;
-        this._type = 'pie';
-        
-        // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
-        if (options.highlightMouseDown && options.highlightMouseOver == null) {
-            options.highlightMouseOver = false;
-        }
-        
-        $.extend(true, this, options);
-
-        if (this.sliceMargin < 0) {
-            this.sliceMargin = 0;
-        }
-
-        this._diameter = null;
-        this._radius = null;
-        // array of [start,end] angles arrays, one for each slice.  In radians.
-        this._sliceAngles = [];
-        // index of the currenty highlighted point, if any
-        this._highlightedPoint = null;
-        
-        // set highlight colors if none provided
-        if (this.highlightColors.length == 0) {
-            for (var i=0; i<this.seriesColors.length; i++){
-                var rgba = $.jqplot.getColorComponents(this.seriesColors[i]);
-                var newrgb = [rgba[0], rgba[1], rgba[2]];
-                var sum = newrgb[0] + newrgb[1] + newrgb[2];
-                for (var j=0; j<3; j++) {
-                    // when darkening, lowest color component can be is 60.
-                    newrgb[j] = (sum > 570) ?  newrgb[j] * 0.8 : newrgb[j] + 0.3 * (255 - newrgb[j]);
-                    newrgb[j] = parseInt(newrgb[j], 10);
-                }
-                this.highlightColors.push('rgb('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+')');
-            }
-        }
-        
-        this.highlightColorGenerator = new $.jqplot.ColorGenerator(this.highlightColors);
-        
-        plot.postParseOptionsHooks.addOnce(postParseOptions);
-        plot.postInitHooks.addOnce(postInit);
-        plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
-        plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
-        plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
-        plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
-        plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
-        plot.postDrawHooks.addOnce(postPlotDraw);
-    };
-    
-    $.jqplot.PieRenderer.prototype.setGridData = function(plot) {
-        // set gridData property.  This will hold angle in radians of each data point.
-        var stack = [];
-        var td = [];
-        var sa = this.startAngle/180*Math.PI;
-        var tot = 0;
-        // don't know if we have any valid data yet, so set plot to not draw.
-        this._drawData = false;
-        for (var i=0; i<this.data.length; i++){
-            if (this.data[i][1] != 0) {
-                // we have data, O.K. to draw.
-                this._drawData = true;
-            }
-            stack.push(this.data[i][1]);
-            td.push([this.data[i][0]]);
-            if (i>0) {
-                stack[i] += stack[i-1];
-            }
-            tot += this.data[i][1];
-        }
-        var fact = Math.PI*2/stack[stack.length - 1];
-        
-        for (var i=0; i<stack.length; i++) {
-            td[i][1] = stack[i] * fact;
-            td[i][2] = this.data[i][1]/tot;
-        }
-        this.gridData = td;
-    };
-    
-    $.jqplot.PieRenderer.prototype.makeGridData = function(data, plot) {
-        var stack = [];
-        var td = [];
-        var tot = 0;
-        var sa = this.startAngle/180*Math.PI;
-        // don't know if we have any valid data yet, so set plot to not draw.
-        this._drawData = false;
-        for (var i=0; i<data.length; i++){
-            if (this.data[i][1] != 0) {
-                // we have data, O.K. to draw.
-                this._drawData = true;
-            }
-            stack.push(data[i][1]);
-            td.push([data[i][0]]);
-            if (i>0) {
-                stack[i] += stack[i-1];
-            }
-            tot += data[i][1];
-        }
-        var fact = Math.PI*2/stack[stack.length - 1];
-        
-        for (var i=0; i<stack.length; i++) {
-            td[i][1] = stack[i] * fact;
-            td[i][2] = data[i][1]/tot;
-        }
-        return td;
-    };
-
-    function calcRadiusAdjustment(ang) {
-        return Math.sin((ang - (ang-Math.PI) / 8 / Math.PI )/2.0);
-    }
-
-    function calcRPrime(ang1, ang2, sliceMargin, fill, lineWidth) {
-        var rprime = 0;
-        var ang = ang2 - ang1;
-        var absang = Math.abs(ang);
-        var sm = sliceMargin;
-        if (fill == false) {
-            sm += lineWidth;
-        }
-
-        if (sm > 0 && absang > 0.01 && absang < 6.282) {
-            rprime = parseFloat(sm) / 2.0 / calcRadiusAdjustment(ang);
-        }
-
-        return rprime;
-    }
-    
-    $.jqplot.PieRenderer.prototype.drawSlice = function (ctx, ang1, ang2, color, isShadow) {
-        if (this._drawData) {
-            var r = this._radius;
-            var fill = this.fill;
-            var lineWidth = this.lineWidth;
-            var sm = this.sliceMargin;
-            if (this.fill == false) {
-                sm += this.lineWidth;
-            }
-            ctx.save();
-            ctx.translate(this._center[0], this._center[1]);
-            
-            var rprime = calcRPrime(ang1, ang2, this.sliceMargin, this.fill, this.lineWidth);
-
-            var transx = rprime * Math.cos((ang1 + ang2) / 2.0);
-            var transy = rprime * Math.sin((ang1 + ang2) / 2.0);
-
-            if ((ang2 - ang1) <= Math.PI) {
-                r -= rprime;  
-            }
-            else {
-                r += rprime;
-            }
-
-            ctx.translate(transx, transy);
-            
-            if (isShadow) {
-                for (var i=0, l=this.shadowDepth; i<l; i++) {
-                    ctx.save();
-                    ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
-                    doDraw(r);
-                }
-                for (var i=0, l=this.shadowDepth; i<l; i++) {
-                    ctx.restore();
-                }
-            }
-    
-            else {
-                doDraw(r);
-            }
-            ctx.restore();
-        }
-    
-        function doDraw (rad) {
-            // Fix for IE and Chrome that can't seem to draw circles correctly.
-            // ang2 should always be <= 2 pi since that is the way the data is converted.
-            // 2Pi = 6.2831853, Pi = 3.1415927
-             if (ang2 > 6.282 + this.startAngle) {
-                ang2 = 6.282 + this.startAngle;
-                if (ang1 > ang2) {
-                    ang1 = 6.281 + this.startAngle;
-                }
-            }
-            // Fix for IE, where it can't seem to handle 0 degree angles.  Also avoids
-            // ugly line on unfilled pies.
-            if (ang1 >= ang2) {
-                return;
-            }            
-        
-            ctx.beginPath();  
-            ctx.fillStyle = color;
-            ctx.strokeStyle = color;
-            ctx.lineWidth = lineWidth;
-            ctx.arc(0, 0, rad, ang1, ang2, false);
-            ctx.lineTo(0,0);
-            ctx.closePath();
-        
-            if (fill) {
-                ctx.fill();
-            }
-            else {
-                ctx.stroke();
-            }
-        }
-    };
-    
-    // called with scope of series
-    $.jqplot.PieRenderer.prototype.draw = function (ctx, gd, options, plot) {
-        var i;
-        var opts = (options != undefined) ? options : {};
-        // offset and direction of offset due to legend placement
-        var offx = 0;
-        var offy = 0;
-        var trans = 1;
-        var colorGenerator = new $.jqplot.ColorGenerator(this.seriesColors);
-        if (options.legendInfo && options.legendInfo.placement == 'insideGrid') {
-            var li = options.legendInfo;
-            switch (li.location) {
-                case 'nw':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'w':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'sw':
-                    offx = li.width + li.xoffset;
-                    break;
-                case 'ne':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'e':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'se':
-                    offx = li.width + li.xoffset;
-                    trans = -1;
-                    break;
-                case 'n':
-                    offy = li.height + li.yoffset;
-                    break;
-                case 's':
-                    offy = li.height + li.yoffset;
-                    trans = -1;
-                    break;
-                default:
-                    break;
-            }
-        }
-        
-        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
-        var fill = (opts.fill != undefined) ? opts.fill : this.fill;
-        var cw = ctx.canvas.width;
-        var ch = ctx.canvas.height;
-        var w = cw - offx - 2 * this.padding;
-        var h = ch - offy - 2 * this.padding;
-        var mindim = Math.min(w,h);
-        var d = mindim;
-        
-        // Fixes issue #272.  Thanks hugwijst!
-        // reset slice angles array.
-        this._sliceAngles = [];
-
-        var sm = this.sliceMargin;
-        if (this.fill == false) {
-            sm += this.lineWidth;
-        }
-        
-        var rprime;
-        var maxrprime = 0;
-
-        var ang, ang1, ang2, shadowColor;
-        var sa = this.startAngle / 180 * Math.PI;
-
-        // have to pre-draw shadows, so loop throgh here and calculate some values also.
-        for (var i=0, l=gd.length; i<l; i++) {
-            ang1 = (i == 0) ? sa : gd[i-1][1] + sa;
-            ang2 = gd[i][1] + sa;
-
-            this._sliceAngles.push([ang1, ang2]);
-
-            rprime = calcRPrime(ang1, ang2, this.sliceMargin, this.fill, this.lineWidth);
-
-            if (Math.abs(ang2-ang1) > Math.PI) {
-                maxrprime = Math.max(rprime, maxrprime);  
-            }
-        }
-
-        if (this.diameter != null && this.diameter > 0) {
-            this._diameter = this.diameter - 2*maxrprime;
-        }
-        else {
-            this._diameter = d - 2*maxrprime;
-        }
-
-        // Need to check for undersized pie.  This can happen if
-        // plot area too small and legend is too big.
-        if (this._diameter < 6) {
-            $.jqplot.log('Diameter of pie too small, not rendering.');
-            return;
-        }
-
-        var r = this._radius = this._diameter/2;
-
-        this._center = [(cw - trans * offx)/2 + trans * offx + maxrprime * Math.cos(sa), (ch - trans*offy)/2 + trans * offy + maxrprime * Math.sin(sa)];
-
-        if (this.shadow) {
-            for (var i=0, l=gd.length; i<l; i++) {
-                shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')';
-                this.renderer.drawSlice.call (this, ctx, this._sliceAngles[i][0], this._sliceAngles[i][1], shadowColor, true);
-            }
-        }
-        
-        for (var i=0; i<gd.length; i++) {
-                      
-            this.renderer.drawSlice.call (this, ctx, this._sliceAngles[i][0], this._sliceAngles[i][1], colorGenerator.next(), false);
-        
-            if (this.showDataLabels && gd[i][2]*100 >= this.dataLabelThreshold) {
-                var fstr, avgang = (this._sliceAngles[i][0] + this._sliceAngles[i][1])/2, label;
-            
-                if (this.dataLabels == 'label') {
-                    fstr = this.dataLabelFormatString || '%s';
-                    label = $.jqplot.sprintf(fstr, gd[i][0]);
-                }
-                else if (this.dataLabels == 'value') {
-                    fstr = this.dataLabelFormatString || '%d';
-                    label = $.jqplot.sprintf(fstr, this.data[i][1]);
-                }
-                else if (this.dataLabels == 'percent') {
-                    fstr = this.dataLabelFormatString || '%d%%';
-                    label = $.jqplot.sprintf(fstr, gd[i][2]*100);
-                }
-                else if (this.dataLabels.constructor == Array) {
-                    fstr = this.dataLabelFormatString || '%s';
-                    label = $.jqplot.sprintf(fstr, this.dataLabels[i]);
-                }
-            
-                var fact = (this._radius ) * this.dataLabelPositionFactor + this.sliceMargin + this.dataLabelNudge;
-            
-                var x = this._center[0] + Math.cos(avgang) * fact + this.canvas._offsets.left;
-                var y = this._center[1] + Math.sin(avgang) * fact + this.canvas._offsets.top;
-            
-                var labelelem = $('<div class="jqplot-pie-series jqplot-data-label" style="position:absolute;">' + label + '</div>').insertBefore(plot.eventCanvas._elem);
-                if (this.dataLabelCenterOn) {
-                    x -= labelelem.width()/2;
-                    y -= labelelem.height()/2;
-                }
-                else {
-                    x -= labelelem.width() * Math.sin(avgang/2);
-                    y -= labelelem.height()/2;
-                }
-                x = Math.round(x);
-                y = Math.round(y);
-                labelelem.css({left: x, top: y});
-            }
-        }            
-    };
-    
-    $.jqplot.PieAxisRenderer = function() {
-        $.jqplot.LinearAxisRenderer.call(this);
-    };
-    
-    $.jqplot.PieAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
-    $.jqplot.PieAxisRenderer.prototype.constructor = $.jqplot.PieAxisRenderer;
-        
-    
-    // There are no traditional axes on a pie chart.  We just need to provide
-    // dummy objects with properties so the plot will render.
-    // called with scope of axis object.
-    $.jqplot.PieAxisRenderer.prototype.init = function(options){
-        //
-        this.tickRenderer = $.jqplot.PieTickRenderer;
-        $.extend(true, this, options);
-        // I don't think I'm going to need _dataBounds here.
-        // have to go Axis scaling in a way to fit chart onto plot area
-        // and provide u2p and p2u functionality for mouse cursor, etc.
-        // for convienence set _dataBounds to 0 and 100 and
-        // set min/max to 0 and 100.
-        this._dataBounds = {min:0, max:100};
-        this.min = 0;
-        this.max = 100;
-        this.showTicks = false;
-        this.ticks = [];
-        this.showMark = false;
-        this.show = false; 
-    };
-    
-    
-    
-    
-    $.jqplot.PieLegendRenderer = function(){
-        $.jqplot.TableLegendRenderer.call(this);
-    };
-    
-    $.jqplot.PieLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
-    $.jqplot.PieLegendRenderer.prototype.constructor = $.jqplot.PieLegendRenderer;
-    
-    /**
-     * Class: $.jqplot.PieLegendRenderer
-     * Legend Renderer specific to pie plots.  Set by default
-     * when user creates a pie plot.
-     */
-    $.jqplot.PieLegendRenderer.prototype.init = function(options) {
-        // Group: Properties
-        //
-        // prop: numberRows
-        // Maximum number of rows in the legend.  0 or null for unlimited.
-        this.numberRows = null;
-        // prop: numberColumns
-        // Maximum number of columns in the legend.  0 or null for unlimited.
-        this.numberColumns = null;
-        $.extend(true, this, options);
-    };
-    
-    // called with context of legend
-    $.jqplot.PieLegendRenderer.prototype.draw = function() {
-        var legend = this;
-        if (this.show) {
-            var series = this._series;
-
-
-            this._elem = $(document.createElement('table'));
-            this._elem.addClass('jqplot-table-legend');
-
-            var ss = {position:'absolute'};
-            if (this.background) {
-                ss['background'] = this.background;
-            }
-            if (this.border) {
-                ss['border'] = this.border;
-            }
-            if (this.fontSize) {
-                ss['fontSize'] = this.fontSize;
-            }
-            if (this.fontFamily) {
-                ss['fontFamily'] = this.fontFamily;
-            }
-            if (this.textColor) {
-                ss['textColor'] = this.textColor;
-            }
-            if (this.marginTop != null) {
-                ss['marginTop'] = this.marginTop;
-            }
-            if (this.marginBottom != null) {
-                ss['marginBottom'] = this.marginBottom;
-            }
-            if (this.marginLeft != null) {
-                ss['marginLeft'] = this.marginLeft;
-            }
-            if (this.marginRight != null) {
-                ss['marginRight'] = this.marginRight;
-            }
-
-            this._elem.css(ss);
-
-            // Pie charts legends don't go by number of series, but by number of data points
-            // in the series.  Refactor things here for that.
-            
-            var pad = false, 
-                reverse = false,
-                nr, 
-                nc;
-            var s = series[0];
-            var colorGenerator = new $.jqplot.ColorGenerator(s.seriesColors);
-            
-            if (s.show) {
-                var pd = s.data;
-                if (this.numberRows) {
-                    nr = this.numberRows;
-                    if (!this.numberColumns){
-                        nc = Math.ceil(pd.length/nr);
-                    }
-                    else{
-                        nc = this.numberColumns;
-                    }
-                }
-                else if (this.numberColumns) {
-                    nc = this.numberColumns;
-                    nr = Math.ceil(pd.length/this.numberColumns);
-                }
-                else {
-                    nr = pd.length;
-                    nc = 1;
-                }
-                
-                var i, j;
-                var tr, td1, td2; 
-                var lt, rs, color;
-                var idx = 0; 
-                var div0, div1;   
-                
-                for (i=0; i<nr; i++) {
-                    tr = $(document.createElement('tr'));
-                    tr.addClass('jqplot-table-legend');
-                    
-                    if (reverse){
-                        tr.prependTo(this._elem);
-                    }
-                    
-                    else{
-                        tr.appendTo(this._elem);
-                    }
-                    
-                    for (j=0; j<nc; j++) {
-                        if (idx < pd.length){
-                            lt = this.labels[idx] || pd[idx][0].toString();
-                            color = colorGenerator.next();
-                            if (!reverse){
-                                if (i>0){
-                                    pad = true;
-                                }
-                                else{
-                                    pad = false;
-                                }
-                            }
-                            else{
-                                if (i == nr -1){
-                                    pad = false;
-                                }
-                                else{
-                                    pad = true;
-                                }
-                            }
-                            rs = (pad) ? this.rowSpacing : '0';
-
-
-
-                            td1 = $(document.createElement('td'));
-                            td1.addClass('jqplot-table-legend jqplot-table-legend-swatch');
-                            td1.css({textAlign: 'center', paddingTop: rs});
-
-                            div0 = $(document.createElement('div'));
-                            div0.addClass('jqplot-table-legend-swatch-outline');
-                            div1 = $(document.createElement('div'));
-                            div1.addClass('jqplot-table-legend-swatch');
-                            div1.css({backgroundColor: color, borderColor: color});
-                            td1.append(div0.append(div1));
-
-                            td2 = $(document.createElement('td'));
-                            td2.addClass('jqplot-table-legend jqplot-table-legend-label');
-                            td2.css('paddingTop', rs);
-
-                            if (this.escapeHtml){
-                                td2.text(lt);
-                            }
-                            else {
-                                td2.html(lt);
-                            }
-                            if (reverse) {
-                                td2.prependTo(tr);
-                                td1.prependTo(tr);
-                            }
-                            else {
-                                td1.appendTo(tr);
-                                td2.appendTo(tr);
-                            }
-                            pad = true;
-                        }
-                        idx++;
-                    }   
-                }
-            }
-        }
-        return this._elem;                
-    };
-    
-    $.jqplot.PieRenderer.prototype.handleMove = function(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            plot.target.trigger('jqplotDataMouseOver', ins);
-            if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                plot.target.trigger('jqplotDataHighlight', ins);
-                highlight (plot, ins[0], ins[1]);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    };
-    
-    
-    // this.eventCanvas._elem.bind($.jqplot.eventListenerHooks[i][0], {plot:this}, $.jqplot.eventListenerHooks[i][1]);
-    
-    // setup default renderers for axes and legend so user doesn't have to
-    // called with scope of plot
-    function preInit(target, data, options) {
-        options = options || {};
-        options.axesDefaults = options.axesDefaults || {};
-        options.legend = options.legend || {};
-        options.seriesDefaults = options.seriesDefaults || {};
-        // only set these if there is a pie series
-        var setopts = false;
-        if (options.seriesDefaults.renderer == $.jqplot.PieRenderer) {
-            setopts = true;
-        }
-        else if (options.series) {
-            for (var i=0; i < options.series.length; i++) {
-                if (options.series[i].renderer == $.jqplot.PieRenderer) {
-                    setopts = true;
-                }
-            }
-        }
-        
-        if (setopts) {
-            options.axesDefaults.renderer = $.jqplot.PieAxisRenderer;
-            options.legend.renderer = $.jqplot.PieLegendRenderer;
-            options.legend.preDraw = true;
-            options.seriesDefaults.pointLabels = {show: false};
-        }
-    }
-    
-    function postInit(target, data, options) {
-        for (var i=0; i<this.series.length; i++) {
-            if (this.series[i].renderer.constructor == $.jqplot.PieRenderer) {
-                // don't allow mouseover and mousedown at same time.
-                if (this.series[i].highlightMouseOver) {
-                    this.series[i].highlightMouseDown = false;
-                }
-            }
-        }
-    }
-    
-    // called with scope of plot
-    function postParseOptions(options) {
-        for (var i=0; i<this.series.length; i++) {
-            this.series[i].seriesColors = this.seriesColors;
-            this.series[i].colorGenerator = $.jqplot.colorGenerator;
-        }
-    }
-    
-    function highlight (plot, sidx, pidx) {
-        var s = plot.series[sidx];
-        var canvas = plot.plugins.pieRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        s._highlightedPoint = pidx;
-        plot.plugins.pieRenderer.highlightedSeriesIndex = sidx;
-        s.renderer.drawSlice.call(s, canvas._ctx, s._sliceAngles[pidx][0], s._sliceAngles[pidx][1], s.highlightColorGenerator.get(pidx), false);
-    }
-    
-    function unhighlight (plot) {
-        var canvas = plot.plugins.pieRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        for (var i=0; i<plot.series.length; i++) {
-            plot.series[i]._highlightedPoint = null;
-        }
-        plot.plugins.pieRenderer.highlightedSeriesIndex = null;
-        plot.target.trigger('jqplotDataUnhighlight');
-    }
- 
-    function handleMove(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt1 = jQuery.Event('jqplotDataMouseOver');
-            evt1.pageX = ev.pageX;
-            evt1.pageY = ev.pageY;
-            plot.target.trigger(evt1, ins);
-            if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, ins[0], ins[1]);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    } 
-    
-    function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.pieRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, ins[0], ins[1]);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    }
-    
-    function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
-        var idx = plot.plugins.pieRenderer.highlightedSeriesIndex;
-        if (idx != null && plot.series[idx].highlightMouseDown) {
-            unhighlight(plot);
-        }
-    }
-    
-    function handleClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt = jQuery.Event('jqplotDataClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }
-    
-    function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var idx = plot.plugins.pieRenderer.highlightedSeriesIndex;
-            if (idx != null && plot.series[idx].highlightMouseDown) {
-                unhighlight(plot);
-            }
-            var evt = jQuery.Event('jqplotDataRightClick');
-            evt.pageX = ev.pageX;
-            evt.pageY = ev.pageY;
-            plot.target.trigger(evt, ins);
-        }
-    }    
-    
-    // called within context of plot
-    // create a canvas which we can draw on.
-    // insert it before the eventCanvas, so eventCanvas will still capture events.
-    function postPlotDraw() {
-        // Memory Leaks patch    
-        if (this.plugins.pieRenderer && this.plugins.pieRenderer.highlightCanvas) {
-            this.plugins.pieRenderer.highlightCanvas.resetCanvas();
-            this.plugins.pieRenderer.highlightCanvas = null;
-        }
-
-        this.plugins.pieRenderer = {highlightedSeriesIndex:null};
-        this.plugins.pieRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
-        
-        // do we have any data labels?  if so, put highlight canvas before those
-        var labels = $(this.targetId+' .jqplot-data-label');
-        if (labels.length) {
-            $(labels[0]).before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pieRenderer-highlight-canvas', this._plotDimensions, this));
-        }
-        // else put highlight canvas before event canvas.
-        else {
-            this.eventCanvas._elem.before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pieRenderer-highlight-canvas', this._plotDimensions, this));
-        }
-        
-        var hctx = this.plugins.pieRenderer.highlightCanvas.setContext();
-        this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
-    }
-    
-    $.jqplot.preInitHooks.push(preInit);
-    
-    $.jqplot.PieTickRenderer = function() {
-        $.jqplot.AxisTickRenderer.call(this);
-    };
-    
-    $.jqplot.PieTickRenderer.prototype = new $.jqplot.AxisTickRenderer();
-    $.jqplot.PieTickRenderer.prototype.constructor = $.jqplot.PieTickRenderer;
-    
-})(jQuery);
-    
-    
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pieRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pieRenderer.min.js
deleted file mode 100644
index 7932d72..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pieRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(e){e.jqplot.PieRenderer=function(){e.jqplot.LineRenderer.call(this)};e.jqplot.PieRenderer.prototype=new e.jqplot.LineRenderer();e.jqplot.PieRenderer.prototype.constructor=e.jqplot.PieRenderer;e.jqplot.PieRenderer.prototype.init=function(q,u){this.diameter=null;this.padding=20;this.sliceMargin=0;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.dataLabels="percent";this.showDataLabels=false;this.dataLabelFormatString=null;this.dataLabelThreshold=3;this.dataLabelPositionFactor=0.52;this.dataLabelNudge=2;this.dataLabelCenterOn=true;this.startAngle=0;this.tickRenderer=e.jqplot.PieTickRenderer;this._drawData=true;this._type="pie";if(q.highlightMouseDown&&q.highlightMouseOver==null){q.highlightMouseOver=false}e.extend(true,this,q);if(this.sliceMargin<0){this.sliceMargin=0}this._diameter=null;this._radius=null;this._sliceAngles=[];this._highlightedPoint=null;if(this.highlightColors.length==0){for(var s=0;s<this.seriesColors.length;s++){var r=e.jqplot.getColorComponents(this.seriesColors[s]);var o=[r[0],r[1],r[2]];var t=o[0]+o[1]+o[2];for(var p=0;p<3;p++){o[p]=(t>570)?o[p]*0.8:o[p]+0.3*(255-o[p]);o[p]=parseInt(o[p],10)}this.highlightColors.push("rgb("+o[0]+","+o[1]+","+o[2]+")")}}this.highlightColorGenerator=new e.jqplot.ColorGenerator(this.highlightColors);u.postParseOptionsHooks.addOnce(m);u.postInitHooks.addOnce(g);u.eventListenerHooks.addOnce("jqplotMouseMove",b);u.eventListenerHooks.addOnce("jqplotMouseDown",a);u.eventListenerHooks.addOnce("jqplotMouseUp",l);u.eventListenerHooks.addOnce("jqplotClick",f);u.eventListenerHooks.addOnce("jqplotRightClick",n);u.postDrawHooks.addOnce(i)};e.jqplot.PieRenderer.prototype.setGridData=function(t){var p=[];var u=[];var o=this.startAngle/180*Math.PI;var s=0;this._drawData=false;for(var r=0;r<this.data.length;r++){if(this.data[r][1]!=0){this._drawData=true}p.push(this.data[r][1]);u.push([this.data[r][0]]);if(r>0){p[r]+=p[r-1]}s+=this.data[r][1]}var q=Math.PI*2/p[p.length-1];for(var r=0;r<p.length;r++){u[r][1]=p[r]*q;u[r][2]=this.data[r][1]/s}this.gridData=u};e.jqplot.PieRenderer.prototype.makeGridData=function(t,u){var p=[];var v=[];var s=0;var o=this.startAngle/180*Math.PI;this._drawData=false;for(var r=0;r<t.length;r++){if(this.data[r][1]!=0){this._drawData=true}p.push(t[r][1]);v.push([t[r][0]]);if(r>0){p[r]+=p[r-1]}s+=t[r][1]}var q=Math.PI*2/p[p.length-1];for(var r=0;r<p.length;r++){v[r][1]=p[r]*q;v[r][2]=t[r][1]/s}return v};function h(o){return Math.sin((o-(o-Math.PI)/8/Math.PI)/2)}function j(u,t,o,v,r){var w=0;var q=t-u;var s=Math.abs(q);var p=o;if(v==false){p+=r}if(p>0&&s>0.01&&s<6.282){w=parseFloat(p)/2/h(q)}return w}e.jqplot.PieRenderer.prototype.drawSlice=function(B,z,y,u,w){if(this._drawData){var p=this._radius;var A=this.fill;var x=this.lineWidth;var s=this.sliceMargin;if(this.fill==false){s+=this.lineWidth}B.save();B.translate(this._center[0],this._center[1]);var D=j(z,y,this.sliceMargin,this.fill,this.lineWidth);var o=D*Math.cos((z+y)/2);var C=D*Math.sin((z+y)/2);if((y-z)<=Math.PI){p-=D}else{p+=D}B.translate(o,C);if(w){for(var v=0,t=this.shadowDepth;v<t;v++){B.save();B.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));q(p)}for(var v=0,t=this.shadowDepth;v<t;v++){B.restore()}}else{q(p)}B.restore()}function q(r){if(y>6.282+this.startAngle){y=6.282+this.startAngle;if(z>y){z=6.281+this.startAngle}}if(z>=y){return}B.beginPath();B.fillStyle=u;B.strokeStyle=u;B.lineWidth=x;B.arc(0,0,r,z,y,false);B.lineTo(0,0);B.closePath();if(A){B.fill()}else{B.stroke()}}};e.jqplot.PieRenderer.prototype.draw=function(B,z,E,o){var W;var H=(E!=undefined)?E:{};var t=0;var s=0;var N=1;var L=new e.jqplot.ColorGenerator(this.seriesColors);if(E.legendInfo&&E.legendInfo.placement=="insideGrid"){var J=E.legendInfo;switch(J.location){case"nw":t=J.width+J.xoffset;break;case"w":t=J.width+J.xoffset;break;case"sw":t=J.width+J.xoffset;break;case"ne":t=J.width+J.xoffset;N=-1;break;case"e":t=J.width+J.xoffset;N=-1;break;case"se":t=J.width+J.xoffset;N=-1;break;case"n":s=J.height+J.yoffset;break;case"s":s=J.height+J.yoffset;N=-1;break;default:break}}var K=(H.shadow!=undefined)?H.shadow:this.shadow;var A=(H.fill!=undefined)?H.fill:this.fill;var C=B.canvas.width;var I=B.canvas.height;var Q=C-t-2*this.padding;var X=I-s-2*this.padding;var M=Math.min(Q,X);var Y=M;this._sliceAngles=[];var v=this.sliceMargin;if(this.fill==false){v+=this.lineWidth}var q;var G=0;var R,aa,Z,ab;var D=this.startAngle/180*Math.PI;for(var W=0,V=z.length;W<V;W++){aa=(W==0)?D:z[W-1][1]+D;Z=z[W][1]+D;this._sliceAngles.push([aa,Z]);q=j(aa,Z,this.sliceMargin,this.fill,this.lineWidth);if(Math.abs(Z-aa)>Math.PI){G=Math.max(q,G)}}if(this.diameter!=null&&this.diameter>0){this._diameter=this.diameter-2*G}else{this._diameter=Y-2*G}if(this._diameter<6){e.jqplot.log("Diameter of pie too small, not rendering.");return}var S=this._radius=this._diameter/2;this._center=[(C-N*t)/2+N*t+G*Math.cos(D),(I-N*s)/2+N*s+G*Math.sin(D)];if(this.shadow){for(var W=0,V=z.length;W<V;W++){ab="rgba(0,0,0,"+this.shadowAlpha+")";this.renderer.drawSlice.call(this,B,this._sliceAngles[W][0],this._sliceAngles[W][1],ab,true)}}for(var W=0;W<z.length;W++){this.renderer.drawSlice.call(this,B,this._sliceAngles[W][0],this._sliceAngles[W][1],L.next(),false);if(this.showDataLabels&&z[W][2]*100>=this.dataLabelThreshold){var F,U=(this._sliceAngles[W][0]+this._sliceAngles[W][1])/2,T;if(this.dataLabels=="label"){F=this.dataLabelFormatString||"%s";T=e.jqplot.sprintf(F,z[W][0])}else{if(this.dataLabels=="value"){F=this.dataLabelFormatString||"%d";T=e.jqplot.sprintf(F,this.data[W][1])}else{if(this.dataLabels=="percent"){F=this.dataLabelFormatString||"%d%%";T=e.jqplot.sprintf(F,z[W][2]*100)}else{if(this.dataLabels.constructor==Array){F=this.dataLabelFormatString||"%s";T=e.jqplot.sprintf(F,this.dataLabels[W])}}}}var p=(this._radius)*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var P=this._center[0]+Math.cos(U)*p+this.canvas._offsets.left;var O=this._center[1]+Math.sin(U)*p+this.canvas._offsets.top;var u=e('<div class="jqplot-pie-series jqplot-data-label" style="position:absolute;">'+T+"</div>").insertBefore(o.eventCanvas._elem);if(this.dataLabelCenterOn){P-=u.width()/2;O-=u.height()/2}else{P-=u.width()*Math.sin(U/2);O-=u.height()/2}P=Math.round(P);O=Math.round(O);u.css({left:P,top:O})}}};e.jqplot.PieAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.PieAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.PieAxisRenderer.prototype.constructor=e.jqplot.PieAxisRenderer;e.jqplot.PieAxisRenderer.prototype.init=function(o){this.tickRenderer=e.jqplot.PieTickRenderer;e.extend(true,this,o);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};e.jqplot.PieLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.PieLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.PieLegendRenderer.prototype.constructor=e.jqplot.PieLegendRenderer;e.jqplot.PieLegendRenderer.prototype.init=function(o){this.numberRows=null;this.numberColumns=null;e.extend(true,this,o)};e.jqplot.PieLegendRenderer.prototype.draw=function(){var r=this;if(this.show){var B=this._series;this._elem=e(document.createElement("table"));this._elem.addClass("jqplot-table-legend");var E={position:"absolute"};if(this.background){E.background=this.background}if(this.border){E.border=this.border}if(this.fontSize){E.fontSize=this.fontSize}if(this.fontFamily){E.fontFamily=this.fontFamily}if(this.textColor){E.textColor=this.textColor}if(this.marginTop!=null){E.marginTop=this.marginTop}if(this.marginBottom!=null){E.marginBottom=this.marginBottom}if(this.marginLeft!=null){E.marginLeft=this.marginLeft}if(this.marginRight!=null){E.marginRight=this.marginRight}this._elem.css(E);var I=false,A=false,o,y;var C=B[0];var p=new e.jqplot.ColorGenerator(C.seriesColors);if(C.show){var J=C.data;if(this.numberRows){o=this.numberRows;if(!this.numberColumns){y=Math.ceil(J.length/o)}else{y=this.numberColumns}}else{if(this.numberColumns){y=this.numberColumns;o=Math.ceil(J.length/this.numberColumns)}else{o=J.length;y=1}}var H,G;var q,w,v;var x,z,F;var D=0;var u,t;for(H=0;H<o;H++){q=e(document.createElement("tr"));q.addClass("jqplot-table-legend");if(A){q.prependTo(this._elem)}else{q.appendTo(this._elem)}for(G=0;G<y;G++){if(D<J.length){x=this.labels[D]||J[D][0].toString();F=p.next();if(!A){if(H>0){I=true}else{I=false}}else{if(H==o-1){I=false}else{I=true}}z=(I)?this.rowSpacing:"0";w=e(document.createElement("td"));w.addClass("jqplot-table-legend jqplot-table-legend-swatch");w.css({textAlign:"center",paddingTop:z});u=e(document.createElement("div"));u.addClass("jqplot-table-legend-swatch-outline");t=e(document.createElement("div"));t.addClass("jqplot-table-legend-swatch");t.css({backgroundColor:F,borderColor:F});w.append(u.append(t));v=e(document.createElement("td"));v.addClass("jqplot-table-legend jqplot-table-legend-label");v.css("paddingTop",z);if(this.escapeHtml){v.text(x)}else{v.html(x)}if(A){v.prependTo(q);w.prependTo(q)}else{w.appendTo(q);v.appendTo(q)}I=true}D++}}}}return this._elem};e.jqplot.PieRenderer.prototype.handleMove=function(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];r.target.trigger("jqplotDataMouseOver",o);if(r.series[o[0]].highlightMouseOver&&!(o[0]==r.plugins.pieRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){r.target.trigger("jqplotDataHighlight",o);d(r,o[0],o[1])}}else{if(s==null){k(r)}}};function c(s,r,p){p=p||{};p.axesDefaults=p.axesDefaults||{};p.legend=p.legend||{};p.seriesDefaults=p.seriesDefaults||{};var o=false;if(p.seriesDefaults.renderer==e.jqplot.PieRenderer){o=true}else{if(p.series){for(var q=0;q<p.series.length;q++){if(p.series[q].renderer==e.jqplot.PieRenderer){o=true}}}}if(o){p.axesDefaults.renderer=e.jqplot.PieAxisRenderer;p.legend.renderer=e.jqplot.PieLegendRenderer;p.legend.preDraw=true;p.seriesDefaults.pointLabels={show:false}}}function g(r,q,o){for(var p=0;p<this.series.length;p++){if(this.series[p].renderer.constructor==e.jqplot.PieRenderer){if(this.series[p].highlightMouseOver){this.series[p].highlightMouseDown=false}}}}function m(o){for(var p=0;p<this.series.length;p++){this.series[p].seriesColors=this.seriesColors;this.series[p].colorGenerator=e.jqplot.colorGenerator}}function d(t,r,q){var p=t.series[r];var o=t.plugins.pieRenderer.highlightCanvas;o._ctx.clearRect(0,0,o._ctx.canvas.width,o._ctx.canvas.height);p._highlightedPoint=q;t.plugins.pieRenderer.highlightedSeriesIndex=r;p.renderer.drawSlice.call(p,o._ctx,p._sliceAngles[q][0],p._sliceAngles[q][1],p.highlightColorGenerator.get(q),false)}function k(q){var o=q.plugins.pieRenderer.highlightCanvas;o._ctx.clearRect(0,0,o._ctx.canvas.width,o._ctx.canvas.height);for(var p=0;p<q.series.length;p++){q.series[p]._highlightedPoint=null}q.plugins.pieRenderer.highlightedSeriesIndex=null;q.target.trigger("jqplotDataUnhighlight")}function b(s,r,v,u,t){if(u){var q=[u.seriesIndex,u.pointIndex,u.data];var p=jQuery.Event("jqplotDataMouseOver");p.pageX=s.pageX;p.pageY=s.pageY;t.target.trigger(p,q);if(t.series[q[0]].highlightMouseOver&&!(q[0]==t.plugins.pieRenderer.highlightedSeriesIndex&&q[1]==t.series[q[0]]._highlightedPoint)){var o=jQuery.Event("jqplotDataHighlight");o.pageX=s.pageX;o.pageY=s.pageY;t.target.trigger(o,q);d(t,q[0],q[1])}}else{if(u==null){k(t)}}}function a(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];if(s.series[p[0]].highlightMouseDown&&!(p[0]==s.plugins.pieRenderer.highlightedSeriesIndex&&p[1]==s.series[p[0]]._highlightedPoint)){var o=jQuery.Event("jqplotDataHighlight");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p);d(s,p[0],p[1])}}else{if(t==null){k(s)}}}function l(q,p,t,s,r){var o=r.plugins.pieRenderer.highlightedSeriesIndex;if(o!=null&&r.series[o].highlightMouseDown){k(r)}}function f(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];var o=jQuery.Event("jqplotDataClick");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p)}}function n(s,r,v,u,t){if(u){var q=[u.seriesIndex,u.pointIndex,u.data];var o=t.plugins.pieRenderer.highlightedSeriesIndex;if(o!=null&&t.series[o].highlightMouseDown){k(t)}var p=jQuery.Event("jqplotDataRightClick");p.pageX=s.pageX;p.pageY=s.pageY;t.target.trigger(p,q)}}function i(){if(this.plugins.pieRenderer&&this.plugins.pieRenderer.highlightCanvas){this.plugins.pieRenderer.highlightCanvas.resetCanvas();this.plugins.pieRenderer.highlightCanvas=null}this.plugins.pieRenderer={highlightedSeriesIndex:null};this.plugins.pieRenderer.highlightCanvas=new e.jqplot.GenericCanvas();var p=e(this.targetId+" .jqplot-data-label");if(p.length){e(p[0]).before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-pieRenderer-highlight-canvas",this._plotDimensions,this))}else{this.eventCanvas._elem.before(this.plugins.pieRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-pieRenderer-highlight-canvas",this._plotDimensions,this))}var o=this.plugins.pieRenderer.highlightCanvas.setContext();this.eventCanvas._elem.bind("mouseleave",{plot:this},function(q){k(q.data.plot)})}e.jqplot.preInitHooks.push(c);e.jqplot.PieTickRenderer=function(){e.jqplot.AxisTickRenderer.call(this)};e.jqplot.PieTickRenderer.prototype=new e.jqplot.AxisTickRenderer();e.jqplot.PieTickRenderer.prototype.constructor=e.jqplot.PieTickRenderer})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pointLabels.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pointLabels.js
deleted file mode 100644
index cbc130d..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pointLabels.js
+++ /dev/null
@@ -1,353 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    
-    /**
-     * Class: $.jqplot.PointLabels
-     * Plugin for putting labels at the data points.
-     * 
-     * To use this plugin, include the js
-     * file in your source:
-     * 
-     * > <script type="text/javascript" src="plugins/jqplot.pointLabels.js"></script>
-     * 
-     * By default, the last value in the data ponit array in the data series is used
-     * for the label.  For most series renderers, extra data can be added to the 
-     * data point arrays and the last value will be used as the label.
-     * 
-     * For instance, 
-     * this series:
-     * 
-     * > [[1,4], [3,5], [7,2]]
-     * 
-     * Would, by default, use the y values in the labels.
-     * Extra data can be added to the series like so:
-     * 
-     * > [[1,4,'mid'], [3 5,'hi'], [7,2,'low']]
-     * 
-     * And now the point labels would be 'mid', 'low', and 'hi'.
-     * 
-     * Options to the point labels and a custom labels array can be passed into the
-     * "pointLabels" option on the series option like so:
-     * 
-     * > series:[{pointLabels:{
-     * >    labels:['mid', 'hi', 'low'],
-     * >    location:'se',
-     * >    ypadding: 12
-     * >    }
-     * > }]
-     * 
-     * A custom labels array in the options takes precendence over any labels
-     * in the series data.  If you have a custom labels array in the options,
-     * but still want to use values from the series array as labels, set the
-     * "labelsFromSeries" option to true.
-     * 
-     * By default, html entities (<, >, etc.) are escaped in point labels.  
-     * If you want to include actual html markup in the labels, 
-     * set the "escapeHTML" option to false.
-     * 
-     */
-    $.jqplot.PointLabels = function(options) {
-        // Group: Properties
-        //
-        // prop: show
-        // show the labels or not.
-        this.show = $.jqplot.config.enablePlugins;
-        // prop: location
-        // compass location where to position the label around the point.
-        // 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'
-        this.location = 'n';
-        // prop: labelsFromSeries
-        // true to use labels within data point arrays.
-        this.labelsFromSeries = false;
-        // prop: seriesLabelIndex
-        // array index for location of labels within data point arrays.
-        // if null, will use the last element of the data point array.
-        this.seriesLabelIndex = null;
-        // prop: labels
-        // array of arrays of labels, one array for each series.
-        this.labels = [];
-        // actual labels that will get displayed.
-        // needed to preserve user specified labels in labels array.
-        this._labels = [];
-        // prop: stackedValue
-        // true to display value as stacked in a stacked plot.
-        // no effect if labels is specified.
-        this.stackedValue = false;
-        // prop: ypadding
-        // vertical padding in pixels between point and label
-        this.ypadding = 6;
-        // prop: xpadding
-        // horizontal padding in pixels between point and label
-        this.xpadding = 6;
-        // prop: escapeHTML
-        // true to escape html entities in the labels.
-        // If you want to include markup in the labels, set to false.
-        this.escapeHTML = true;
-        // prop: edgeTolerance
-        // Number of pixels that the label must be away from an axis
-        // boundary in order to be drawn.  Negative values will allow overlap
-        // with the grid boundaries.
-        this.edgeTolerance = -5;
-        // prop: formatter
-        // A class of a formatter for the tick text.  sprintf by default.
-        this.formatter = $.jqplot.DefaultTickFormatter;
-        // prop: formatString
-        // string passed to the formatter.
-        this.formatString = '';
-        // prop: hideZeros
-        // true to not show a label for a value which is 0.
-        this.hideZeros = false;
-        this._elems = [];
-        
-        $.extend(true, this, options);
-    };
-    
-    var locations = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
-    var locationIndicies = {'nw':0, 'n':1, 'ne':2, 'e':3, 'se':4, 's':5, 'sw':6, 'w':7};
-    var oppositeLocations = ['se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];
-    
-    // called with scope of a series
-    $.jqplot.PointLabels.init = function (target, data, seriesDefaults, opts){
-        var options = $.extend(true, {}, seriesDefaults, opts);
-        options.pointLabels = options.pointLabels || {};
-        if (this.renderer.constructor === $.jqplot.BarRenderer && this.barDirection === 'horizontal' && !options.pointLabels.location) {
-            options.pointLabels.location = 'e';
-        }
-        // add a pointLabels attribute to the series plugins
-        this.plugins.pointLabels = new $.jqplot.PointLabels(options.pointLabels);
-        this.plugins.pointLabels.setLabels.call(this);
-    };
-    
-    // called with scope of series
-    $.jqplot.PointLabels.prototype.setLabels = function() {   
-        var p = this.plugins.pointLabels; 
-        var labelIdx;
-        if (p.seriesLabelIndex != null) {
-            labelIdx = p.seriesLabelIndex;
-        }
-        else if (this.renderer.constructor === $.jqplot.BarRenderer && this.barDirection === 'horizontal') {
-            labelIdx = 0;
-        }
-        else {
-            labelIdx = (this._plotData.length === 0) ? 0 : this._plotData[0].length -1;
-        }
-        p._labels = [];
-        if (p.labels.length === 0 || p.labelsFromSeries) {    
-            if (p.stackedValue) {
-                if (this._plotData.length && this._plotData[0].length){
-                    // var idx = p.seriesLabelIndex || this._plotData[0].length -1;
-                    for (var i=0; i<this._plotData.length; i++) {
-                        p._labels.push(this._plotData[i][labelIdx]);
-                    }
-                }
-            }
-            else {
-                var d = this._plotData;
-                if (this.renderer.constructor === $.jqplot.BarRenderer && this.waterfall) {
-                    d = this._data;
-                }
-                if (d.length && d[0].length) {
-                    // var idx = p.seriesLabelIndex || d[0].length -1;
-                    for (var i=0; i<d.length; i++) {
-                        p._labels.push(d[i][labelIdx]);
-                    }
-                }
-                d = null;
-            }
-        }
-        else if (p.labels.length){
-            p._labels = p.labels;
-        }
-    };
-    
-    $.jqplot.PointLabels.prototype.xOffset = function(elem, location, padding) {
-        location = location || this.location;
-        padding = padding || this.xpadding;
-        var offset;
-        
-        switch (location) {
-            case 'nw':
-                offset = -elem.outerWidth(true) - this.xpadding;
-                break;
-            case 'n':
-                offset = -elem.outerWidth(true)/2;
-                break;
-            case 'ne':
-                offset =  this.xpadding;
-                break;
-            case 'e':
-                offset = this.xpadding;
-                break;
-            case 'se':
-                offset = this.xpadding;
-                break;
-            case 's':
-                offset = -elem.outerWidth(true)/2;
-                break;
-            case 'sw':
-                offset = -elem.outerWidth(true) - this.xpadding;
-                break;
-            case 'w':
-                offset = -elem.outerWidth(true) - this.xpadding;
-                break;
-            default: // same as 'nw'
-                offset = -elem.outerWidth(true) - this.xpadding;
-                break;
-        }
-        return offset; 
-    };
-    
-    $.jqplot.PointLabels.prototype.yOffset = function(elem, location, padding) {
-        location = location || this.location;
-        padding = padding || this.xpadding;
-        var offset;
-        
-        switch (location) {
-            case 'nw':
-                offset = -elem.outerHeight(true) - this.ypadding;
-                break;
-            case 'n':
-                offset = -elem.outerHeight(true) - this.ypadding;
-                break;
-            case 'ne':
-                offset = -elem.outerHeight(true) - this.ypadding;
-                break;
-            case 'e':
-                offset = -elem.outerHeight(true)/2;
-                break;
-            case 'se':
-                offset = this.ypadding;
-                break;
-            case 's':
-                offset = this.ypadding;
-                break;
-            case 'sw':
-                offset = this.ypadding;
-                break;
-            case 'w':
-                offset = -elem.outerHeight(true)/2;
-                break;
-            default: // same as 'nw'
-                offset = -elem.outerHeight(true) - this.ypadding;
-                break;
-        }
-        return offset; 
-    };
-    
-    // called with scope of series
-    $.jqplot.PointLabels.draw = function (sctx, options) {
-        var p = this.plugins.pointLabels;
-        // set labels again in case they have changed.
-        p.setLabels.call(this);
-        // remove any previous labels
-        for (var i=0; i<p._elems.length; i++) {
-            // Memory Leaks patch
-            // p._elems[i].remove();
-            p._elems[i].emptyForce();
-        }
-        p._elems.splice(0, p._elems.length);
-
-        if (p.show) {
-            var ax = '_'+this._stackAxis+'axis';
-        
-            if (!p.formatString) {
-                p.formatString = this[ax]._ticks[0].formatString;
-                p.formatter = this[ax]._ticks[0].formatter;
-            }
-        
-            var pd = this._plotData;
-            var xax = this._xaxis;
-            var yax = this._yaxis;
-            var elem, helem;
-
-            for (var i=0, l=p._labels.length; i < l; i++) {
-                var label = p._labels[i];
-                
-                if (p.hideZeros && parseInt(p._labels[i], 10) == 0) {
-                    label = '';
-                }
-                
-                if (label != null) {
-                    label = p.formatter(p.formatString, label);
-                } 
-
-                helem = document.createElement('div');
-                p._elems[i] = $(helem);
-
-                elem = p._elems[i];
-
-
-                elem.addClass('jqplot-point-label jqplot-series-'+this.index+' jqplot-point-'+i);
-                elem.css('position', 'absolute');
-                elem.insertAfter(sctx.canvas);
-
-                if (p.escapeHTML) {
-                    elem.text(label);
-                }
-                else {
-                    elem.html(label);
-                }
-                var location = p.location;
-                if ((this.fillToZero && pd[i][1] < 0) || (this.fillToZero && this._type === 'bar' && this.barDirection === 'horizontal' && pd[i][0] < 0) || (this.waterfall && parseInt(label, 10)) < 0) {
-                    location = oppositeLocations[locationIndicies[location]];
-                }
-                var ell = xax.u2p(pd[i][0]) + p.xOffset(elem, location);
-                var elt = yax.u2p(pd[i][1]) + p.yOffset(elem, location);
-                if (this.renderer.constructor == $.jqplot.BarRenderer) {
-                    if (this.barDirection == "vertical") {
-                        ell += this._barNudge;
-                    }
-                    else {
-                        elt -= this._barNudge;
-                    }
-                }
-                elem.css('left', ell);
-                elem.css('top', elt);
-                var elr = ell + elem.width();
-                var elb = elt + elem.height();
-                var et = p.edgeTolerance;
-                var scl = $(sctx.canvas).position().left;
-                var sct = $(sctx.canvas).position().top;
-                var scr = sctx.canvas.width + scl;
-                var scb = sctx.canvas.height + sct;
-                // if label is outside of allowed area, remove it
-                if (ell - et < scl || elt - et < sct || elr + et > scr || elb + et > scb) {
-                    elem.remove();
-                }
-                elem = null;
-                helem = null;
-            }
-        }
-    };
-    
-    $.jqplot.postSeriesInitHooks.push($.jqplot.PointLabels.init);
-    $.jqplot.postDrawSeriesHooks.push($.jqplot.PointLabels.draw);
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pointLabels.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pointLabels.min.js
deleted file mode 100644
index 5e6b539..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pointLabels.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(c){c.jqplot.PointLabels=function(e){this.show=c.jqplot.config.enablePlugins;this.location="n";this.labelsFromSeries=false;this.seriesLabelIndex=null;this.labels=[];this._labels=[];this.stackedValue=false;this.ypadding=6;this.xpadding=6;this.escapeHTML=true;this.edgeTolerance=-5;this.formatter=c.jqplot.DefaultTickFormatter;this.formatString="";this.hideZeros=false;this._elems=[];c.extend(true,this,e)};var a=["nw","n","ne","e","se","s","sw","w"];var d={nw:0,n:1,ne:2,e:3,se:4,s:5,sw:6,w:7};var b=["se","s","sw","w","nw","n","ne","e"];c.jqplot.PointLabels.init=function(i,h,f,g){var e=c.extend(true,{},f,g);e.pointLabels=e.pointLabels||{};if(this.renderer.constructor===c.jqplot.BarRenderer&&this.barDirection==="horizontal"&&!e.pointLabels.location){e.pointLabels.location="e"}this.plugins.pointLabels=new c.jqplot.PointLabels(e.pointLabels);this.plugins.pointLabels.setLabels.call(this)};c.jqplot.PointLabels.prototype.setLabels=function(){var f=this.plugins.pointLabels;var h;if(f.seriesLabelIndex!=null){h=f.seriesLabelIndex}else{if(this.renderer.constructor===c.jqplot.BarRenderer&&this.barDirection==="horizontal"){h=0}else{h=(this._plotData.length===0)?0:this._plotData[0].length-1}}f._labels=[];if(f.labels.length===0||f.labelsFromSeries){if(f.stackedValue){if(this._plotData.length&&this._plotData[0].length){for(var e=0;e<this._plotData.length;e++){f._labels.push(this._plotData[e][h])}}}else{var g=this._plotData;if(this.renderer.constructor===c.jqplot.BarRenderer&&this.waterfall){g=this._data}if(g.length&&g[0].length){for(var e=0;e<g.length;e++){f._labels.push(g[e][h])}}g=null}}else{if(f.labels.length){f._labels=f.labels}}};c.jqplot.PointLabels.prototype.xOffset=function(f,e,g){e=e||this.location;g=g||this.xpadding;var h;switch(e){case"nw":h=-f.outerWidth(true)-this.xpadding;break;case"n":h=-f.outerWidth(true)/2;break;case"ne":h=this.xpadding;break;case"e":h=this.xpadding;break;case"se":h=this.xpadding;break;case"s":h=-f.outerWidth(true)/2;break;case"sw":h=-f.outerWidth(true)-this.xpadding;break;case"w":h=-f.outerWidth(true)-this.xpadding;break;default:h=-f.outerWidth(true)-this.xpadding;break}return h};c.jqplot.PointLabels.prototype.yOffset=function(f,e,g){e=e||this.location;g=g||this.xpadding;var h;switch(e){case"nw":h=-f.outerHeight(true)-this.ypadding;break;case"n":h=-f.outerHeight(true)-this.ypadding;break;case"ne":h=-f.outerHeight(true)-this.ypadding;break;case"e":h=-f.outerHeight(true)/2;break;case"se":h=this.ypadding;break;case"s":h=this.ypadding;break;case"sw":h=this.ypadding;break;case"w":h=-f.outerHeight(true)/2;break;default:h=-f.outerHeight(true)-this.ypadding;break}return h};c.jqplot.PointLabels.draw=function(w,j){var t=this.plugins.pointLabels;t.setLabels.call(this);for(var v=0;v<t._elems.length;v++){t._elems[v].emptyForce()}t._elems.splice(0,t._elems.length);if(t.show){var r="_"+this._stackAxis+"axis";if(!t.formatString){t.formatString=this[r]._ticks[0].formatString;t.formatter=this[r]._ticks[0].formatter}var C=this._plotData;var z=this._xaxis;var q=this._yaxis;var y,f;for(var v=0,u=t._labels.length;v<u;v++){var o=t._labels[v];if(t.hideZeros&&parseInt(t._labels[v],10)==0){o=""}if(o!=null){o=t.formatter(t.formatString,o)}f=document.createElement("div");t._elems[v]=c(f);y=t._elems[v];y.addClass("jqplot-point-label jqplot-series-"+this.index+" jqplot-point-"+v);y.css("position","absolute");y.insertAfter(w.canvas);if(t.escapeHTML){y.text(o)}else{y.html(o)}var g=t.location;if((this.fillToZero&&C[v][1]<0)||(this.fillToZero&&this._type==="bar"&&this.barDirection==="horizontal"&&C[v][0]<0)||(this.waterfall&&parseInt(o,10))<0){g=b[d[g]]}var n=z.u2p(C[v][0])+t.xOffset(y,g);var h=q.u2p(C[v][1])+t.yOffset(y,g);if(this.renderer.constructor==c.jqplot.BarRenderer){if(this.barDirection=="vertical"){n+=this._barNudge}else{h-=this._barNudge}}y.css("left",n);y.css("top",h);var k=n+y.width();var s=h+y.height();var B=t.edgeTolerance;var e=c(w.canvas).position().left;var x=c(w.canvas).position().top;var A=w.canvas.width+e;var m=w.canvas.height+x;if(n-B<e||h-B<x||k+B>A||s+B>m){y.remove()}y=null;f=null}}};c.jqplot.postSeriesInitHooks.push(c.jqplot.PointLabels.init);c.jqplot.postDrawSeriesHooks.push(c.jqplot.PointLabels.draw)})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidAxisRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidAxisRenderer.js
deleted file mode 100644
index 95625a6..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidAxisRenderer.js
+++ /dev/null
@@ -1,713 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    $.jqplot.PyramidAxisRenderer = function() {
-        $.jqplot.LinearAxisRenderer.call(this);
-    };
-    
-    $.jqplot.PyramidAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
-    $.jqplot.PyramidAxisRenderer.prototype.constructor = $.jqplot.PyramidAxisRenderer;
-        
-    // called with scope of axis
-    $.jqplot.PyramidAxisRenderer.prototype.init = function(options){
-        // Group: Properties
-        //
-        // prop: position
-        // Position of axis.  Values are: top, bottom , left, center, right.
-        // By default, x and x2 axes are bottom, y axis is center.
-        this.position = null;
-        // prop: drawBaseline
-        // True to draw the axis baseline.
-        this.drawBaseline = true;
-        // prop: baselineWidth
-        // width of the baseline in pixels.
-        this.baselineWidth = null;
-        // prop: baselineColor
-        // CSS color spec for the baseline.
-        this.baselineColor = null;
-        this.tickSpacingFactor = 25;
-        this._type = 'pyramid';
-        this._splitAxis = false;
-        this._splitLength = null;
-        this.category = false;
-        
-        $.extend(true, this, options);
-        this.renderer.options = options;
-
-        this.resetDataBounds = this.renderer.resetDataBounds;
-        this.resetDataBounds();
-
-    };
-
-    $.jqplot.PyramidAxisRenderer.prototype.resetDataBounds = function() {
-        // Go through all the series attached to this axis and find
-        // the min/max bounds for this axis.
-        var db = this._dataBounds;
-        db.min = null;
-        db.max = null;
-        var temp;
-        for (var i=0; i<this._series.length; i++) {
-            var s = this._series[i];
-            var d = s._plotData;
-            
-            for (var j=0, l=d.length; j<l; j++) { 
-                if (this.name.charAt(0) === 'x') {
-                    temp = d[j][1];
-                    if ((temp !== null && temp < db.min) || db.min === null) {
-                        db.min = temp;
-                    }
-                    if ((temp !== null && temp > db.max) || db.max === null) {
-                        db.max = temp;
-                    }
-                }              
-                else {
-                    temp = d[j][0];
-                    if ((temp !== null && temp < db.min) || db.min === null) {
-                        db.min = temp;
-                    }
-                    if ((temp !== null && temp > db.max) || db.max === null) {
-                        db.max = temp;
-                    }
-                }              
-            }
-        }
-    };
-    
-    // called with scope of axis
-    $.jqplot.PyramidAxisRenderer.prototype.draw = function(ctx, plot) {
-        if (this.show) {
-            // populate the axis label and value properties.
-            // createTicks is a method on the renderer, but
-            // call it within the scope of the axis.
-            this.renderer.createTicks.call(this, plot);
-            // fill a div with axes labels in the right direction.
-            // Need to pregenerate each axis to get it's bounds and
-            // position it and the labels correctly on the plot.
-            var dim=0;
-            var temp;
-            // Added for theming.
-            if (this._elem) {
-                // Memory Leaks patch
-                //this._elem.empty();
-                this._elem.emptyForce();
-                this._elem = null;
-            }
-            
-            this._elem = $(document.createElement('div'));
-            this._elem.addClass('jqplot-axis jqplot-'+this.name);
-            this._elem.css('position', 'absolute');
-
-            
-            if (this.name == 'xaxis' || this.name == 'x2axis') {
-                this._elem.width(this._plotDimensions.width);
-            }
-            else {
-                this._elem.height(this._plotDimensions.height);
-            }
-            
-            // create a _label object.
-            this.labelOptions.axis = this.name;
-            this._label = new this.labelRenderer(this.labelOptions);
-            if (this._label.show) {
-                var elem = this._label.draw(ctx, plot);
-                elem.appendTo(this._elem);
-                elem = null;
-            }
-    
-            var t = this._ticks;
-            var tick;
-            for (var i=0; i<t.length; i++) {
-                tick = t[i];
-                if (tick.show && tick.showLabel && (!tick.isMinorTick)) {
-                    this._elem.append(tick.draw(ctx, plot));
-                }
-            }
-            tick = null;
-            t = null;
-        }
-        return this._elem;
-    };   
-
-    // Note, primes can be found on http://primes.utm.edu/
-    var _primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
-
-
-    var _primesHash = {};
-
-    for (var i =0, l = _primes.length; i < l; i++) {
-        _primesHash[_primes[i]] = _primes[i];
-    }
-
-    // called with scope of axis
-    $.jqplot.PyramidAxisRenderer.prototype.createTicks = function(plot) {
-        // we're are operating on an axis here
-        var userTicks = this.ticks;
-        // databounds were set on axis initialization.
-        var db = this._dataBounds;
-        var dim;
-        var interval;
-        var min;
-        var max;
-        var range;
-        var pos1;
-        var pos2;
-        var tt;
-        var i;
-        var l;
-        var s;
-        // get a copy of user's settings for min/max.
-        var userMin = this.min;
-        var userMax = this.max;
-        var ut;
-        var t;
-        var threshold;
-        var tdim;
-        var scalefact;
-        var ret;
-        var tumin;
-        var tumax;
-        var maxVisibleTicks;
-        var val;
-        var skip = null;
-        var temp;
-        
-        // if we already have ticks, use them.
-        // ticks must be in order of increasing value.
-
-        if (userTicks.length) {
-            // ticks could be 1D or 2D array of [val, val, ,,,] or [[val, label], [val, label], ...] or mixed
-            for (i=0, l=userTicks.length; i<l; i++){
-                ut = userTicks[i];
-                t = new this.tickRenderer(this.tickOptions);
-                if ($.isArray(ut)) {
-                    t.value = ut[0];
-                    t.label = ut[1];
-                    t.setTick(ut[0], this.name);
-                    this._ticks.push(t);
-                }
-
-                else if ($.isPlainObject(ut)) {
-                    $.extend(true, t, ut);
-                    t.axis = this.name;
-                    this._ticks.push(t);
-                }
-                
-                else {
-                    if (typeof ut === 'string') {
-                        val = i + plot.defaultAxisStart;
-                    }
-                    else {
-                        val = ut;
-                    }
-                    t.value = val;
-                    t.label = ut;
-                    t.axis = this.name;
-                    this._ticks.push(t);
-                }
-            }
-            this.numberTicks = userTicks.length;
-            this.min = this._ticks[0].value;
-            this.max = this._ticks[this.numberTicks-1].value;
-            this.tickInterval = (this.max - this.min) / (this.numberTicks - 1);
-
-            // use user specified tickInterval if there is one
-            if (this._options.tickInterval) {
-                // hide every tick except for ticks on interval
-                var ti = this._options.tickInterval;
-                for (i=0; i<this.numberTicks; i++) {
-                    if (i%ti !== 0) {
-                        // this._ticks[i].show = false;
-                        this._ticks[i].isMinorTick = true;
-                    }
-                }
-            }
-
-            else {
-                // check if we have too many ticks
-                dim = (this.name.charAt(0) === 'x') ? this._plotDimensions.width : this._plotDimensions.height;
-                maxVisibleTicks = Math.round(2.0 + dim/this.tickSpacingFactor);
-
-                if (this.numberTicks > maxVisibleTicks) {
-                    // check for number of ticks we can skip
-                    temp = this.numberTicks - 1;
-                    for (i=2; i<temp; i++) {
-                        if (temp % i === 0 && temp/i < maxVisibleTicks) {
-                            skip = i-1;
-                            break;
-                        }
-                    }
-
-                    if (skip !== null) {
-                        var count = 1;
-                        for (i=1, l=this._ticks.length; i<l; i++) {
-                            if (count <= skip) {
-                                this._ticks[i].show = false;
-                                count += 1;
-                            }
-                            else {
-                                count = 1;
-                            }
-                        }
-                    }
-                }
-            }
-
-            // if category style, add minor ticks in between
-            temp = [];
-            if (this.category) {
-                // turn off gridline and mark on first tick
-                this._ticks[0].showGridline = false;
-                this._ticks[0].showMark = false;
-
-                for (i=this._ticks.length-1; i>0; i--) {
-                    t = new this.tickRenderer(this.tickOptions);
-                    t.value = this._ticks[i-1].value + this.tickInterval/2.0;
-                    t.label = '';
-                    t.showLabel = false;
-                    t.axis = this.name;
-                    this._ticks[i].showGridline = false;
-                    this._ticks[i].showMark = false;
-                    this._ticks.splice(i, 0, t);
-                    // temp.push(t);
-                }
-
-                // merge in the new ticks
-                // for (i=1, l=temp.length; i<l; i++) {
-                //     this._ticks.splice(i, 0, temp[i]);
-                // }
-
-                // now add a tick at beginning and end
-                t = new this.tickRenderer(this.tickOptions);
-                t.value = this._ticks[0].value - this.tickInterval/2.0;
-                t.label = '';
-                t.showLabel = false;
-                t.axis = this.name;
-                this._ticks.unshift(t);
-
-                t = new this.tickRenderer(this.tickOptions);
-                t.value = this._ticks[this._ticks.length-1].value + this.tickInterval/2.0;
-                t.label = '';
-                t.showLabel = false;
-                t.axis = this.name;
-                this._ticks.push(t);
-
-                this.tickInterval = this.tickInterval / 2.0;
-                this.numberTicks = this._ticks.length;
-                this.min = this._ticks[0].value;
-                this.max = this._ticks[this._ticks.length-1].value;
-            }
-        }
-
-        // we don't have any ticks yet, let's make some!
-        else {
-            if (this.name.charAt(0) === 'x') {
-                dim = this._plotDimensions.width;
-                // make sure x axis is symetric about 0.
-                var tempmax = Math.max(db.max, Math.abs(db.min));
-                var tempmin = Math.min(db.min, -tempmax);
-                // min = ((this.min != null) ? this.min : tempmin);
-                // max = ((this.max != null) ? this.max : tempmax);
-                min = tempmin;
-                max = tempmax;
-                range = max - min;
-
-                threshold = 30;
-                tdim = Math.max(dim, threshold+1);
-                scalefact =  (tdim-threshold)/300.0;
-                ret = $.jqplot.LinearTickGenerator(min, max, scalefact); 
-                // calculate a padded max and min, points should be less than these
-                // so that they aren't too close to the edges of the plot.
-                // User can adjust how much padding is allowed with pad, padMin and PadMax options. 
-                tumin = min + range*(this.padMin - 1);
-                tumax = max - range*(this.padMax - 1);
-
-                if (min <=tumin || max >= tumax) {
-                    tumin = min - range*(this.padMin - 1);
-                    tumax = max + range*(this.padMax - 1);
-                    ret = $.jqplot.LinearTickGenerator(tumin, tumax, scalefact);
-                }
-
-                this.min = ret[0];
-                this.max = ret[1];
-                this.numberTicks = ret[2];
-                this._autoFormatString = ret[3];
-                this.tickInterval = ret[4];
-            }
-            else {
-                dim = this._plotDimensions.height;
-
-                // ticks will be on whole integers like 1, 2, 3, ... or 1, 4, 7, ...
-                min = db.min;
-                max = db.max;
-                s = this._series[0];
-                this._ticks = [];
-
-                range = max - min;
-
-                // if range is a prime, will get only 2 ticks, expand range in that case.
-                if (_primesHash[range]) {
-                    range += 1;
-                    max += 1;
-                }
-
-                this.max = max;
-                this.min = min;
-                
-                maxVisibleTicks = Math.round(2.0 + dim/this.tickSpacingFactor);
-
-                if (range + 1 <= maxVisibleTicks) {
-                    this.numberTicks = range + 1;
-                    this.tickInterval = 1.0;
-                }
-
-                else {
-                    // figure out a round number of ticks to skip in every interval
-                    // range / ti + 1 = nt
-                    // ti = range / (nt - 1)
-                    for (var i=maxVisibleTicks; i>1; i--) {
-                        if (range/(i - 1) === Math.round(range/(i - 1))) {
-                            this.numberTicks = i;
-                            this.tickInterval = range/(i - 1);
-                            break;
-                        }
-                        
-                    }
-                }
-            }
-
-            var labelval;
-            for (i=0; i<this.numberTicks; i++) {
-                this.tickOptions.axis = this.name;
-                labelval = this.min + this.tickInterval * i;
-                if (this.name.charAt(0) === 'x') {
-                    labelval = Math.abs(labelval);
-                }
-                this.tickOptions.label = String (labelval);
-                this.tickOptions.value = this.min + this.tickInterval * i;
-                t = new this.tickRenderer(this.tickOptions);
-                this._ticks.push(t);
-                // for x axis, if y axis is in middle, add a symetrical 0 tick
-                if (this.name.charAt(0) === 'x' && plot.axes.yMidAxis.show && this.tickOptions.value === 0) {
-                    this._splitAxis = true;
-                    this._splitLength = plot.axes.yMidAxis.getWidth();
-                    // t.value = -this.max/2000.0;
-                    t = new this.tickRenderer(this.tickOptions);
-                    this._ticks.push(t);
-                    t.value = this.max/2000.0;
-                }
-            }
-            t = null;
-        }
-    };
-    
-    // called with scope of axis
-    $.jqplot.PyramidAxisRenderer.prototype.set = function() { 
-        var dim = 0;
-        var temp;
-        var w = 0;
-        var h = 0;
-        var i;
-        var t;
-        var tick;
-        var lshow = (this._label == null) ? false : this._label.show;
-        if (this.show) {
-            t = this._ticks;
-            l = t.length;
-            for (i=0; i<l; i++) {
-                tick = t[i];
-                if (!tick._breakTick && tick.show && tick.showLabel && !tick.isMinorTick) {
-                    if (this.name.charAt(0) === 'x') {
-                        temp = tick._elem.outerHeight(true);
-                    }
-                    else {
-                        temp = tick._elem.outerWidth(true);
-                    }
-                    if (temp > dim) {
-                        dim = temp;
-                    }
-                }
-            }
-
-            if (this.name === 'yMidAxis') {
-                for (i=0; i<l; i++) {
-                    tick = t[i];
-                    if (tick._elem) {
-                        temp = (dim - tick._elem.outerWidth(true))/2.0;
-                        tick._elem.css('left', temp);
-                    }
-                }
-            }
-            tick = null;
-            t = null;
-            
-            if (lshow) {
-                w = this._label._elem.outerWidth(true);
-                h = this._label._elem.outerHeight(true); 
-            }
-            if (this.name === 'xaxis') {
-                dim = dim + h;
-                this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'});
-            }
-            else if (this.name === 'x2axis') {
-                dim = dim + h;
-                this._elem.css({'height':dim+'px', left:'0px', top:'0px'});
-            }
-            else if (this.name === 'yaxis') {
-                dim = dim + w;
-                this._elem.css({'width':dim+'px', left:'0px', top:'0px'});
-                if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
-                    this._label._elem.css('width', w+'px');
-                }
-            }
-            else if (this.name === 'yMidAxis') {
-                // don't include width of label at all in width of axis?
-                // dim = (dim > w) ? dim : w;
-                var temp = dim/2.0 - w/2.0;
-                this._elem.css({'width':dim+'px', top:'0px'});
-                if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
-                    this._label._elem.css({width: w, left: temp, top: 0});
-                }
-            }
-            else {
-                dim = dim + w;
-                this._elem.css({'width':dim+'px', right:'0px', top:'0px'});
-                if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) {
-                    this._label._elem.css('width', w+'px');
-                }
-            }
-        }  
-    };
-    
-    $.jqplot.PyramidAxisRenderer.prototype.pack = function(pos, offsets) { 
-        // Add defaults for repacking from resetTickValues function.
-        pos = pos || {};
-        offsets = offsets || this._offsets;
-        
-        var ticks = this._ticks;
-        var max = this.max;
-        var min = this.min;
-        var offmax = offsets.max;
-        var offmin = offsets.min;
-        var lshow = (this._label == null) ? false : this._label.show;
-        
-        for (var p in pos) {
-            this._elem.css(p, pos[p]);
-        }
-        
-        this._offsets = offsets;
-        // pixellength will be + for x axes and - for y axes becasue pixels always measured from top left.
-        var pixellength = offmax - offmin;
-        var unitlength = max - min;
-        var sl = this._splitLength;
-        
-        // point to unit and unit to point conversions references to Plot DOM element top left corner.
-        if (this._splitAxis) {
-            pixellength -= this._splitLength;
-            
-            // don't know that this one is correct.
-            this.p2u = function(p){
-                return (p - offmin) * unitlength / pixellength + min;
-            };
-        
-            this.u2p = function(u){
-                if (u <= 0) {
-                    return (u - min) * pixellength / unitlength + offmin;
-                }
-                else {
-                    return (u - min) * pixellength / unitlength + offmin + sl;
-                }
-            };
-                
-            this.series_u2p = function(u){
-                if (u <= 0) {
-                    return (u - min) * pixellength / unitlength;
-                }
-                else {
-                    return (u - min) * pixellength / unitlength + sl;
-                }
-            };
-
-            // don't know that this one is correct.
-            this.series_p2u = function(p){
-                return p * unitlength / pixellength + min;
-            };
-        }
-        else {
-            this.p2u = function(p){
-                return (p - offmin) * unitlength / pixellength + min;
-            };
-        
-            this.u2p = function(u){
-                return (u - min) * pixellength / unitlength + offmin;
-            };
-                
-            if (this.name.charAt(0) === 'x'){
-                this.series_u2p = function(u){
-                    return (u - min) * pixellength / unitlength;
-                };
-                this.series_p2u = function(p){
-                    return p * unitlength / pixellength + min;
-                };
-            }
-        
-            else {
-                this.series_u2p = function(u){
-                    return (u - max) * pixellength / unitlength;
-                };
-                this.series_p2u = function(p){
-                    return p * unitlength / pixellength + max;
-                };
-            }
-        }
-        
-        if (this.show) {
-            if (this.name.charAt(0) === 'x') {
-                for (var i=0; i<ticks.length; i++) {
-                    var t = ticks[i];
-                    if (t.show && t.showLabel) {
-                        var shim;
-                        
-                        if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
-                            // will need to adjust auto positioning based on which axis this is.
-                            var temp = (this.name == 'xaxis') ? 1 : -1;
-                            switch (t.labelPosition) {
-                                case 'auto':
-                                    // position at end
-                                    if (temp * t.angle < 0) {
-                                        shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    }
-                                    // position at start
-                                    else {
-                                        shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'end':
-                                    shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                                case 'start':
-                                    shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    break;
-                                case 'middle':
-                                    shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                                default:
-                                    shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    break;
-                            }
-                        }
-                        else {
-                            shim = -t.getWidth()/2;
-                        }
-                        var val = this.u2p(t.value) + shim + 'px';
-                        t._elem.css('left', val);
-                        t.pack();
-                    }
-                }
-                if (lshow) {
-                    var w = this._label._elem.outerWidth(true);
-                    this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px');
-                    if (this.name == 'xaxis') {
-                        this._label._elem.css('bottom', '0px');
-                    }
-                    else {
-                        this._label._elem.css('top', '0px');
-                    }
-                    this._label.pack();
-                }
-            }
-            else {
-                for (var i=0; i<ticks.length; i++) {
-                    var t = ticks[i];
-                    if (t.show && t.showLabel && !t.isMinorTick) {                        
-                        var shim;
-                        if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) {
-                            // will need to adjust auto positioning based on which axis this is.
-                            var temp = (this.name == 'yaxis') ? 1 : -1;
-                            switch (t.labelPosition) {
-                                case 'auto':
-                                    // position at end
-                                case 'end':
-                                    if (temp * t.angle < 0) {
-                                        shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
-                                    }
-                                    else {
-                                        shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'start':
-                                    if (t.angle > 0) {
-                                        shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2;
-                                    }
-                                    else {
-                                        shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2;
-                                    }
-                                    break;
-                                case 'middle':
-                                    // if (t.angle > 0) {
-                                    //     shim = -t.getHeight()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2;
-                                    // }
-                                    // else {
-                                    //     shim = -t.getHeight()/2 - t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2;
-                                    // }
-                                    shim = -t.getHeight()/2;
-                                    break;
-                                default:
-                                    shim = -t.getHeight()/2;
-                                    break;
-                            }
-                        }
-                        else {
-                            shim = -t.getHeight()/2;
-                        }
-                        
-                        var val = this.u2p(t.value) + shim + 'px';
-                        t._elem.css('top', val);
-                        t.pack();
-                    }
-                }
-                if (lshow) {
-                    var h = this._label._elem.outerHeight(true);
-                    if (this.name !== 'yMidAxis') {
-                        this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px');
-                    }
-                    if (this.name == 'yaxis') {
-                        this._label._elem.css('left', '0px');
-                    }
-                    else if (this.name !== 'yMidAxis') {
-                        this._label._elem.css('right', '0px');
-                    }   
-                    this._label.pack();
-                }
-            }
-        }
-
-        ticks = null;
-    };
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidAxisRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidAxisRenderer.min.js
deleted file mode 100644
index ad6aa9d..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidAxisRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(e){e.jqplot.PyramidAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.PyramidAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.PyramidAxisRenderer.prototype.constructor=e.jqplot.PyramidAxisRenderer;e.jqplot.PyramidAxisRenderer.prototype.init=function(f){this.position=null;this.drawBaseline=true;this.baselineWidth=null;this.baselineColor=null;this.tickSpacingFactor=25;this._type="pyramid";this._splitAxis=false;this._splitLength=null;this.category=false;e.extend(true,this,f);this.renderer.options=f;this.resetDataBounds=this.renderer.resetDataBounds;this.resetDataBounds()};e.jqplot.PyramidAxisRenderer.prototype.resetDataBounds=function(){var h=this._dataBounds;h.min=null;h.max=null;var g;for(var m=0;m<this._series.length;m++){var n=this._series[m];var o=n._plotData;for(var k=0,f=o.length;k<f;k++){if(this.name.charAt(0)==="x"){g=o[k][1];if((g!==null&&g<h.min)||h.min===null){h.min=g}if((g!==null&&g>h.max)||h.max===null){h.max=g}}else{g=o[k][0];if((g!==null&&g<h.min)||h.min===null){h.min=g}if((g!==null&&g>h.max)||h.max===null){h.max=g}}}}};e.jqplot.PyramidAxisRenderer.prototype.draw=function(f,n){if(this.show){this.renderer.createTicks.call(this,n);var m=0;var g;if(this._elem){this._elem.emptyForce();this._elem=null}this._elem=e(document.createElement("div"));this._elem.addClass("jqplot-axis jqplot-"+this.name);this._elem.css("position","absolute");if(this.name=="xaxis"||this.name=="x2axis"){this._elem.width(this._plotDimensions.width)}else{this._elem.height(this._plotDimensions.height)}this.labelOptions.axis=this.name;this._label=new this.labelRenderer(this.labelOptions);if(this._label.show){var l=this._label.draw(f,n);l.appendTo(this._elem);l=null}var k=this._ticks;var j;for(var h=0;h<k.length;h++){j=k[h];if(j.show&&j.showLabel&&(!j.isMinorTick)){this._elem.append(j.draw(f,n))}}j=null;k=null}return this._elem};var b=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var d={};for(var c=0,a=b.length;c<a;c++){d[b[c]]=b[c]}e.jqplot.PyramidAxisRenderer.prototype.createTicks=function(D){var J=this.ticks;var M=this._dataBounds;var E;var K;var B;var G;var y;var n;var k;var h;var H;var C;var x;var L=this.min;var N=this.max;var q;var v;var m;var g;var j;var O;var A;var F;var r;var P;var z=null;var I;if(J.length){for(H=0,C=J.length;H<C;H++){q=J[H];v=new this.tickRenderer(this.tickOptions);if(e.isArray(q)){v.value=q[0];v.label=q[1];v.setTick(q[0],this.name);this._ticks.push(v)}else{if(e.isPlainObject(q)){e.extend(true,v,q);v.axis=this.name;this._ticks.push(v)}else{if(typeof q==="string"){P=H+D.defaultAxisStart}else{P=q}v.value=P;v.label=q;v.axis=this.name;this._ticks.push(v)}}}this.numberTicks=J.length;this.min=this._ticks[0].value;this.max=this._ticks[this.numberTicks-1].value;this.tickInterval=(this.max-this.min)/(this.numberTicks-1);if(this._options.tickInterval){var o=this._options.tickInterval;for(H=0;H<this.numberTicks;H++){if(H%o!==0){this._ticks[H].isMinorTick=true}}}else{E=(this.name.charAt(0)==="x")?this._plotDimensions.width:this._plotDimensions.height;r=Math.round(2+E/this.tickSpacingFactor);if(this.numberTicks>r){I=this.numberTicks-1;for(H=2;H<I;H++){if(I%H===0&&I/H<r){z=H-1;break}}if(z!==null){var p=1;for(H=1,C=this._ticks.length;H<C;H++){if(p<=z){this._ticks[H].show=false;p+=1}else{p=1}}}}}I=[];if(this.category){this._ticks[0].showGridline=false;this._ticks[0].showMark=false;for(H=this._ticks.length-1;H>0;H--){v=new this.tickRenderer(this.tickOptions);v.value=this._ticks[H-1].value+this.tickInterval/2;v.label="";v.showLabel=false;v.axis=this.name;this._ticks[H].showGridline=false;this._ticks[H].showMark=false;this._ticks.splice(H,0,v)}v=new this.tickRenderer(this.tickOptions);v.value=this._ticks[0].value-this.tickInterval/2;v.label="";v.showLabel=false;v.axis=this.name;this._ticks.unshift(v);v=new this.tickRenderer(this.tickOptions);v.value=this._ticks[this._ticks.length-1].value+this.tickInterval/2;v.label="";v.showLabel=false;v.axis=this.name;this._ticks.push(v);this.tickInterval=this.tickInterval/2;this.numberTicks=this._ticks.length;this.min=this._ticks[0].value;this.max=this._ticks[this._ticks.length-1].value}}else{if(this.name.charAt(0)==="x"){E=this._plotDimensions.width;var w=Math.max(M.max,Math.abs(M.min));var u=Math.min(M.min,-w);B=u;G=w;y=G-B;m=30;g=Math.max(E,m+1);j=(g-m)/300;O=e.jqplot.LinearTickGenerator(B,G,j);A=B+y*(this.padMin-1);F=G-y*(this.padMax-1);if(B<=A||G>=F){A=B-y*(this.padMin-1);F=G+y*(this.padMax-1);O=e.jqplot.LinearTickGenerator(A,F,j)}this.min=O[0];this.max=O[1];this.numberTicks=O[2];this._autoFormatString=O[3];this.tickInterval=O[4]}else{E=this._plotDimensions.height;B=M.min;G=M.max;x=this._series[0];this._ticks=[];y=G-B;if(d[y]){y+=1;G+=1}this.max=G;this.min=B;r=Math.round(2+E/this.tickSpacingFactor);if(y+1<=r){this.numberTicks=y+1;this.tickInterval=1}else{for(var H=r;H>1;H--){if(y/(H-1)===Math.round(y/(H-1))){this.numberTicks=H;this.tickInterval=y/(H-1);break}}}}var f;for(H=0;H<this.numberTicks;H++){this.tickOptions.axis=this.name;f=this.min+this.tickInterval*H;if(this.name.charAt(0)==="x"){f=Math.abs(f)}this.tickOptions.label=String(f);this.tickOptions.value=this.min+this.tickInterval*H;v=new this.tickRenderer(this.tickOptions);this._ticks.push(v);if(this.name.charAt(0)==="x"&&D.axes.yMidAxis.show&&this.tickOptions.value===0){this._splitAxis=true;this._splitLength=D.axes.yMidAxis.getWidth();v=new this.tickRenderer(this.tickOptions);this._ticks.push(v);v.value=this.max/2000}}v=null}};e.jqplot.PyramidAxisRenderer.prototype.set=function(){var o=0;var j;var g=0;var n=0;var m;var l;var k;var f=(this._label==null)?false:this._label.show;if(this.show){l=this._ticks;a=l.length;for(m=0;m<a;m++){k=l[m];if(!k._breakTick&&k.show&&k.showLabel&&!k.isMinorTick){if(this.name.charAt(0)==="x"){j=k._elem.outerHeight(true)}else{j=k._elem.outerWidth(true)}if(j>o){o=j}}}if(this.name==="yMidAxis"){for(m=0;m<a;m++){k=l[m];if(k._elem){j=(o-k._elem.outerWidth(true))/2;k._elem.css("left",j)}}}k=null;l=null;if(f){g=this._label._elem.outerWidth(true);n=this._label._elem.outerHeight(true)}if(this.name==="xaxis"){o=o+n;this._elem.css({height:o+"px",left:"0px",bottom:"0px"})}else{if(this.name==="x2axis"){o=o+n;this._elem.css({height:o+"px",left:"0px",top:"0px"})}else{if(this.name==="yaxis"){o=o+g;this._elem.css({width:o+"px",left:"0px",top:"0px"});if(f&&this._label.constructor==e.jqplot.AxisLabelRenderer){this._label._elem.css("width",g+"px")}}else{if(this.name==="yMidAxis"){var j=o/2-g/2;this._elem.css({width:o+"px",top:"0px"});if(f&&this._label.constructor==e.jqplot.AxisLabelRenderer){this._label._elem.css({width:g,left:j,top:0})}}else{o=o+g;this._elem.css({width:o+"px",right:"0px",top:"0px"});if(f&&this._label.constructor==e.jqplot.AxisLabelRenderer){this._label._elem.css("width",g+"px")}}}}}}};e.jqplot.PyramidAxisRenderer.prototype.pack=function(j,g){j=j||{};g=g||this._offsets;var B=this._ticks;var v=this.max;var u=this.min;var o=g.max;var m=g.min;var r=(this._label==null)?false:this._label.show;for(var s in j){this._elem.css(s,j[s])}this._offsets=g;var k=o-m;var l=v-u;var z=this._splitLength;if(this._splitAxis){k-=this._splitLength;this.p2u=function(h){return(h-m)*l/k+u};this.u2p=function(h){if(h<=0){return(h-u)*k/l+m}else{return(h-u)*k/l+m+z}};this.series_u2p=function(h){if(h<=0){return(h-u)*k/l}else{return(h-u)*k/l+z}};this.series_p2u=function(h){return h*l/k+u}}else{this.p2u=function(h){return(h-m)*l/k+u};this.u2p=function(h){return(h-u)*k/l+m};if(this.name.charAt(0)==="x"){this.series_u2p=function(h){return(h-u)*k/l};this.series_p2u=function(h){return h*l/k+u}}else{this.series_u2p=function(h){return(h-v)*k/l};this.series_p2u=function(h){return h*l/k+v}}}if(this.show){if(this.name.charAt(0)==="x"){for(var x=0;x<B.length;x++){var q=B[x];if(q.show&&q.showLabel){var f;if(q.constructor==e.jqplot.CanvasAxisTickRenderer&&q.angle){var A=(this.name=="xaxis")?1:-1;switch(q.labelPosition){case"auto":if(A*q.angle<0){f=-q.getWidth()+q._textRenderer.height*Math.sin(-q._textRenderer.angle)/2}else{f=-q._textRenderer.height*Math.sin(q._textRenderer.angle)/2}break;case"end":f=-q.getWidth()+q._textRenderer.height*Math.sin(-q._textRenderer.angle)/2;break;case"start":f=-q._textRenderer.height*Math.sin(q._textRenderer.angle)/2;break;case"middle":f=-q.getWidth()/2+q._textRenderer.height*Math.sin(-q._textRenderer.angle)/2;break;default:f=-q.getWidth()/2+q._textRenderer.height*Math.sin(-q._textRenderer.angle)/2;break}}else{f=-q.getWidth()/2}var C=this.u2p(q.value)+f+"px";q._elem.css("left",C);q.pack()}}if(r){var n=this._label._elem.outerWidth(true);this._label._elem.css("left",m+k/2-n/2+"px");if(this.name=="xaxis"){this._label._elem.css("bottom","0px")}else{this._label._elem.css("top","0px")}this._label.pack()}}else{for(var x=0;x<B.length;x++){var q=B[x];if(q.show&&q.showLabel&&!q.isMinorTick){var f;if(q.constructor==e.jqplot.CanvasAxisTickRenderer&&q.angle){var A=(this.name=="yaxis")?1:-1;switch(q.labelPosition){case"auto":case"end":if(A*q.angle<0){f=-q._textRenderer.height*Math.cos(-q._textRenderer.angle)/2}else{f=-q.getHeight()+q._textRenderer.height*Math.cos(q._textRenderer.angle)/2}break;case"start":if(q.angle>0){f=-q._textRenderer.height*Math.cos(-q._textRenderer.angle)/2}else{f=-q.getHeight()+q._textRenderer.height*Math.cos(q._textRenderer.angle)/2}break;case"middle":f=-q.getHeight()/2;break;default:f=-q.getHeight()/2;break}}else{f=-q.getHeight()/2}var C=this.u2p(q.value)+f+"px";q._elem.css("top",C);q.pack()}}if(r){var y=this._label._elem.outerHeight(true);if(this.name!=="yMidAxis"){this._label._elem.css("top",o-k/2-y/2+"px")}if(this.name=="yaxis"){this._label._elem.css("left","0px")}else{if(this.name!=="yMidAxis"){this._label._elem.css("right","0px")}}this._label.pack()}}}B=null}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidGridRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidGridRenderer.js
deleted file mode 100644
index 522bdc1..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidGridRenderer.js
+++ /dev/null
@@ -1,423 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {     
-    // Class: $.jqplot.CanvasGridRenderer
-    // The default jqPlot grid renderer, creating a grid on a canvas element.
-    // The renderer has no additional options beyond the <Grid> class.
-    $.jqplot.PyramidGridRenderer = function(){
-        $.jqplot.CanvasGridRenderer.call(this);
-    };
-
-    $.jqplot.PyramidGridRenderer.prototype = new $.jqplot.CanvasGridRenderer();
-    $.jqplot.PyramidGridRenderer.prototype.constructor = $.jqplot.PyramidGridRenderer;
-    
-    // called with context of Grid object
-    $.jqplot.CanvasGridRenderer.prototype.init = function(options) {
-        this._ctx;
-        this.plotBands = {
-            show: false,
-            color: 'rgb(230, 219, 179)',
-            axis: 'y',
-            start: null,
-            interval: 10
-        };
-        $.extend(true, this, options);
-        // set the shadow renderer options
-        var sopts = {lineJoin:'miter', lineCap:'round', fill:false, isarc:false, angle:this.shadowAngle, offset:this.shadowOffset, alpha:this.shadowAlpha, depth:this.shadowDepth, lineWidth:this.shadowWidth, closePath:false, strokeStyle:this.shadowColor};
-        this.renderer.shadowRenderer.init(sopts);
-    };
-    
-    $.jqplot.PyramidGridRenderer.prototype.draw = function() {
-        this._ctx = this._elem.get(0).getContext("2d");
-        var ctx = this._ctx;
-        var axes = this._axes;
-        var xp = axes.xaxis.u2p;
-        var yp = axes.yMidAxis.u2p;
-        var xnudge = axes.xaxis.max/1000.0;
-        var xp0 = xp(0);
-        var xpn = xp(xnudge);
-        var ax = ['xaxis', 'yaxis', 'x2axis', 'y2axis','yMidAxis'];
-        // Add the grid onto the grid canvas.  This is the bottom most layer.
-        ctx.save();
-        ctx.clearRect(0, 0, this._plotDimensions.width, this._plotDimensions.height);
-        ctx.fillStyle = this.backgroundColor || this.background;
-
-        ctx.fillRect(this._left, this._top, this._width, this._height);
-
-        if (this.plotBands.show) {
-            ctx.save();
-            var pb = this.plotBands;
-            ctx.fillStyle = pb.color;
-            var axis;
-            var x, y, w, h;
-            // find axis to work with
-            if (pb.axis.charAt(0) === 'x') {
-                if (axes.xaxis.show) {
-                    axis = axes.xaxis;
-                }
-            }
-            else if (pb.axis.charAt(0) === 'y') {
-                if (axes.yaxis.show) {
-                    axis = axes.yaxis;
-                }
-                else if (axes.y2axis.show) {
-                    axis = axes.y2axis;
-                }
-                else if (axes.yMidAxis.show) {
-                    axis = axes.yMidAxis;
-                }
-            }
-
-            if (axis !== undefined) {
-                // draw some rectangles
-                var start = pb.start;
-                if (start === null) {
-                    start = axis.min;
-                }
-                for (var i = start; i < axis.max; i += 2 * pb.interval) {
-                    if (axis.name.charAt(0) === 'y') {
-                        x = this._left;
-                        y = axis.series_u2p(i + pb.interval) + this._top;
-                        w = this._right - this._left;
-                        h = axis.series_u2p(start) - axis.series_u2p(start + pb.interval);
-                        ctx.fillRect(x, y, w, h);
-                    }
-                    // else {
-                    //     y = 0;
-                    //     x = axis.series_u2p(i);
-                    //     h = this._height;
-                    //     w = axis.series_u2p(start + pb.interval) - axis.series_u2p(start);
-                    // }
-
-                }
-            }
-            ctx.restore();
-        }
-        
-        ctx.save();
-        ctx.lineJoin = 'miter';
-        ctx.lineCap = 'butt';
-        ctx.lineWidth = this.gridLineWidth;
-        ctx.strokeStyle = this.gridLineColor;
-        var b, e, s, m;
-        for (var i=5; i>0; i--) {
-            var name = ax[i-1];
-            var axis = axes[name];
-            var ticks = axis._ticks;
-            var numticks = ticks.length;
-            if (axis.show) {
-                if (axis.drawBaseline) {
-                    var bopts = {};
-                    if (axis.baselineWidth !== null) {
-                        bopts.lineWidth = axis.baselineWidth;
-                    }
-                    if (axis.baselineColor !== null) {
-                        bopts.strokeStyle = axis.baselineColor;
-                    }
-                    switch (name) {
-                        case 'xaxis':
-                            if (axes.yMidAxis.show) {
-                                drawLine (this._left, this._bottom, xp0, this._bottom, bopts);
-                                drawLine (xpn, this._bottom, this._right, this._bottom, bopts);
-                            }
-                            else {
-                                drawLine (this._left, this._bottom, this._right, this._bottom, bopts);
-                            }
-                            break;
-                        case 'yaxis':
-                            drawLine (this._left, this._bottom, this._left, this._top, bopts);
-                            break;
-                        case 'yMidAxis':               
-                            drawLine(xp0, this._bottom, xp0, this._top, bopts);
-                            drawLine(xpn, this._bottom, xpn, this._top, bopts);
-                            break;
-                        case 'x2axis':
-                            if (axes.yMidAxis.show) {
-                                drawLine (this._left, this._top, xp0, this._top, bopts);
-                                drawLine (xpn, this._top, this._right, this._top, bopts);
-                            }
-                            else {
-                                drawLine (this._left, this._bottom, this._right, this._bottom, bopts);
-                            }
-                            break;
-                        case 'y2axis':
-                            drawLine (this._right, this._bottom, this._right, this._top, bopts);
-                            break;
-
-                    }
-                }
-                for (var j=numticks; j>0; j--) {
-                    var t = ticks[j-1];
-                    if (t.show) {
-                        var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                        switch (name) {
-                            case 'xaxis':
-                                // draw the grid line if we should
-                                if (t.showGridline && this.drawGridlines && (!t.isMinorTick || axis.showMinorTicks)) {
-                                    drawLine(pos, this._top, pos, this._bottom);
-                                }
-                                
-                                // draw the mark
-                                if (t.showMark && t.mark && (!t.isMinorTick || axis.showMinorTicks)) {
-                                    s = t.markSize;
-                                    m = t.mark;
-                                    var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                                    switch (m) {
-                                        case 'outside':
-                                            b = this._bottom;
-                                            e = this._bottom+s;
-                                            break;
-                                        case 'inside':
-                                            b = this._bottom-s;
-                                            e = this._bottom;
-                                            break;
-                                        case 'cross':
-                                            b = this._bottom-s;
-                                            e = this._bottom+s;
-                                            break;
-                                        default:
-                                            b = this._bottom;
-                                            e = this._bottom+s;
-                                            break;
-                                    }
-                                    // draw the shadow
-                                    if (this.shadow) {
-                                        this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false});
-                                    }
-                                    // draw the line
-                                    drawLine(pos, b, pos, e);
-                                }
-                                break;
-                            case 'yaxis':
-                                // draw the grid line
-                                if (t.showGridline && this.drawGridlines && (!t.isMinorTick || axis.showMinorTicks)) {
-                                    drawLine(this._right, pos, this._left, pos);
-                                }
-
-                                // draw the mark
-                                if (t.showMark && t.mark && (!t.isMinorTick || axis.showMinorTicks)) {
-                                    s = t.markSize;
-                                    m = t.mark;
-                                    var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                                    switch (m) {
-                                        case 'outside':
-                                            b = this._left-s;
-                                            e = this._left;
-                                            break;
-                                        case 'inside':
-                                            b = this._left;
-                                            e = this._left+s;
-                                            break;
-                                        case 'cross':
-                                            b = this._left-s;
-                                            e = this._left+s;
-                                            break;
-                                        default:
-                                            b = this._left-s;
-                                            e = this._left;
-                                            break;
-                                            }
-                                    // draw the shadow
-                                    if (this.shadow) {
-                                        this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
-                                    }
-                                    drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
-                                }
-                                break;
-                            case 'yMidAxis':
-                                // draw the grid line
-                                if (t.showGridline && this.drawGridlines && (!t.isMinorTick || axis.showMinorTicks)) {
-                                    drawLine(this._left, pos, xp0, pos);
-                                    drawLine(xpn, pos, this._right, pos);
-                                }
-                                // draw the mark
-                                if (t.showMark && t.mark && (!t.isMinorTick || axis.showMinorTicks)) {
-                                    s = t.markSize;
-                                    m = t.mark;
-                                    var pos = Math.round(axis.u2p(t.value)) + 0.5;
-
-                                    b = xp0;
-                                    e = xp0 + s;
-                                    // draw the shadow
-                                    if (this.shadow) {
-                                        this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
-                                    }
-                                    drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
-
-                                    b = xpn - s;
-                                    e = xpn;
-                                    // draw the shadow
-                                    if (this.shadow) {
-                                        this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
-                                    }
-                                    drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
-                                }
-                                break;
-                            case 'x2axis':
-                                // draw the grid line
-                                if (t.showGridline && this.drawGridlines && (!t.isMinorTick || axis.showMinorTicks)) {
-                                    drawLine(pos, this._bottom, pos, this._top);
-                                }
-
-                                // draw the mark
-                                if (t.showMark && t.mark && (!t.isMinorTick || axis.showMinorTicks)) {
-                                    s = t.markSize;
-                                    m = t.mark;
-                                    var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                                    switch (m) {
-                                        case 'outside':
-                                            b = this._top-s;
-                                            e = this._top;
-                                            break;
-                                        case 'inside':
-                                            b = this._top;
-                                            e = this._top+s;
-                                            break;
-                                        case 'cross':
-                                            b = this._top-s;
-                                            e = this._top+s;
-                                            break;
-                                        default:
-                                            b = this._top-s;
-                                            e = this._top;
-                                            break;
-                                            }
-                                    // draw the shadow
-                                    if (this.shadow) {
-                                        this.renderer.shadowRenderer.draw(ctx, [[pos,b],[pos,e]], {lineCap:'butt', lineWidth:this.gridLineWidth, offset:this.gridLineWidth*0.75, depth:2, fill:false, closePath:false});
-                                    }
-                                    drawLine(pos, b, pos, e);
-                                }
-                                break;
-                            case 'y2axis':
-                                // draw the grid line
-                                if (t.showGridline && this.drawGridlines && (!t.isMinorTick || axis.showMinorTicks)) {
-                                    drawLine(this._left, pos, this._right, pos);
-                                }
-
-                                // draw the mark
-                                if (t.showMark && t.mark && (!t.isMinorTick || axis.showMinorTicks)) {
-                                    s = t.markSize;
-                                    m = t.mark;
-                                    var pos = Math.round(axis.u2p(t.value)) + 0.5;
-                                    switch (m) {
-                                        case 'outside':
-                                            b = this._right;
-                                            e = this._right+s;
-                                            break;
-                                        case 'inside':
-                                            b = this._right-s;
-                                            e = this._right;
-                                            break;
-                                        case 'cross':
-                                            b = this._right-s;
-                                            e = this._right+s;
-                                            break;
-                                        default:
-                                            b = this._right;
-                                            e = this._right+s;
-                                            break;
-                                            }
-                                    // draw the shadow
-                                    if (this.shadow) {
-                                        this.renderer.shadowRenderer.draw(ctx, [[b, pos], [e, pos]], {lineCap:'butt', lineWidth:this.gridLineWidth*1.5, offset:this.gridLineWidth*0.75, fill:false, closePath:false});
-                                    }
-                                    drawLine(b, pos, e, pos, {strokeStyle:axis.borderColor});
-                                }
-                                break;
-                            default:
-                                break;
-                        }
-                    }
-                }
-                t = null;
-            }
-            axis = null;
-            ticks = null;
-        }
-        
-        ctx.restore();
-        
-        function drawLine(bx, by, ex, ey, opts) {
-            ctx.save();
-            opts = opts || {};
-            if (opts.lineWidth == null || opts.lineWidth != 0){
-                $.extend(true, ctx, opts);
-                ctx.beginPath();
-                ctx.moveTo(bx, by);
-                ctx.lineTo(ex, ey);
-                ctx.stroke();
-            }
-            ctx.restore();
-        }
-        
-        if (this.shadow) {
-            if (axes.yMidAxis.show) {
-                var points = [[this._left, this._bottom], [xp0, this._bottom]];
-                this.renderer.shadowRenderer.draw(ctx, points);
-                var points = [[xpn, this._bottom], [this._right, this._bottom], [this._right, this._top]];
-                this.renderer.shadowRenderer.draw(ctx, points);
-                var points = [[xp0, this._bottom], [xp0, this._top]];
-                this.renderer.shadowRenderer.draw(ctx, points);
-            }
-            else {
-                var points = [[this._left, this._bottom], [this._right, this._bottom], [this._right, this._top]];
-                this.renderer.shadowRenderer.draw(ctx, points);
-            }
-        }
-        // Now draw border around grid.  Use axis border definitions. start at
-        // upper left and go clockwise.
-        if (this.borderWidth != 0 && this.drawBorder) {
-            if (axes.yMidAxis.show) {
-                drawLine (this._left, this._top, xp0, this._top, {lineCap:'round', strokeStyle:axes.x2axis.borderColor, lineWidth:axes.x2axis.borderWidth});
-                drawLine (xpn, this._top, this._right, this._top, {lineCap:'round', strokeStyle:axes.x2axis.borderColor, lineWidth:axes.x2axis.borderWidth});
-                drawLine (this._right, this._top, this._right, this._bottom, {lineCap:'round', strokeStyle:axes.y2axis.borderColor, lineWidth:axes.y2axis.borderWidth});
-                drawLine (this._right, this._bottom, xpn, this._bottom, {lineCap:'round', strokeStyle:axes.xaxis.borderColor, lineWidth:axes.xaxis.borderWidth});
-                drawLine (xp0, this._bottom, this._left, this._bottom, {lineCap:'round', strokeStyle:axes.xaxis.borderColor, lineWidth:axes.xaxis.borderWidth});
-                drawLine (this._left, this._bottom, this._left, this._top, {lineCap:'round', strokeStyle:axes.yaxis.borderColor, lineWidth:axes.yaxis.borderWidth});
-                drawLine (xp0, this._bottom, xp0, this._top, {lineCap:'round', strokeStyle:axes.yaxis.borderColor, lineWidth:axes.yaxis.borderWidth});
-                drawLine (xpn, this._bottom, xpn, this._top, {lineCap:'round', strokeStyle:axes.yaxis.borderColor, lineWidth:axes.yaxis.borderWidth});
-            }
-            else {
-                drawLine (this._left, this._top, this._right, this._top, {lineCap:'round', strokeStyle:axes.x2axis.borderColor, lineWidth:axes.x2axis.borderWidth});
-                drawLine (this._right, this._top, this._right, this._bottom, {lineCap:'round', strokeStyle:axes.y2axis.borderColor, lineWidth:axes.y2axis.borderWidth});
-                drawLine (this._right, this._bottom, this._left, this._bottom, {lineCap:'round', strokeStyle:axes.xaxis.borderColor, lineWidth:axes.xaxis.borderWidth});
-                drawLine (this._left, this._bottom, this._left, this._top, {lineCap:'round', strokeStyle:axes.yaxis.borderColor, lineWidth:axes.yaxis.borderWidth});
-            }
-        }
-        // ctx.lineWidth = this.borderWidth;
-        // ctx.strokeStyle = this.borderColor;
-        // ctx.strokeRect(this._left, this._top, this._width, this._height);
-        
-        ctx.restore();
-        ctx =  null;
-        axes = null;
-    };
-})(jQuery); 
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidGridRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidGridRenderer.min.js
deleted file mode 100644
index 78395e6..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidGridRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(a){a.jqplot.PyramidGridRenderer=function(){a.jqplot.CanvasGridRenderer.call(this)};a.jqplot.PyramidGridRenderer.prototype=new a.jqplot.CanvasGridRenderer();a.jqplot.PyramidGridRenderer.prototype.constructor=a.jqplot.PyramidGridRenderer;a.jqplot.CanvasGridRenderer.prototype.init=function(c){this._ctx;this.plotBands={show:false,color:"rgb(230, 219, 179)",axis:"y",start:null,interval:10};a.extend(true,this,c);var b={lineJoin:"miter",lineCap:"round",fill:false,isarc:false,angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,depth:this.shadowDepth,lineWidth:this.shadowWidth,closePath:false,strokeStyle:this.shadowColor};this.renderer.shadowRenderer.init(b)};a.jqplot.PyramidGridRenderer.prototype.draw=function(){this._ctx=this._elem.get(0).getContext("2d");var D=this._ctx;var G=this._axes;var q=G.xaxis.u2p;var J=G.yMidAxis.u2p;var l=G.xaxis.max/1000;var u=q(0);var f=q(l);var r=["xaxis","yaxis","x2axis","y2axis","yMidAxis"];D.save();D.clearRect(0,0,this._plotDimensions.width,this._plotDimensions.height);D.fillStyle=this.backgroundColor||this.background;D.fillRect(this._left,this._top,this._width,this._height);if(this.plotBands.show){D.save();var c=this.plotBands;D.fillStyle=c.color;var d;var o,n,p,I;if(c.axis.charAt(0)==="x"){if(G.xaxis.show){d=G.xaxis}}else{if(c.axis.charAt(0)==="y"){if(G.yaxis.show){d=G.yaxis}else{if(G.y2axis.show){d=G.y2axis}else{if(G.yMidAxis.show){d=G.yMidAxis}}}}}if(d!==undefined){var g=c.start;if(g===null){g=d.min}for(var H=g;H<d.max;H+=2*c.interval){if(d.name.charAt(0)==="y"){o=this._left;n=d.series_u2p(H+c.interval)+this._top;p=this._right-this._left;I=d.series_u2p(g)-d.series_u2p(g+c.interval);D.fillRect(o,n,p,I)}}}D.restore()}D.save();D.lineJoin="miter";D.lineCap="butt";D.lineWidth=this.gridLineWidth;D.strokeStyle=this.gridLineColor;var L,K,A,C;for(var H=5;H>0;H--){var O=r[H-1];var d=G[O];var M=d._ticks;var B=M.length;if(d.show){if(d.drawBaseline){var N={};if(d.baselineWidth!==null){N.lineWidth=d.baselineWidth}if(d.baselineColor!==null){N.strokeStyle=d.baselineColor}switch(O){case"xaxis":if(G.yMidAxis.show){z(this._left,this._bottom,u,this._bottom,N);z(f,this._bottom,this._right,this._bottom,N)}else{z(this._left,this._bottom,this._right,this._bottom,N)}break;case"yaxis":z(this._left,this._bottom,this._left,this._top,N);break;case"yMidAxis":z(u,this._bottom,u,this._top,N);z(f,this._bottom,f,this._top,N);break;case"x2axis":if(G.yMidAxis.show){z(this._left,this._top,u,this._top,N);z(f,this._top,this._right,this._top,N)}else{z(this._left,this._bottom,this._right,this._bottom,N)}break;case"y2axis":z(this._right,this._bottom,this._right,this._top,N);break}}for(var E=B;E>0;E--){var v=M[E-1];if(v.show){var k=Math.round(d.u2p(v.value))+0.5;switch(O){case"xaxis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(k,this._top,k,this._bottom)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._bottom;K=this._bottom+A;break;case"inside":L=this._bottom-A;K=this._bottom;break;case"cross":L=this._bottom-A;K=this._bottom+A;break;default:L=this._bottom;K=this._bottom+A;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[k,L],[k,K]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}z(k,L,k,K)}break;case"yaxis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(this._right,k,this._left,k)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._left-A;K=this._left;break;case"inside":L=this._left;K=this._left+A;break;case"cross":L=this._left-A;K=this._left+A;break;default:L=this._left-A;K=this._left;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor})}break;case"yMidAxis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(this._left,k,u,k);z(f,k,this._right,k)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;L=u;K=u+A;if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor});L=f-A;K=f;if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor})}break;case"x2axis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(k,this._bottom,k,this._top)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._top-A;K=this._top;break;case"inside":L=this._top;K=this._top+A;break;case"cross":L=this._top-A;K=this._top+A;break;default:L=this._top-A;K=this._top;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[k,L],[k,K]],{lineCap:"butt",lineWidth:this.gridLineWidth,offset:this.gridLineWidth*0.75,depth:2,fill:false,closePath:false})}z(k,L,k,K)}break;case"y2axis":if(v.showGridline&&this.drawGridlines&&(!v.isMinorTick||d.showMinorTicks)){z(this._left,k,this._right,k)}if(v.showMark&&v.mark&&(!v.isMinorTick||d.showMinorTicks)){A=v.markSize;C=v.mark;var k=Math.round(d.u2p(v.value))+0.5;switch(C){case"outside":L=this._right;K=this._right+A;break;case"inside":L=this._right-A;K=this._right;break;case"cross":L=this._right-A;K=this._right+A;break;default:L=this._right;K=this._right+A;break}if(this.shadow){this.renderer.shadowRenderer.draw(D,[[L,k],[K,k]],{lineCap:"butt",lineWidth:this.gridLineWidth*1.5,offset:this.gridLineWidth*0.75,fill:false,closePath:false})}z(L,k,K,k,{strokeStyle:d.borderColor})}break;default:break}}}v=null}d=null;M=null}D.restore();function z(j,i,e,b,h){D.save();h=h||{};if(h.lineWidth==null||h.lineWidth!=0){a.extend(true,D,h);D.beginPath();D.moveTo(j,i);D.lineTo(e,b);D.stroke()}D.restore()}if(this.shadow){if(G.yMidAxis.show){var F=[[this._left,this._bottom],[u,this._bottom]];this.renderer.shadowRenderer.draw(D,F);var F=[[f,this._bottom],[this._right,this._bottom],[this._right,this._top]];this.renderer.shadowRenderer.draw(D,F);var F=[[u,this._bottom],[u,this._top]];this.renderer.shadowRenderer.draw(D,F)}else{var F=[[this._left,this._bottom],[this._right,this._bottom],[this._right,this._top]];this.renderer.shadowRenderer.draw(D,F)}}if(this.borderWidth!=0&&this.drawBorder){if(G.yMidAxis.show){z(this._left,this._top,u,this._top,{lineCap:"round",strokeStyle:G.x2axis.borderColor,lineWidth:G.x2axis.borderWidth});z(f,this._top,this._right,this._top,{lineCap:"round",strokeStyle:G.x2axis.borderColor,lineWidth:G.x2axis.borderWidth});z(this._right,this._top,this._right,this._bottom,{lineCap:"round",strokeStyle:G.y2axis.borderColor,lineWidth:G.y2axis.borderWidth});z(this._right,this._bottom,f,this._bottom,{lineCap:"round",strokeStyle:G.xaxis.borderColor,lineWidth:G.xaxis.borderWidth});z(u,this._bottom,this._left,this._bottom,{lineCap:"round",strokeStyle:G.xaxis.borderColor,lineWidth:G.xaxis.borderWidth});z(this._left,this._bottom,this._left,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth});z(u,this._bottom,u,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth});z(f,this._bottom,f,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth})}else{z(this._left,this._top,this._right,this._top,{lineCap:"round",strokeStyle:G.x2axis.borderColor,lineWidth:G.x2axis.borderWidth});z(this._right,this._top,this._right,this._bottom,{lineCap:"round",strokeStyle:G.y2axis.borderColor,lineWidth:G.y2axis.borderWidth});z(this._right,this._bottom,this._left,this._bottom,{lineCap:"round",strokeStyle:G.xaxis.borderColor,lineWidth:G.xaxis.borderWidth});z(this._left,this._bottom,this._left,this._top,{lineCap:"round",strokeStyle:G.yaxis.borderColor,lineWidth:G.yaxis.borderWidth})}}D.restore();D=null;G=null}})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidRenderer.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidRenderer.js
deleted file mode 100644
index 20e8961..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidRenderer.js
+++ /dev/null
@@ -1,482 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-
-    // Need to ensure pyramid axis and grid renderers are loaded.
-    // You should load these with script tags in the html head, that is more efficient
-    // as the browser will cache the request.
-    // Note, have to block with synchronous request in order to execute bar renderer code.
-    if ($.jqplot.PyramidAxisRenderer === undefined) {
-        $.ajax({
-            url: $.jqplot.pluginLocation + 'jqplot.pyramidAxisRenderer.js',
-            dataType: "script",
-            async: false
-        });
-    }
-    
-    if ($.jqplot.PyramidGridRenderer === undefined) {
-        $.ajax({
-            url: $.jqplot.pluginLocation + 'jqplot.pyramidGridRenderer.js',
-            dataType: "script",
-            async: false
-        });
-    }
-
-    $.jqplot.PyramidRenderer = function(){
-        $.jqplot.LineRenderer.call(this);
-    };
-    
-    $.jqplot.PyramidRenderer.prototype = new $.jqplot.LineRenderer();
-    $.jqplot.PyramidRenderer.prototype.constructor = $.jqplot.PyramidRenderer;
-    
-    // called with scope of a series
-    $.jqplot.PyramidRenderer.prototype.init = function(options, plot) {
-        options = options || {};
-        this._type = 'pyramid';
-        // Group: Properties
-        //
-        // prop: barPadding
-        this.barPadding = 10;
-        this.barWidth = null;
-        // prop: fill
-        // True to fill the bars.
-        this.fill = true;
-        // prop: highlightMouseOver
-        // True to highlight slice when moused over.
-        // This must be false to enable highlightMouseDown to highlight when clicking on a slice.
-        this.highlightMouseOver = true;
-        // prop: highlightMouseDown
-        // True to highlight when a mouse button is pressed over a slice.
-        // This will be disabled if highlightMouseOver is true.
-        this.highlightMouseDown = false;
-        // prop: highlightColors
-        // an array of colors to use when highlighting a slice.
-        this.highlightColors = [];
-        
-        // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
-        if (options.highlightMouseDown && options.highlightMouseOver == null) {
-            options.highlightMouseOver = false;
-        }
-
-        this.side = 'right';
-        
-        $.extend(true, this, options);
-
-        // if (this.fill === false) {
-        //     this.shadow = false;
-        // }
-        
-        this.renderer.options = options;
-        // index of the currenty highlighted point, if any
-        this._highlightedPoint = null;
-        // Array of actual data colors used for each data point.
-        this._dataColors = [];
-        this._barPoints = [];
-        this.fillAxis = 'y';
-        this._primaryAxis = '_yaxis';
-        this._xnudge = 0;
-        
-        // set the shape renderer options
-        var opts = {lineJoin:'miter', lineCap:'butt', fill:this.fill, fillRect:this.fill, isarc:false, strokeStyle:this.color, fillStyle:this.color, closePath:this.fill, lineWidth: this.lineWidth};
-        this.renderer.shapeRenderer.init(opts);
-        // set the shadow renderer options
-        var shadow_offset = options.shadowOffset;
-        // set the shadow renderer options
-        if (shadow_offset == null) {
-            // scale the shadowOffset to the width of the line.
-            if (this.lineWidth > 2.5) {
-                shadow_offset = 1.25 * (1 + (Math.atan((this.lineWidth/2.5))/0.785398163 - 1)*0.6);
-                // var shadow_offset = this.shadowOffset;
-            }
-            // for skinny lines, don't make such a big shadow.
-            else {
-                shadow_offset = 1.25 * Math.atan((this.lineWidth/2.5))/0.785398163;
-            }
-        }
-        var sopts = {lineJoin:'miter', lineCap:'butt', fill:this.fill, fillRect:this.fill, isarc:false, angle:this.shadowAngle, offset:shadow_offset, alpha:this.shadowAlpha, depth:this.shadowDepth, closePath:this.fill, lineWidth: this.lineWidth};
-        this.renderer.shadowRenderer.init(sopts);
-
-        plot.postDrawHooks.addOnce(postPlotDraw);
-        plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
-
-        // if this is the left side of pyramid, set y values to negative.
-        if (this.side === 'left') {
-            for (var i=0, l=this.data.length; i<l; i++) {
-                this.data[i][1] = -Math.abs(this.data[i][1]);
-            }
-        }
-    };
-    
-    // setGridData
-    // converts the user data values to grid coordinates and stores them
-    // in the gridData array.
-    // Called with scope of a series.
-    $.jqplot.PyramidRenderer.prototype.setGridData = function(plot) {
-        // recalculate the grid data
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var data = this._plotData;
-        var pdata = this._prevPlotData;
-        this.gridData = [];
-        this._prevGridData = [];
-        var l = data.length;
-        var adjust = false;
-        var i;
-
-        // if any data values are < 0,  consider this a negative series
-        for (i = 0; i < l; i++) {
-            if (data[i][1] < 0) {
-                this.side = 'left';
-            }
-        }
-
-        if (this._yaxis.name === 'yMidAxis' && this.side === 'right') {
-            this._xnudge = this._xaxis.max/2000.0;
-            adjust = true;
-        }
-
-        for (i = 0; i < l; i++) {
-            // if not a line series or if no nulls in data, push the converted point onto the array.
-            if (data[i][0] != null && data[i][1] != null) {
-                this.gridData.push([xp(data[i][1]), yp(data[i][0])]);
-            }
-            // else if there is a null, preserve it.
-            else if (data[i][0] == null) {
-                this.gridData.push([xp(data[i][1]), null]);
-            }
-            else if (data[i][1] == null) {
-                this.gridData.push(null, [yp(data[i][0])]);
-            }
-            // finally, adjust x grid data if have to
-            if (data[i][1] === 0 && adjust) {
-                this.gridData[i][0] = xp(this._xnudge);
-            }
-        }
-    };
-    
-    // makeGridData
-    // converts any arbitrary data values to grid coordinates and
-    // returns them.  This method exists so that plugins can use a series'
-    // linerenderer to generate grid data points without overwriting the
-    // grid data associated with that series.
-    // Called with scope of a series.
-    $.jqplot.PyramidRenderer.prototype.makeGridData = function(data, plot) {
-        // recalculate the grid data
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var gd = [];
-        var l = data.length;
-        var adjust = false;
-        var i;
-
-        // if any data values are < 0,  consider this a negative series
-        for (i = 0; i < l; i++) {
-            if (data[i][1] < 0) {
-                this.side = 'left';
-            }
-        }
-
-        if (this._yaxis.name === 'yMidAxis' && this.side === 'right') {
-            this._xnudge = this._xaxis.max/2000.0;
-            adjust = true;
-        }
-
-        for (i = 0; i < l; i++) {
-            // if not a line series or if no nulls in data, push the converted point onto the array.
-            if (data[i][0] != null && data[i][1] != null) {
-                gd.push([xp(data[i][1]), yp(data[i][0])]);
-            }
-            // else if there is a null, preserve it.
-            else if (data[i][0] == null) {
-                gd.push([xp(data[i][1]), null]);
-            }
-            else if (data[i][1] == null) {
-                gd.push([null, yp(data[i][0])]);
-            }
-            // finally, adjust x grid data if have to
-            if (data[i][1] === 0 && adjust) {
-                gd[i][0] = xp(this._xnudge);
-            }
-        }
-
-        return gd;
-    };
-
-    $.jqplot.PyramidRenderer.prototype.setBarWidth = function() {
-        // need to know how many data values we have on the approprate axis and figure it out.
-        var i;
-        var nvals = 0;
-        var nseries = 0;
-        var paxis = this[this._primaryAxis];
-        var s, series, pos;
-        nvals = paxis.max - paxis.min;
-        var nticks = paxis.numberTicks;
-        var nbins = (nticks-1)/2;
-        // so, now we have total number of axis values.
-        var temp = (this.barPadding === 0) ? 1.0 : 0;
-        if (paxis.name == 'xaxis' || paxis.name == 'x2axis') {
-            this.barWidth = (paxis._offsets.max - paxis._offsets.min) / nvals - this.barPadding + temp;
-        }
-        else {
-            if (this.fill) {
-                this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals - this.barPadding + temp;
-            }
-            else {
-                this.barWidth = (paxis._offsets.min - paxis._offsets.max) / nvals;
-            }
-        }
-    };
-    
-    $.jqplot.PyramidRenderer.prototype.draw = function(ctx, gridData, options) {
-        var i;
-        // Ughhh, have to make a copy of options b/c it may be modified later.
-        var opts = $.extend({}, options);
-        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
-        var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
-        var fill = (opts.fill != undefined) ? opts.fill : this.fill;
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        var pointx, pointy;
-        // clear out data colors.
-        this._dataColors = [];
-        this._barPoints = [];
-        
-        if (this.renderer.options.barWidth == null) {
-            this.renderer.setBarWidth.call(this);
-        }
-        
-        // var temp = this._plotSeriesInfo = this.renderer.calcSeriesNumbers.call(this);
-        // var nvals = temp[0];
-        // var nseries = temp[1];
-        // var pos = temp[2];
-        var points = [],
-            w,
-            h;
-        
-        // this._barNudge = 0;
-
-        if (showLine) {
-            var negativeColors = new $.jqplot.ColorGenerator(this.negativeSeriesColors);
-            var positiveColors = new $.jqplot.ColorGenerator(this.seriesColors);
-            var negativeColor = negativeColors.get(this.index);
-            if (! this.useNegativeColors) {
-                negativeColor = opts.fillStyle;
-            }
-            var positiveColor = opts.fillStyle;
-            var base;
-            var xstart = this._xaxis.series_u2p(this._xnudge);
-            var ystart = this._yaxis.series_u2p(this._yaxis.min);
-            var yend = this._yaxis.series_u2p(this._yaxis.max);
-            var bw2 = this.barWidth/2.0;
-            var points = [];
-            
-            for (var i=0, l=gridData.length; i<l; i++) {
-                if (this.data[i][0] == null) {
-                    continue;
-                }
-                base = gridData[i][1];
-                // not stacked and first series in stack
-
-                if (this._plotData[i][1] < 0) {
-                    if (this.varyBarColor && !this._stack) {
-                        if (this.useNegativeColors) {
-                            opts.fillStyle = negativeColors.next();
-                        }
-                        else {
-                            opts.fillStyle = positiveColors.next();
-                        }
-                    }
-                }
-                else {
-                    if (this.varyBarColor && !this._stack) {
-                        opts.fillStyle = positiveColors.next();
-                    }
-                    else {
-                        opts.fillStyle = positiveColor;
-                    }                    
-                }
-                
-                if (this.fill) {
-                    if (this._plotData[i][1] >= 0) {
-                        // xstart = this._xaxis.series_u2p(this._xnudge);
-                        w = gridData[i][0] - xstart;
-                        h = this.barWidth;
-                        points = [xstart, base - bw2, w, h];
-                    }
-                    else {
-                        // xstart = this._xaxis.series_u2p(0);
-                        w = xstart - gridData[i][0];
-                        h = this.barWidth;
-                        points = [gridData[i][0], base - bw2, w, h];
-                    }
-
-                    this._barPoints.push([[points[0], points[1] + h], [points[0], points[1]], [points[0] + w, points[1]], [points[0] + w, points[1] + h]]);
-
-                    if (shadow) {
-                        this.renderer.shadowRenderer.draw(ctx, points);
-                    }
-                    var clr = opts.fillStyle || this.color;
-                    this._dataColors.push(clr);
-                    this.renderer.shapeRenderer.draw(ctx, points, opts); 
-                }
-
-                else {
-                    if (i === 0) {
-                        points =[[xstart, ystart], [gridData[i][0], ystart], [gridData[i][0], gridData[i][1] - bw2]];
-                    }
-
-                    else if (i < l-1) {
-                        points = points.concat([[gridData[i-1][0], gridData[i-1][1] - bw2], [gridData[i][0], gridData[i][1] + bw2], [gridData[i][0], gridData[i][1] - bw2]]);
-                    } 
-
-                    // finally, draw the line
-                    else {
-                        points = points.concat([[gridData[i-1][0], gridData[i-1][1] - bw2], [gridData[i][0], gridData[i][1] + bw2], [gridData[i][0], yend], [xstart, yend]]);
-                    
-                        if (shadow) {
-                            this.renderer.shadowRenderer.draw(ctx, points);
-                        }
-                        var clr = opts.fillStyle || this.color;
-                        this._dataColors.push(clr);
-                        this.renderer.shapeRenderer.draw(ctx, points, opts);
-                    }
-                }
-            }  
-        }        
-        
-        if (this.highlightColors.length == 0) {
-            this.highlightColors = $.jqplot.computeHighlightColors(this._dataColors);
-        }
-        
-        else if (typeof(this.highlightColors) == 'string') {
-            this.highlightColors = [];
-            for (var i=0; i<this._dataColors.length; i++) {
-                this.highlightColors.push(this.highlightColors);
-            }
-        }
-        
-    };
-
-        
-    // setup default renderers for axes and legend so user doesn't have to
-    // called with scope of plot
-    function preInit(target, data, options) {
-        options = options || {};
-        options.axesDefaults = options.axesDefaults || {};
-        options.grid = options.grid || {};
-        options.legend = options.legend || {};
-        options.seriesDefaults = options.seriesDefaults || {};
-        // only set these if there is a pie series
-        var setopts = false;
-        if (options.seriesDefaults.renderer === $.jqplot.PyramidRenderer) {
-            setopts = true;
-        }
-        else if (options.series) {
-            for (var i=0; i < options.series.length; i++) {
-                if (options.series[i].renderer === $.jqplot.PyramidRenderer) {
-                    setopts = true;
-                }
-            }
-        }
-        
-        if (setopts) {
-            options.axesDefaults.renderer = $.jqplot.PyramidAxisRenderer;
-            options.grid.renderer = $.jqplot.PyramidGridRenderer;
-            options.seriesDefaults.pointLabels = {show: false};
-        }
-    }
-    
-    // called within context of plot
-    // create a canvas which we can draw on.
-    // insert it before the eventCanvas, so eventCanvas will still capture events.
-    function postPlotDraw() {
-        // Memory Leaks patch    
-        if (this.plugins.pyramidRenderer && this.plugins.pyramidRenderer.highlightCanvas) {
-
-            this.plugins.pyramidRenderer.highlightCanvas.resetCanvas();
-            this.plugins.pyramidRenderer.highlightCanvas = null;
-        }
-         
-        this.plugins.pyramidRenderer = {highlightedSeriesIndex:null};
-        this.plugins.pyramidRenderer.highlightCanvas = new $.jqplot.GenericCanvas();
-        
-        this.eventCanvas._elem.before(this.plugins.pyramidRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-pyramidRenderer-highlight-canvas', this._plotDimensions, this));
-        this.plugins.pyramidRenderer.highlightCanvas.setContext();
-        this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
-    }  
-    
-    function highlight (plot, sidx, pidx, points) {
-        var s = plot.series[sidx];
-        var canvas = plot.plugins.pyramidRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        s._highlightedPoint = pidx;
-        plot.plugins.pyramidRenderer.highlightedSeriesIndex = sidx;
-        var opts = {fillStyle: s.highlightColors[pidx], fillRect: false};
-        s.renderer.shapeRenderer.draw(canvas._ctx, points, opts);
-        canvas = null;
-    }
-    
-    function unhighlight (plot) {
-        var canvas = plot.plugins.pyramidRenderer.highlightCanvas;
-        canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
-        for (var i=0; i<plot.series.length; i++) {
-            plot.series[i]._highlightedPoint = null;
-        }
-        plot.plugins.pyramidRenderer.highlightedSeriesIndex = null;
-        plot.target.trigger('jqplotDataUnhighlight');
-        canvas =  null;
-    }
-    
-    
-    function handleMove(ev, gridpos, datapos, neighbor, plot) {
-        if (neighbor) {
-            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
-            var evt1 = jQuery.Event('jqplotDataMouseOver');
-            evt1.pageX = ev.pageX;
-            evt1.pageY = ev.pageY;
-            plot.target.trigger(evt1, ins);
-            if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.pyramidRenderer.highlightedSeriesIndex && ins[1] == plot.series[ins[0]]._highlightedPoint)) {
-                var evt = jQuery.Event('jqplotDataHighlight');
-                evt.pageX = ev.pageX;
-                evt.pageY = ev.pageY;
-                plot.target.trigger(evt, ins);
-                highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
-            }
-        }
-        else if (neighbor == null) {
-            unhighlight (plot);
-        }
-    }
-
-    // Have to add hook here, becuase it needs called before series is inited.
-    $.jqplot.preInitHooks.push(preInit);
-    
-
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidRenderer.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidRenderer.min.js
deleted file mode 100644
index 9d0c903..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.pyramidRenderer.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(c){if(c.jqplot.PyramidAxisRenderer===undefined){c.ajax({url:c.jqplot.pluginLocation+"jqplot.pyramidAxisRenderer.js",dataType:"script",async:false})}if(c.jqplot.PyramidGridRenderer===undefined){c.ajax({url:c.jqplot.pluginLocation+"jqplot.pyramidGridRenderer.js",dataType:"script",async:false})}c.jqplot.PyramidRenderer=function(){c.jqplot.LineRenderer.call(this)};c.jqplot.PyramidRenderer.prototype=new c.jqplot.LineRenderer();c.jqplot.PyramidRenderer.prototype.constructor=c.jqplot.PyramidRenderer;c.jqplot.PyramidRenderer.prototype.init=function(j,o){j=j||{};this._type="pyramid";this.barPadding=10;this.barWidth=null;this.fill=true;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];if(j.highlightMouseDown&&j.highlightMouseOver==null){j.highlightMouseOver=false}this.side="right";c.extend(true,this,j);this.renderer.options=j;this._highlightedPoint=null;this._dataColors=[];this._barPoints=[];this.fillAxis="y";this._primaryAxis="_yaxis";this._xnudge=0;var n={lineJoin:"miter",lineCap:"butt",fill:this.fill,fillRect:this.fill,isarc:false,strokeStyle:this.color,fillStyle:this.color,closePath:this.fill,lineWidth:this.lineWidth};this.renderer.shapeRenderer.init(n);var m=j.shadowOffset;if(m==null){if(this.lineWidth>2.5){m=1.25*(1+(Math.atan((this.lineWidth/2.5))/0.785398163-1)*0.6)}else{m=1.25*Math.atan((this.lineWidth/2.5))/0.785398163}}var h={lineJoin:"miter",lineCap:"butt",fill:this.fill,fillRect:this.fill,isarc:false,angle:this.shadowAngle,offset:m,alpha:this.shadowAlpha,depth:this.shadowDepth,closePath:this.fill,lineWidth:this.lineWidth};this.renderer.shadowRenderer.init(h);o.postDrawHooks.addOnce(f);o.eventListenerHooks.addOnce("jqplotMouseMove",e);if(this.side==="left"){for(var k=0,g=this.data.length;k<g;k++){this.data[k][1]=-Math.abs(this.data[k][1])}}};c.jqplot.PyramidRenderer.prototype.setGridData=function(p){var j=this._xaxis.series_u2p;var o=this._yaxis.series_u2p;var k=this._plotData;var n=this._prevPlotData;this.gridData=[];this._prevGridData=[];var g=k.length;var m=false;var h;for(h=0;h<g;h++){if(k[h][1]<0){this.side="left"}}if(this._yaxis.name==="yMidAxis"&&this.side==="right"){this._xnudge=this._xaxis.max/2000;m=true}for(h=0;h<g;h++){if(k[h][0]!=null&&k[h][1]!=null){this.gridData.push([j(k[h][1]),o(k[h][0])])}else{if(k[h][0]==null){this.gridData.push([j(k[h][1]),null])}else{if(k[h][1]==null){this.gridData.push(null,[o(k[h][0])])}}}if(k[h][1]===0&&m){this.gridData[h][0]=j(this._xnudge)}}};c.jqplot.PyramidRenderer.prototype.makeGridData=function(m,p){var k=this._xaxis.series_u2p;var o=this._yaxis.series_u2p;var j=[];var g=m.length;var n=false;var h;for(h=0;h<g;h++){if(m[h][1]<0){this.side="left"}}if(this._yaxis.name==="yMidAxis"&&this.side==="right"){this._xnudge=this._xaxis.max/2000;n=true}for(h=0;h<g;h++){if(m[h][0]!=null&&m[h][1]!=null){j.push([k(m[h][1]),o(m[h][0])])}else{if(m[h][0]==null){j.push([k(m[h][1]),null])}else{if(m[h][1]==null){j.push([null,o(m[h][0])])}}}if(m[h][1]===0&&n){j[h][0]=k(this._xnudge)}}return j};c.jqplot.PyramidRenderer.prototype.setBarWidth=function(){var k;var g=0;var h=0;var m=this[this._primaryAxis];var q,l,o;g=m.max-m.min;var n=m.numberTicks;var j=(n-1)/2;var p=(this.barPadding===0)?1:0;if(m.name=="xaxis"||m.name=="x2axis"){this.barWidth=(m._offsets.max-m._offsets.min)/g-this.barPadding+p}else{if(this.fill){this.barWidth=(m._offsets.min-m._offsets.max)/g-this.barPadding+p}else{this.barWidth=(m._offsets.min-m._offsets.max)/g}}};c.jqplot.PyramidRenderer.prototype.draw=function(A,G,k){var D;var t=c.extend({},k);var p=(t.shadow!=undefined)?t.shadow:this.shadow;var I=(t.showLine!=undefined)?t.showLine:this.showLine;var B=(t.fill!=undefined)?t.fill:this.fill;var s=this._xaxis.series_u2p;var F=this._yaxis.series_u2p;var y,v;this._dataColors=[];this._barPoints=[];if(this.renderer.options.barWidth==null){this.renderer.setBarWidth.call(this)}var C=[],r,E;if(I){var q=new c.jqplot.ColorGenerator(this.negativeSeriesColors);var u=new c.jqplot.ColorGenerator(this.seriesColors);var H=q.get(this.index);if(!this.useNegativeColors){H=t.fillStyle}var o=t.fillStyle;var n;var J=this._xaxis.series_u2p(this._xnudge);var j=this._yaxis.series_u2p(this._yaxis.min);var m=this._yaxis.series_u2p(this._yaxis.max);var x=this.barWidth/2;var C=[];for(var D=0,z=G.length;D<z;D++){if(this.data[D][0]==null){continue}n=G[D][1];if(this._plotData[D][1]<0){if(this.varyBarColor&&!this._stack){if(this.useNegativeColors){t.fillStyle=q.next()}else{t.fillStyle=u.next()}}}else{if(this.varyBarColor&&!this._stack){t.fillStyle=u.next()}else{t.fillStyle=o}}if(this.fill){if(this._plotData[D][1]>=0){r=G[D][0]-J;E=this.barWidth;C=[J,n-x,r,E]}else{r=J-G[D][0];E=this.barWidth;C=[G[D][0],n-x,r,E]}this._barPoints.push([[C[0],C[1]+E],[C[0],C[1]],[C[0]+r,C[1]],[C[0]+r,C[1]+E]]);if(p){this.renderer.shadowRenderer.draw(A,C)}var g=t.fillStyle||this.color;this._dataColors.push(g);this.renderer.shapeRenderer.draw(A,C,t)}else{if(D===0){C=[[J,j],[G[D][0],j],[G[D][0],G[D][1]-x]]}else{if(D<z-1){C=C.concat([[G[D-1][0],G[D-1][1]-x],[G[D][0],G[D][1]+x],[G[D][0],G[D][1]-x]])}else{C=C.concat([[G[D-1][0],G[D-1][1]-x],[G[D][0],G[D][1]+x],[G[D][0],m],[J,m]]);if(p){this.renderer.shadowRenderer.draw(A,C)}var g=t.fillStyle||this.color;this._dataColors.push(g);this.renderer.shapeRenderer.draw(A,C,t)}}}}}if(this.highlightColors.length==0){this.highlightColors=c.jqplot.computeHighlightColors(this._dataColors)}else{if(typeof(this.highlightColors)=="string"){this.highlightColors=[];for(var D=0;D<this._dataColors.length;D++){this.highlightColors.push(this.highlightColors)}}}};function b(l,k,h){h=h||{};h.axesDefaults=h.axesDefaults||{};h.grid=h.grid||{};h.legend=h.legend||{};h.seriesDefaults=h.seriesDefaults||{};var g=false;if(h.seriesDefaults.renderer===c.jqplot.PyramidRenderer){g=true}else{if(h.series){for(var j=0;j<h.series.length;j++){if(h.series[j].renderer===c.jqplot.PyramidRenderer){g=true}}}}if(g){h.axesDefaults.renderer=c.jqplot.PyramidAxisRenderer;h.grid.renderer=c.jqplot.PyramidGridRenderer;h.seriesDefaults.pointLabels={show:false}}}function f(){if(this.plugins.pyramidRenderer&&this.plugins.pyramidRenderer.highlightCanvas){this.plugins.pyramidRenderer.highlightCanvas.resetCanvas();this.plugins.pyramidRenderer.highlightCanvas=null}this.plugins.pyramidRenderer={highlightedSeriesIndex:null};this.plugins.pyramidRenderer.highlightCanvas=new c.jqplot.GenericCanvas();this.eventCanvas._elem.before(this.plugins.pyramidRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-pyramidRenderer-highlight-canvas",this._plotDimensions,this));this.plugins.pyramidRenderer.highlightCanvas.setContext();this.eventCanvas._elem.bind("mouseleave",{plot:this},function(g){d(g.data.plot)})}function a(m,l,j,i){var h=m.series[l];var g=m.plugins.pyramidRenderer.highlightCanvas;g._ctx.clearRect(0,0,g._ctx.canvas.width,g._ctx.canvas.height);h._highlightedPoint=j;m.plugins.pyramidRenderer.highlightedSeriesIndex=l;var k={fillStyle:h.highlightColors[j],fillRect:false};h.renderer.shapeRenderer.draw(g._ctx,i,k);g=null}function d(j){var g=j.plugins.pyramidRenderer.highlightCanvas;g._ctx.clearRect(0,0,g._ctx.canvas.width,g._ctx.canvas.height);for(var h=0;h<j.series.length;h++){j.series[h]._highlightedPoint=null}j.plugins.pyramidRenderer.highlightedSeriesIndex=null;j.target.trigger("jqplotDataUnhighlight");g=null}function e(k,j,n,m,l){if(m){var i=[m.seriesIndex,m.pointIndex,m.data];var h=jQuery.Event("jqplotDataMouseOver");h.pageX=k.pageX;h.pageY=k.pageY;l.target.trigger(h,i);if(l.series[i[0]].highlightMouseOver&&!(i[0]==l.plugins.pyramidRenderer.highlightedSeriesIndex&&i[1]==l.series[i[0]]._highlightedPoint)){var g=jQuery.Event("jqplotDataHighlight");g.pageX=k.pageX;g.pageY=k.pageY;l.target.trigger(g,i);a(l,m.seriesIndex,m.pointIndex,m.points)}}else{if(m==null){d(l)}}}c.jqplot.preInitHooks.push(b)})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.trendline.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.trendline.js
deleted file mode 100644
index 1204c9b..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.trendline.js
+++ /dev/null
@@ -1,222 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- * 
- */
-(function($) {
-    
-    /**
-     * Class: $.jqplot.Trendline
-     * Plugin which will automatically compute and draw trendlines for plotted data.
-     */
-    $.jqplot.Trendline = function() {
-        // Group: Properties
-        
-        // prop: show
-        // Wether or not to show the trend line.
-        this.show = $.jqplot.config.enablePlugins;
-        // prop: color
-        // CSS color spec for the trend line.
-        // By default this wil be the same color as the primary line.
-        this.color = '#666666';
-        // prop: renderer
-        // Renderer to use to draw the trend line.
-        // The data series that is plotted may not be rendered as a line.
-        // Therefore, we use our own line renderer here to draw a trend line.
-        this.renderer = new $.jqplot.LineRenderer();
-        // prop: rendererOptions
-        // Options to pass to the line renderer.
-        // By default, markers are not shown on trend lines.
-        this.rendererOptions = {marker:{show:false}};
-        // prop: label
-        // Label for the trend line to use in the legend.
-        this.label = '';
-        // prop: type
-        // Either 'exponential', 'exp', or 'linear'.
-        this.type = 'linear';
-        // prop: shadow
-        // true or false, wether or not to show the shadow.
-        this.shadow = true;
-        // prop: markerRenderer
-        // Renderer to use to draw markers on the line.
-        // I think this is wrong.
-        this.markerRenderer = {show:false};
-        // prop: lineWidth
-        // Width of the trend line.
-        this.lineWidth = 1.5;
-        // prop: shadowAngle
-        // Angle of the shadow on the trend line.
-        this.shadowAngle = 45;
-        // prop: shadowOffset
-        // pixel offset for each stroke of the shadow.
-        this.shadowOffset = 1.0;
-        // prop: shadowAlpha
-        // Alpha transparency of the shadow.
-        this.shadowAlpha = 0.07;
-        // prop: shadowDepth
-        // number of strokes to make of the shadow.
-        this.shadowDepth = 3;
-        this.isTrendline = true;
-        
-    };
-    
-    $.jqplot.postSeriesInitHooks.push(parseTrendLineOptions);
-    $.jqplot.postDrawSeriesHooks.push(drawTrendline);
-    $.jqplot.addLegendRowHooks.push(addTrendlineLegend);
-    
-    // called witin scope of the legend object
-    // current series passed in
-    // must return null or an object {label:label, color:color}
-    function addTrendlineLegend(series) {
-        var ret = null;
-        if (series.trendline && series.trendline.show) {
-            var lt = series.trendline.label.toString();
-            if (lt) {
-                ret = {label:lt, color:series.trendline.color};
-            }
-        }
-        return ret;
-    }
-
-    // called within scope of a series
-    function parseTrendLineOptions (target, data, seriesDefaults, options, plot) {
-        if (this._type && (this._type === 'line' || this._type == 'bar')) {
-            this.trendline = new $.jqplot.Trendline();
-            options = options || {};
-            $.extend(true, this.trendline, {color:this.color}, seriesDefaults.trendline, options.trendline);
-            this.trendline.renderer.init.call(this.trendline, null);
-        }
-    }
-    
-    // called within scope of series object
-    function drawTrendline(sctx, options) {
-        // if we have options, merge trendline options in with precedence
-        options = $.extend(true, {}, this.trendline, options);
-
-        if (this.trendline && options.show) {
-            var fit;
-            // this.renderer.setGridData.call(this);
-            var data = options.data || this.data;
-            fit = fitData(data, this.trendline.type);
-            var gridData = options.gridData || this.renderer.makeGridData.call(this, fit.data);
-            this.trendline.renderer.draw.call(this.trendline, sctx, gridData, {showLine:true, shadow:this.trendline.shadow});
-        }
-    }
-    
-    function regression(x, y, typ)  {
-        var type = (typ == null) ? 'linear' : typ;
-        var N = x.length;
-        var slope;
-        var intercept;  
-        var SX = 0;
-        var SY = 0;
-        var SXX = 0;
-        var SXY = 0;
-        var SYY = 0;
-        var Y = [];
-        var X = [];
-    
-        if (type == 'linear') {
-            X = x;
-            Y = y;
-        }
-        else if (type == 'exp' || type == 'exponential') {
-            for ( var i=0; i<y.length; i++) {
-                // ignore points <= 0, log undefined.
-                if (y[i] <= 0) {
-                    N--;
-                }
-                else {
-                    X.push(x[i]);
-                    Y.push(Math.log(y[i]));
-                }
-            }
-        }
-
-        for ( var i = 0; i < N; i++) {
-            SX = SX + X[i];
-            SY = SY + Y[i];
-            SXY = SXY + X[i]* Y[i];
-            SXX = SXX + X[i]* X[i];
-            SYY = SYY + Y[i]* Y[i];
-        }
-
-        slope = (N*SXY - SX*SY)/(N*SXX - SX*SX);
-        intercept = (SY - slope*SX)/N;
-
-        return [slope, intercept];
-    }
-
-    function linearRegression(X,Y) {
-        var ret;
-        ret = regression(X,Y,'linear');
-        return [ret[0],ret[1]];
-    }
-
-    function expRegression(X,Y) {
-        var ret;
-        var x = X;
-        var y = Y;
-        ret = regression(x, y,'exp');
-        var base = Math.exp(ret[0]);
-        var coeff = Math.exp(ret[1]);
-        return [base, coeff];
-    }
-
-    function fitData(data, typ) {
-        var type = (typ == null) ?  'linear' : typ;
-        var ret;
-        var res;
-        var x = [];
-        var y = [];
-        var ypred = [];
-        
-        for (i=0; i<data.length; i++){
-            if (data[i] != null && data[i][0] != null && data[i][1] != null) {
-                x.push(data[i][0]);
-                y.push(data[i][1]);
-            }
-        }
-        
-        if (type == 'linear') {
-            ret = linearRegression(x,y);
-            for ( var i=0; i<x.length; i++){
-                res = ret[0]*x[i] + ret[1];
-                ypred.push([x[i], res]);
-            }
-        }
-        else if (type == 'exp' || type == 'exponential') {
-            ret = expRegression(x,y);
-            for ( var i=0; i<x.length; i++){
-                res = ret[1]*Math.pow(ret[0],x[i]);
-                ypred.push([x[i], res]);
-            }
-        }
-        return {data: ypred, slope: ret[0], intercept: ret[1]};
-    } 
-
-})(jQuery);
\ No newline at end of file
diff --git a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.trendline.min.js b/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.trendline.min.js
deleted file mode 100644
index c7c5089..0000000
--- a/hyracks-control-cc/src/main/resources/static/javascript/jqplot/plugins/jqplot.trendline.min.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * jqPlot
- * Pure JavaScript plotting plugin using jQuery
- *
- * Version: 1.0.0b2_r947
- *
- * Copyright (c) 2009-2011 Chris Leonello
- * jqPlot is currently available for use in all personal or commercial projects 
- * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL 
- * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly. 
- *
- * Although not required, the author would appreciate an email letting him 
- * know of any substantial use of jqPlot.  You can reach the author at: 
- * chris at jqplot dot com or see http://www.jqplot.com/info.php .
- *
- * If you are feeling kind and generous, consider supporting the project by
- * making a donation at: http://www.jqplot.com/donate.php .
- *
- * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
- *
- *     version 2007.04.27
- *     author Ash Searle
- *     http://hexmen.com/blog/2007/03/printf-sprintf/
- *     http://hexmen.com/js/sprintf.js
- *     The author (Ash Searle) has placed this code in the public domain:
- *     "This code is unrestricted: you are free to use it however you like."
- *
- * included jsDate library by Chris Leonello:
- *
- * Copyright (c) 2010-2011 Chris Leonello
- *
- * jsDate is currently available for use in all personal or commercial projects 
- * under both the MIT and GPL version 2.0 licenses. This means that you can 
- * choose the license that best suits your project and use it accordingly.
- *
- * jsDate borrows many concepts and ideas from the Date Instance 
- * Methods by Ken Snyder along with some parts of Ken's actual code.
- * 
- * Ken's origianl Date Instance Methods and copyright notice:
- * 
- * Ken Snyder (ken d snyder at gmail dot com)
- * 2008-09-10
- * version 2.0.2 (http://kendsnyder.com/sandbox/date/)     
- * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
- *
- * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js.
- * Larry has generously given permission to adapt his code for inclusion
- * into jqPlot.
- *
- * Larry's original code can be found here:
- *
- * https://github.com/lsiden/export-jqplot-to-png
- * 
- * 
- */
-(function(f){f.jqplot.Trendline=function(){this.show=f.jqplot.config.enablePlugins;this.color="#666666";this.renderer=new f.jqplot.LineRenderer();this.rendererOptions={marker:{show:false}};this.label="";this.type="linear";this.shadow=true;this.markerRenderer={show:false};this.lineWidth=1.5;this.shadowAngle=45;this.shadowOffset=1;this.shadowAlpha=0.07;this.shadowDepth=3;this.isTrendline=true};f.jqplot.postSeriesInitHooks.push(e);f.jqplot.postDrawSeriesHooks.push(g);f.jqplot.addLegendRowHooks.push(a);function a(k){var j=null;if(k.trendline&&k.trendline.show){var i=k.trendline.label.toString();if(i){j={label:i,color:k.trendline.color}}}return j}function e(m,k,j,i,l){if(this._type&&(this._type==="line"||this._type=="bar")){this.trendline=new f.jqplot.Trendline();i=i||{};f.extend(true,this.trendline,{color:this.color},j.trendline,i.trendline);this.trendline.renderer.init.call(this.trendline,null)}}function g(m,i){i=f.extend(true,{},this.trendline,i);if(this.trendline&&i.show){var k;var l=i.data||this.data;k=c(l,this.trendline.type);var j=i.gridData||this.renderer.makeGridData.call(this,k.data);this.trendline.renderer.draw.call(this.trendline,m,j,{showLine:true,shadow:this.trendline.shadow})}}function b(w,v,n){var u=(n==null)?"linear":n;var s=w.length;var t;var z;var o=0;var m=0;var r=0;var q=0;var l=0;var j=[];var k=[];if(u=="linear"){k=w;j=v}else{if(u=="exp"||u=="exponential"){for(var p=0;p<v.length;p++){if(v[p]<=0){s--}else{k.push(w[p]);j.push(Math.log(v[p]))}}}}for(var p=0;p<s;p++){o=o+k[p];m=m+j[p];q=q+k[p]*j[p];r=r+k[p]*k[p];l=l+j[p]*j[p]}t=(s*q-o*m)/(s*r-o*o);z=(m-t*o)/s;return[t,z]}function h(k,j){var i;i=b(k,j,"linear");return[i[0],i[1]]}function d(o,m){var k;var i=o;var n=m;k=b(i,n,"exp");var l=Math.exp(k[0]);var j=Math.exp(k[1]);return[l,j]}function c(l,j){var p=(j==null)?"linear":j;var n;var o;var r=[];var q=[];var m=[];for(k=0;k<l.length;k++){if(l[k]!=null&&l[k][0]!=null&&l[k][1]!=null){r.push(l[k][0]);q.push(l[k][1])}}if(p=="linear"){n=h(r,q);for(var k=0;k<r.length;k++){o=n[0]*r[k]+n[1];m.push([r[k],o])}}else{if(p=="exp"||p=="exponential"){n=d(r,q);for(var k=0;k<r.length;k++){o=n[1]*Math.pow(n[0],r[k]);m.push([r[k],o])}}}return{data:m,slope:n[0],intercept:n[1]}}})(jQuery);
\ No newline at end of file
