﻿
/*
This file created by Michael Taylor - 2007-07-01

- AttrGet() is used to get an attribute value for any page element that contains an ID attribute.
- It will work on dynamic IDs set by the .NET runat="server" server-side attribute.

Arguments:

	strTag (optional if the full ID is supplied):
		This is the the tag name of the element.
		It is used only if the supplied strIdPart argument doesn't match the ID of a page element.

	strIdPart (required):
		This is the ID or part of the ID of the element.
		If the full ID of a page element is supplied, the strTag argument is not used and can be set to null.
	
	strAttr (required):
		This is the attribute name to search for within the given strTag/strIdPart.
		The value that has been set for this attribute will be returned by the function.
	
	Example:
		AttrGet('div', 'Menu_Home', 'style.left');

It has been tested on and is compatible with:
	Microsoft Internet Explorer 6 and up
	Mozilla Firefox 2 and up

For inquiries or comments, visit www.genxml.com
*/

function AttrGet(strTag, strIdPart, strAttr) {
	var strReturnVal = '';
	if(document.getElementById(strIdPart) != null) { // then the full ID has been supplied
		eval('strReturnVal = document.getElementById(strIdPart).' + strAttr);
	}
	else {
		var colTags = document.getElementsByTagName(strTag);
		if(typeof(colTags) != 'undefined') {
			for(var intX = 0; intX < colTags.length; intX++) {
				if(colTags[intX].id.indexOf(strIdPart) != -1) {
					eval('strReturnVal = colTags[intX].' + strAttr);
					intX = colTags.length;
				}
			}
		}
	}
	return strReturnVal;
}
