--- /dev/null
+/*\r
+* These functions taken from online article here:\r
+* http://www.webreference.com/programming/javascript/definitive2/index.html\r
+* They are not included under the Apache license for the rest of the source.\r
+*/\r
+\r
+var TimelineHelper = function()\r
+{\r
+}\r
+\r
+/**\r
+ * Create a new Document object. If no arguments are specified,\r
+ * the document will be empty. If a root tag is specified, the document\r
+ * will contain that single root tag. If the root tag has a namespace\r
+ * prefix, the second argument must specify the URL that identifies the\r
+ * namespace.\r
+ */\r
+\r
+TimelineHelper.newDocument = function(rootTagName, namespaceURL) {\r
+ if (!rootTagName) rootTagName = "";\r
+ if (!namespaceURL) namespaceURL = "";\r
+ if (document.implementation && document.implementation.createDocument) {\r
+ // This is the W3C standard way to do it\r
+ return document.implementation.createDocument(namespaceURL, rootTagName, null);\r
+ }\r
+ else { // This is the IE way to do it\r
+ // Create an empty document as an ActiveX object\r
+ // If there is no root element, this is all we have to do\r
+ var doc = new ActiveXObject("MSXML2.DOMDocument");\r
+ // If there is a root tag, initialize the document\r
+ if (rootTagName) {\r
+ // Look for a namespace prefix\r
+ var prefix = "";\r
+ var tagname = rootTagName;\r
+ var p = rootTagName.indexOf(':');\r
+ if (p != -1) {\r
+ prefix = rootTagName.substring(0, p);\r
+ tagname = rootTagName.substring(p+1);\r
+ }\r
+ // If we have a namespace, we must have a namespace prefix\r
+ // If we don't have a namespace, we discard any prefix\r
+ if (namespaceURL) {\r
+ if (!prefix) prefix = "a0"; // What Firefox uses\r
+ }\r
+ else prefix = "";\r
+ // Create the root element (with optional namespace) as a\r
+ // string of text\r
+ var text = "<" + (prefix?(prefix+":"):"") + tagname +\r
+ (namespaceURL\r
+ ?(" xmlns:" + prefix + '="' + namespaceURL +'"')\r
+ :"") +\r
+ "/>";\r
+ // And parse that text into the empty document\r
+ doc.loadXML(text);\r
+ }\r
+ return doc;\r
+ }\r
+};\r
+\r
+\r
+/**\r
+ * Parse the XML document contained in the string argument and return\r
+ * a Document object that represents it.\r
+ */\r
+TimelineHelper.parseXML = function(text) {\r
+ if (typeof DOMParser != "undefined") {\r
+ // Mozilla, Firefox, and related browsers\r
+ return (new DOMParser()).parseFromString(text, "application/xml");\r
+ }\r
+ else if (typeof ActiveXObject != "undefined") {\r
+ // Internet Explorer.\r
+ var doc = TimelineHelper.newDocument(); // Create an empty document\r
+ doc.loadXML(text); // Parse text into it\r
+ return doc; // Return it\r
+ }\r
+ else {\r
+ // As a last resort, try loading the document from a data: URL\r
+ // This is supposed to work in Safari. Thanks to Manos Batsis and\r
+ // his Sarissa library (sarissa.sourceforge.net) for this technique.\r
+ var url = "data:text/xml;charset=utf-8," + encodeURIComponent(text);\r
+ var request = new XMLHttpRequest();\r
+ request.open("GET", url, false);\r
+ request.send(null);\r
+ return request.responseXML;\r
+ }\r
+};\r
+\r