// set attribute of an DOM element. this function replace the native element.setAttribute(),
// working around the cross-browser issues.
// setAttribute: NOTE usage:
	// **NOTE** for attr=='name' or 'type', myNode = setAttribute(myNode, 'align', 'right');
	// otherwise, just setAttribute(myNode, 'align', 'right');
function setAttribute(node, attr, value) {
	if(document.all) {
		if (attr == 'name' || attr == 'type') {
			// to work around IE unable to set 'name' and 'type' as tag attribute.
			var _attrTail = '__attrTailZYX__'; // just to make a unique name
			node.setAttribute(attr + _attrTail, value);
			// replace back to 'name' or 'type'
			tempParent = document.createElement('div');
			tempParent.appendChild(node);
			reg = new RegExp(_attrTail, 'g');
			tempParent.innerHTML = tempParent.innerHTML.replace(reg, '');
			newNode = tempParent.childNodes[0].cloneNode(false);
			return newNode; // note return for IE, since pass-by-reference can change the orig elem
		} else if (attr == 'class') {
			node.className = value;
			return node;
		} else {
			node.setAttribute(attr, value);
			return node;
		}
	} else {
		node.setAttribute(attr, value);
		return node;
	}
}
