/*
* This file reads the about.xml file and displays its contents.
* author:V.Sendling-Ortiz, vivortiz@yahoo.com
*/

////////////////////////
//Declarations
////////////////////////
var isFireFox = (!document.layers) && (navigator.userAgent.indexOf('Firefox')!=-1)?true:false;
var xmlFile = "xml/about.xml";
var xmlAboutDoc;

//Is IE or Firefox?
if (isFireFox){	
	//Create an instance of the XML parser in Mozilla browsers
	//namespace, root, file
	xmlAboutDoc=document.implementation.createDocument("","",null);
	xmlAboutDoc.load(xmlFile);
}else{
	xmlAboutDoc = new ActiveXObject("Microsoft.XMLDOM");
}

////////////////////////
//Functions
////////////////////////

//Loads XML file
function loadaboutXML(xmlFile, inRetText, isDebugging)
{
  if (isFireFox){	
	xmlAboutDoc.async="false";
	xmlAboutDoc.onreadystatechange=verify;	
	xmlaboutObj=xmlAboutDoc.documentElement; //root element 
  }else{
	xmlAboutDoc.async="false";
	xmlAboutDoc.onreadystatechange=verify;
	xmlAboutDoc.load(xmlFile);
	xmlaboutObj=xmlAboutDoc.documentElement; //root element 
  }
  try{ 	
	if (inRetText){
	}else{
		displayaboutXML();
	}
  }
  catch(e){    
	if (isDebugging){
		/*document.write("e is: " + e + "<br>")
		document.write("e.number is: " + (e.number & 0xFFFF) + "<br>");
		document.write("e.description is: " + e.description + "<br>");
		document.write("e.name is: " + e.name + "<br>");
		document.write("e.message is: " + e.message + "<br>");*/
	}else{
		document.write ("<BR><font color=white>This About coming soon! Try refreshing the page.</font><BR> <HR>")
	}	
  }
}

//Verifies
function verify()
{
  // 0 Object is not initialized
  // 1 Loading object is loading data
  // 2 Loaded object has loaded data
  // 3 Data from object can be worked with
  // 4 Object completely initialized
  if (xmlAboutDoc.readyState != 4)
  {
		return false;
  }else{
		//alert(xmlAboutDoc.readyState);
  }
}

//Displays XML file contents
function displayaboutXML(){ 	
    var aboutCount = 1; //xmlaboutObj.childNodes.length; //giving 3?
	var x;
	var straboutNodeValue;
	var arrText;
	
	//will loop thru from top top bottom XML file.
	for (i=0;i<aboutCount;i++)
	{			
		//get about text
		var x=xmlAboutDoc.getElementsByTagName('text');
		var straboutNodeValue = x[i].childNodes[0].nodeValue;		
		//split at pipe and create paragraphs
		var arraboutText = straboutNodeValue.split("|");
		for (arrCounter=0; arrCounter<arraboutText.length; arrCounter++){
			document.write("<h3>" + arraboutText[arrCounter] + "</h3>");			
		}				
	}		
}

//Only return text without formating
function returnText(){ 
    var aboutCount = xmlaboutObj.childNodes.length;	
	var arrCounter;
	
	//will loop thru from top top bottom XML file.
	for (i=0;i<aboutCount;i++)
	{			
		//get about text
		var x=xmlAboutDoc.getElementsByTagName('text');
		var straboutNodeValue = x[i].childNodes[0].nodeValue;		
		//split at pipe and create paragraphs
		var arraboutText = straboutNodeValue.split("|");
	}	
	return arraboutText;
}