
/* ---------------------------------------------------------------------------------------------------------------------------------------- */

function SetAttrib (node, attrib_name, attrib_value)
{
	var new_attrib = document.createAttribute (attrib_name);
	new_attrib.nodeValue = attrib_value;
	node.setAttributeNode (new_attrib);
}

/* ---------------------------------------------------------------------------------------------------------------------------------------- */

function AddImageChildNode (node, imgsrc, imgid)
{
	var new_img = document.createElement("IMG"); 
	node.appendChild (new_img);
	new_img.setAttribute ("src", imgsrc);
	if (imgid != '')
		SetAttrib (new_img, "id", imgid);
	
	return new_img;
}

/* ---------------------------------------------------------------------------------------------------------------------------------------- */

function RemoveChildrenNodes (node)
{
	while (node.hasChildNodes())
	{
		node.removeChild (node.firstChild);
	}
}

/* ---------------------------------------------------------------------------------------------------------------------------------------- */

function AddTableChildNode (node, table_class)
{
	var new_table, new_tbody;
		
	new_table = document.createElement("TABLE");
	node.appendChild (new_table);

	SetAttrib (new_table, "class", table_class);
	SetAttrib (new_table, "cellspacing", "0");
	SetAttrib (new_table, "cellpadding", "0");

	new_tbody = document.createElement("TBODY");
	new_table.appendChild (new_tbody);

	return new_tbody;	
}

/* ---------------------------------------------------------------------------------------------------------------------------------------- */

function joAddHTMLChildNode (parent_node, node_type, node_class, node_id)
{
	var new_node = document.createElement (node_type);
	parent_node.appendChild (new_node);
	if (node_class && node_class != "")	new_node.setAttribute ("class", node_class);
	if (node_id && node_id != "")	new_node.setAttribute ("id", node_id);
	return new_node;
}

/* ---------------------------------------------------------------------------------------------------------------------------------------- */

function joAddTextChildNode (parent_node, node_text)
{
	var new_node = document.createTextNode (node_text);
	parent_node.appendChild (new_node);
	return new_node;
}

/* ---------------------------------------------------------------------------------------------------------------------------------------- */

function joRemoveChildNodes (node)
{
	while (node && node.hasChildNodes())
	{
		joRemoveChildNodes (node.firstChild);
		var subnode = node.removeChild (node.firstChild);
		subnode = null;
	}
}

/* ---------------------------------------------------------------------------------------------------------------------------------------- */

function SetTextColor (node, textcolor)
{
	if (node)
	{
		node.style.color = textcolor;
	}
}

/* ---------------------------------------------------------------------------------------------------------------------------------------- */

function joAddEvent (node, oneEvent, handler) 
{
    if(document.body.addEventListener) node.addEventListener (oneEvent, handler, false);
    if(document.body.attachEvent) node.attachEvent ("on" + oneEvent, handler);
}
