function clear(htmlnode)
{
	while(htmlnode.hasChildNodes())
	{
		htmlnode.removeChild(htmlnode.firstChild);
	}
}

function addclass(obj, classvalue)
{
	var ovalue = obj.getAttribute('class');
	if(ovalue == null)
	{
		ovalue = classvalue;
	}
	else
	{
		var avalue = ovalue.split(' ');
		for(var ncount = 0; ncount < avalue.length; ncount++)
		{
			if(avalue[ncount] == classvalue)
				return;
		}
		ovalue = ovalue + ' ' + classvalue;
	}
	if(ovalue.length == 0)
		obj.removeAttribute('class');
	else
		obj.setAttribute('class', ovalue);
}

function delclass(obj, classvalue)
{
	var ovalue = obj.getAttribute('class');
	if(ovalue == null)
		return;
	var avalue = ovalue.split(' ');
	var nvalue = Array();
	for(var ncount = 0; ncount < avalue.length; ncount++)
	{
		if(avalue[ncount] != classvalue)
			nvalue.push(avalue[ncount]);
	}
	nvalue = nvalue.join(' ');
	if(nvalue.length == 0)
		obj.removeAttribute('class');
	else
		obj.setAttribute('class', nvalue);
}

function addelement(obj, elmname)
{
	var nelm = document.createElement(elmname);
	return obj.appendChild(nelm);
}

function addtext(obj, text)
{
	var nelm = document.createTextNode(text);
	return obj.appendChild(nelm);
}

