xlr.core = 
{
    getXlrElements 	: function (node, xelmTypeList)
    {
	return xlr.core.pathThroughNodes(node, xelmTypeList, new Array());
    },

    pathThroughNodes 	: function (node, xelmTypeList, xelmList) 
    {
	    xlr.core.handleNode(node, xelmTypeList, xelmList);
	    if (node.hasChildNodes()) 
	    {
		for (var i = 0; i < node.childNodes.length; i++) 
		{
		    xlr.core.pathThroughNodes(node.childNodes[i], xelmTypeList, xelmList);
		}
	    }
	    return xelmList;
    },

    handleNode 		: function (node, xelmTypeList, xelmList)
    {
	switch (node.nodeType) 
	{
	    case 1 :	// Unterknoten 
		    var xelm = xlr.core.parseID(node); 
		    if(xelm != null && !xelm.isShadow)
		    {
			if(this.isXelmTypeInXelmTypeList(xelm.xelmType,xelmTypeList))
			{
			    xelmList[xelmList.length] = xelm;
			}
		    }
		    break;
	    case 3 :	/* Textknoten */          break;
	    case 8 :	/* Kommentarknoten*/      break;
	    
	    default :	/*Unbekannter Knoten-Type*/
	}
    },

    isXelmTypeInXelmTypeList 	: function (xelmType, xelmTypeList)
    {
	for(var i = 0; i < xelmTypeList.length;i++)
	{
	    var text = xelmTypeList[i];
	    if(text == xelmType)return true;
	}
	return false;
    },

    parseID : function (node)
    {
	var rv = null;
	var id = node.getAttribute("id");

	if(id != null)
	{
	      var keys = id.split("_");
	      if(keys.length >= 3)
	      {
		  rv = 
		  {
		      xelmType 		: keys[1], 
		      xelmTypeID 	: keys[2],
		      xelmName		: node.getAttribute("name"),
		      isShadow		: keys.length > 3 ? true:false,
		      xelmValue		: node.value,
		      xelmNode		: node
		  };
	      }
	}
	return rv;
    },

    parseBoolean : function(wert)
    {
	var rv = false;
	switch(wert)
	{
	    case "true"		: rv = true;	break;
	    case true		: rv = true;	break;
	}
	return rv;
    }
};

