// set/change CSS a list of styles <styleNames> of object with ID <id>
// taking values from CSS class <className>
function setStylesFromClass(obj, styleNames, klassName)
{
	var styles = styleNames.split(' ');
	
	for(style in styles) {
		alert(document.classes.elements(klassName).all.elements(style));
//		setStyle(obj, style, document.classes[klassName].all[style]);
	}
}

// set/change CSS style of object with ID <id>
function setStyleByID(id, styleName, styleValue)
{
	var obj = null;
	
	if(document.all != undefined)
		obj = document.all[id];
	else if(document.getElementById != undefined)
		obj = document.getElementById(id);
	
	if(obj != null)
		return setStyle(obj, styleName, styleValue);
	return false;
}

// set/change CSS style of object <obj>
function setStyle(obj, styleName, styleValue)
{
	if(obj.style != undefined) {
		obj = obj.style;
	} else
		return false;
	
	obj[styleName] = styleValue;
	return true;
}

// get HTML object with ID <id>
function getElementByID(id)
{
	var obj = null;
	if(document.all != undefined)
		obj = document.all[id];
	else if(document.getElementById != undefined)
		obj = document.getElementById(id);
	
	return obj;
}

// get CSS style of object <obj>
function getStyle(obj, styleName)
{
	if(obj.currentStyle != undefined) {
		obj = obj.currentStyle;
	} else if(obj.style != undefined) {
		obj = obj.style;
	} else
		return "";
	
	return obj[styleName];
}

// show all CSS styles of object <obj>
function enumStyles(obj)
{
	txt = "";
	c = 0;
	if(obj.style != undefined) {
		obj = obj.style;
		txt = "style:\n";
	} else
		return false;
	
	for(x in obj) {
		if(c++ == 20) {
			alert(txt);
			txt = "";
			c = 0;
		}
		s = String(obj[x]);
		pos = s.indexOf("\n");
		if(pos != -1)
			s = s.substr(0, pos);
		txt += x + ": " + s + "\n";
	}
	alert(txt);
	return true;
}

// show all key/value pairs of object <obj>
// eventually can filter keys only showing ones that contain <filter>
function enumKeys(obj, filter)
{
	txt = "";
	c = 0;
	for(x in obj) {
		if(filter != null && filter != "") {
			if(x.toLowerCase().indexOf(filter) != -1)
				x = "***" + x;
			else
				continue;
		}
		if(c++ == 20) {
			if(txt != "")
				alert(txt);
			txt = "";
			c = 0;
		}
		s = String(obj[x]);
		pos = s.indexOf("\n");
		if(pos != -1)
			s = s.substr(0, pos);
		txt += x + ": " + s + "\n";
	}
	if(txt != "")
		alert(txt);
}
