
// 
// CLASS:
// - Ajax
// 
// VERSION:
// - 1.0.0 - 2007xxxx - Core design
// - 1.0.1 - 2007xxxx - Restructured
// - 1.0.2 - 20070626 - Bug fixes
// - 1.0.3 - 20070809 - Restructured
// - 1.0.4 - 20071108 - Outputs XML errors
// 

var Xml = 
{
  file: function (file)
  {
    xmlDoc = null;
    
    // IE
    if (window.ActiveXObject)
    {
    	xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
    	xmlDoc.async = false;
    	xmlDoc.load(file);
      
    	this.control();
    }
    
    // Mozilla, Firefox, Opera
    else if (document.implementation && document.implementation.createDocument)
    {
    	xmlDoc = document.implementation.createDocument('', '', null);
    	xmlDoc.load(file);
    	xmlDoc.onload = this.control;
    }
    
    else
    {
    	alert('Your browser cannot handle this script');
    }
  },

  string: function (data)
  {
    // Initialize
    var xmlDoc;
    var xmlString = data.compress();
    
    // IE
    if (window.ActiveXObject)
    {
      var xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
      xmlDoc.async = 'false';
      xmlDoc.loadXML(xmlString);
      
      if (xmlDoc.parseError.errorCode != 0)
      {
        txt="Error Code: " + xmlDoc.parseError.errorCode + "\n"
        txt=txt+"Error Reason: " + xmlDoc.parseError.reason
        txt=txt+"Error Line: " + xmlDoc.parseError.line
        alert(txt)
      }
      
      return xmlDoc;
    }
    
    // Mozilla, Firefox, Opera, etc.
    else
    {
      var parser = new DOMParser();
      xmlDoc = parser.parseFromString(xmlString, 'text/xml');
      
      return xmlDoc;
    }
  }
}

