Index: /schedule/js/xmlrequest.js
===================================================================
--- /schedule/js/xmlrequest.js	(revision 16573)
+++ /schedule/js/xmlrequest.js	(revision 16574)
@@ -1,41 +1,43 @@
-function testData() 
-{
-   	//calls the xml request in a loop based on the current sources                
-	var source = ['Mrk 421','Mrk 501'];
-	for (i = 0; i<source.length; i++) {
-		testXMLData(i, source);
-	}
-}
-
-function testXMLData(index, source) 
-{
-	var testXML;
-	testXML = new XMLHttpRequest();
-	//NOTE: previous errors on the request was caused by appending "http://www.fact-project.org"
-	testXML.open("GET","/smartfact/index.php?source="+escape(source[index])+"&time="+year+"-"+month+"-"+day,true);
-	dataSource = new Array();
-	testXML.onload=function() {
-		if (testXML.status==200)
-		{
-			line=testXML.responseText.split('\n');
-			dataSource.push(line);
-			if (dataSource.length == source.length)
-				displayXMLData(dataSource, source); //this will be called when the last data from the list is read
-		}
-	testXML.send();
-}
-
-function displayXMLData(dataSource, source)
-{
-	//This function splits the lines of data per data source
-	var dataGraph = new Array(source.length); 
-	for (i=0; i<source.length; i++) {
-		dataGraph[i] = new Array(); //dataGraph contains the individual points for each source i
-		for(row=0;row<dataSource[i].length;row++)
-		{
-			rows=line[row].split(',');
-			dataGraph[i].push(rows[4]);
-			$('#data').append(i + ' GRAPH DATA ' + dataGraph[i]);
+$(document).ready(function(){
+	function testData() 
+	{
+		//calls the xml request in a loop based on the current sources                
+		var source = ['Mrk 421','Mrk 501'];
+		for (i = 0; i<source.length; i++) {
+			testXMLData(i, source);
 		}
 	}
-}
+
+	function testXMLData(index, source) 
+	{
+		var testXML;
+		testXML = new XMLHttpRequest();
+		//NOTE: previous errors on the request was caused by appending "http://www.fact-project.org"
+		testXML.open("GET","/smartfact/index.php?source="+escape(source[index])+"&time="+year+"-"+month+"-"+day,true);
+		dataSource = new Array();
+		testXML.onload=function() {
+			if (testXML.status==200)
+			{
+				line=testXML.responseText.split('\n');
+				dataSource.push(line);
+				if (dataSource.length == source.length)
+					displayXMLData(dataSource, source); //this will be called when the last data from the list is read
+			}
+		testXML.send();
+	}
+
+	function displayXMLData(dataSource, source)
+	{
+		//This function splits the lines of data per data source
+		var dataGraph = new Array(source.length); 
+		for (i=0; i<source.length; i++) {
+			dataGraph[i] = new Array(); //dataGraph contains the individual points for each source i
+			for(row=0;row<dataSource[i].length;row++)
+			{
+				rows=line[row].split(',');
+				dataGraph[i].push(rows[4]);
+				$('#data').append(i + ' GRAPH DATA ' + dataGraph[i]);
+			}
+		}
+	}
+});
