function chkMe(box)
{
	var b = document.getElementById(box);
	
	if (b.checked)	b.checked = false;
	else			b.checked = true;
}

function moveFocus(event, from_id, to_id)
{
	var from = document.getElementById(from_id);
	if (!from) return;
	
	var to = document.getElementById(to_id);
	if (!to) return;
	
	/*TODO: Opera is 48 through 57...*/
	if (event.keyCode < 96 || event.keyCode > 105)
		return;
	
	if (from.value.length == from.getAttribute("maxlength"))
		to.focus();
}

function copyMyContent(from_id, to_id, inner)
{
	var from = document.getElementById(from_id);
	if (!from) return;
	
	var to = document.getElementById(to_id);
	if (!to) return;
	
	if (arguments.length >= 3)	to.innerHTML = from.innerHTML;
	else						to.value = from.value;
}

function copyOurContent(start_id, end_id, to_id, inner)
{
	var start = document.getElementById(start_id);
	if (!start) return;
	
	var end = document.getElementById(end_id);
	if (!end) return;
	
	var to = document.getElementById(to_id);
	if (!to) return;
	
	if (arguments.length >= 4)	to.innerHTML = start.innerHTML + " " + end.innerHTML;
	else						to.value = start.value + " " + end.value;
}

function concatMyContent(from_id, to_id, inner)
{
	var from = document.getElementById(from_id);
	if (!from) return;
	
	var to = document.getElementById(to_id);
	if (!to) return;
	
	if (arguments.length >= 3)
		to.innerHTML += " " + from.innerHTML;
	else
		to.value += " " + from.value;
}

function setMyFocus(id)
{
	var x = document.getElementById(id);
	if (x) x.focus();
}

function setCSSClass(id, css_class)
{
	var x = document.getElementById(id);
	if (x) {
		x.className = css_class;
		x.setAttribute("class", css_class);
	}
}

function setHTML(id, content)
{
	var x = document.getElementById(id);
	if (x) x.innerHTML = content;
}

function appendTableRow(table_id, row_id, data, row_class, cell_class, colspan, table_row)
{
	var table = document.getElementById(table_id);
	
	var col_span = -1;
	if (arguments.length >= 6)
		col_span = colspan;
	
	var index = table.rows.length;
	if (arguments.length >= 7)
		index = table_row;
		
	var row = table.insertRow(index);
		
	row.setAttribute("id", row_id);
	
	for (c = 0; c < data.length; c++) {
		var cell = row.insertCell(c);
		cell.innerHTML = data[c];
		cell.className = cell_class;
		cell.setAttribute("class", cell_class);
		
		if (col_span > -1 && i == data.length-1)
			cell.setAttribute("colspan", col_span);
	}
	
	//why does this suddenly work?
	row.className = row_class;
	row.setAttribute("class", row_class);
	
	/*t_row_id =		row_id;
	t_row_class =	row_class;*/
	
	/*oh sweet Moses, IE is a piece of junk*/
	/*setTimeout("_appendTableRowClass();", 1);*/
}

/*var t_row_id; var t_row_class;
function _appendTableRowClass()
{
	var d = document.getElementById(t_row_id);
	if (d) {
		d.className = t_row_class;
		d.setAttribute("class", t_row_class);
	}
}*/

function createElement(tag_type, tag_id, tag_class)
{
	var d = document.createElement(tag_type);
	
	if (navigator.userAgent.indexOf("MSIE")>=0) {
		document.body.appendChild(d);
		d.setAttribute("id", tag_id);
		d.className = tag_class;
		d.setAttribute("class", tag_class);
	} else {
		d.setAttribute("id", tag_id);
		d.className = tag_class;
		d.setAttribute("class", tag_class);
		document.documentElement.appendChild(d);
	}
	
	return d;
}

function getArrayOfElements(names)
{
	var e = Array();
	
	var numNames = names.length;
	
	for (i = 0; i < numNames; i++)
		e[i] = document.getElementById(names[i]);
		
	return e;
}

var posX = 0;	var posY = 0;
window.document.onmousemove = getMouseXY;
function getMouseXY(e)
{
	if (navigator.userAgent.indexOf("MSIE")>=0) {
		posX = window.event.clientX;
 		posY = window.event.clientY;
	} else {
		posX = e.pageX;
	 	posY = e.pageY;
	}

	if (posX <= 0) {posX = 0;} 
	if (posY <= 0) {posY = 0;}

 	return true;
}

function showBlock(id)
{
	var d = document.getElementById(id);

	if (d)	d.style.visibility = 'visible';
}

function hideBlock(id)
{
	var d = document.getElementById(id);

	if (d)	d.style.visibility = 'hidden';
}

function collapseBlock(id)
{
	var d = document.getElementById(id);

	if (d)	d.style.visibility = 'collapse';
}