var undefined;
if(	typeof(XtrazDebug) == "undefined" )
{ XtrazDebug = new Object
	XtrazDebug.alert = function(level){}
	XtrazDebug.assert = function(level,level2){}
	XtrazDebug.start = function(level){}
	XtrazDebug.trace = function(level,level2){}
}

function genTextObj(dir,xmlTxts)
{
  this.m_dir = dir;
  this.m_xmlTexts = xmlTxts;
  this.m_txtArr;
  
  function getDir(){return this.m_dir;}
  function getXmlTexts(){return this.m_xmlTexts;}
  
  this.init = function()
  {
    // code for IE
		/*if (window.ActiveXObject)
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.load(this.m_xmlTexts);
		}
		else// code for Mozilla, etc.
		{
			if (document.implementation && document.implementation.createDocument)
			{
				xmlDoc= document.implementation.createDocument("","",null);
				xmlDoc.load(this.m_xmlTexts);
			}
			else
			{
			   //alert('Your browser cannot handle this script');
			}
		}
		
		this.m_txtArr = fromXmlToHash(this.m_xmlTexts);		*/
	}
	
	this.getKeyVal = function(key)
	{
	  var ret = ""
		try
		{
			ret = this.m_txtArr[key];
			if(isEmpty(ret))
			{
			  ret = "";
		  }
		}
		catch(e)
		{
		  ret = "";
		}

		return ret;
	}
}
//get an xml doc from an xml file or string
function getXmlDoc(xml,isFile)
{
  var xmlDoc = null;
  // code for IE
	if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		
	}
	else// code for Mozilla, etc.
	{
		if (document.implementation && document.implementation.createDocument)
		{
		  xmlDoc = document.implementation.createDocument("","",null);
		  if(isFile == false)
		  {
		    xmlDoc.prototype.loadXML = function(strXML) 
				{
			    //create a DOMParser
			    var objDOMParser = new DOMParser();
			        
			    //create new document from string
			    var objDoc = objDOMParser.parseFromString(strXML, "text/xml");
			    while (this.hasChildNodes())
			    {
  				  this.removeChild(this.lastChild);
 				  }
 				  //add the nodes from the new document
					for (var i=0; i < objDoc.childNodes.length; i++) {
					            
					  //import the node
					  var objImportedNode = this.importNode(objDoc.childNodes[i], true);
					            
					  //append the child to the current document
					  this.appendChild(objImportedNode);
					        
					}
			  } 
	    }
	    
		}
		else{}
	}
	if(xmlDoc != null)
	{
	  if(isFile == true)
	  {
	    xmlDoc.load(xml);
    }
    else
    {
      xmlDoc.loadXML(xml);
		}
	}
	return xmlDoc;
}
// parse the xml into hash
function fromXmlToHash(inXml)
{
  var currNode = inXml.documentElement.firstChild.childNodes;
 
	var tempArray = new Array();
	for(var i=0;i < currNode.length ; i++)
	{
		try
		{
		    if (isNull(currNode(i).firstChild.nodeValue) == false)
		    {
				 	 tempArray[currNode(i).tagName] = currNode(i).firstChild.nodeValue;
		    }
				else
				{
				    tempArray[currNode(i).tagName] = currNode(i);
				}
		}
		catch(e){}
	}
	//alert(tempArray.length);
	return tempArray;
}

/* Test if an object is null */
function isNull(obj)
{
    return ( (typeof obj == 'object') && !obj );
}

function isEmpty(param)
{
  var ret = false;
	if(	typeof(param) == "undefined" )
	{
		ret = true;
	}
	return ret;
}

