

// 
// DOM utility methods
// 

function getElementsByAttribute(attr, value, tag)
{
	//alert("getElementsByAttribute(" + attr + ", " + value + ", " + tagName + ")");
	
	var ar = new Array();
	var attribute;
	var tagName = "";
	var tags;
	var attrs;
	
	if (tag != undefined)
	{
		tagName = tag;
	}

	if ("" != tagName)
	{
		tags = document.getElementsByTagName(tagName);
	}
	else
	{
		tags = document.all;
	}
	
	for (var i=0; i<tags.length; i++)
	{
		attrs = tags[i].attributes;
		if (null != attrs)
		{
			for (var j=0; j<attrs.length; j++)
			{
				attribute = new ajxAttribute(attrs[j]);
				if (attribute.getName() == attr && attribute.getValue() == value)
				{
					ar[ar.length] = new ajxNode(tags[i]);
					break;
				}
			}
		}
	}
	//alert(ar.length);
	return ar;
}


// 
// String utility methods
// 

function trim(value)
{
	if (undefined != value && "" != value)
	{
		return value.replace(/^\s*|\s*$/g,"");
	}
	else
	{
		return "";
	}
}

function trimAll(value)
{
	if (undefined != value && "" != value)
	{
		while (value.substr(0, 1) == " " || value.substr(0, 1) == "\t" || value.substr(0, 1) == "\r" || value.substr(0, 1) == "\n")
			value = value.substr(1);
		while (value.substr(value.length - 1, 1) == " " || value.substr(value.length - 1, 1) == "\t" || value.substr(value.length - 1, 1) == "\r" || value.substr(value.length - 1, 1) == "\n")
			value = value.substr(0, value.length - 1);
		return value;
	}
	else
	{
		return "";
	}
}


